Package jadex.common

Class Tuple

java.lang.Object
jadex.common.Tuple
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
Tuple2, Tuple3

public class Tuple extends Object implements Cloneable, Serializable
A tuple is a list of entities. The entities of a tuple may be null. The equals and hashCode methods are overridden, such that two tuples are equal and have the same hashcode, if they contain the same entities. Therefore tuples can be used for multipart keys in hashtables.
See Also:
  • Field Details

    • entities

      protected Object[] entities
      The entities of the tuple.
  • Constructor Details

    • Tuple

      public Tuple(Object entity1, Object entity2)
      Convenience constructor for binary tuples.
      Parameters:
      entity1 - The first object in the tuple.
      entity2 - The second object in the tuple.
    • Tuple

      public Tuple(Object entity1, Object entity2, Object entity3)
      Convenience constructor for binary tuples.
      Parameters:
      entity1 - The first object in the tuple.
      entity2 - The second object in the tuple.
      entity3 - The third object in the tuple.
    • Tuple

      public Tuple(Object[] entities)
      Create a new tuple.
      Parameters:
      entities - The objects in the tuple.
  • Method Details

    • getEntity

      public Object getEntity(int n)
      Get an entity.
      Parameters:
      n - The entities position.
      Returns:
      The entity.
    • getEntities

      public Object[] getEntities()
      Get entities
      Returns:
      The entities.
    • get

      public Object get(int n)
      Get an entity.
      Parameters:
      n - The entities position.
      Returns:
      The entity.
    • size

      public int size()
      Get the size.
      Returns:
      The size.
    • hashCode

      public int hashCode()
      Compute the hashcode of the tuple.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Test two tuples for equality.
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Convert this tuple to a string representation.
      Overrides:
      toString in class Object
      Returns:
      A string representation of this tuple.
    • clone

      public Object clone() throws CloneNotSupportedException
      Clone this tuple.
      Overrides:
      clone in class Object
      Returns:
      A shallow copy of this tuple.
      Throws:
      CloneNotSupportedException
    • main

      public static void main(String[] args) throws Exception
      Throws:
      Exception