Package jadex.commons
Class Tuple
- java.lang.Object
-
- jadex.commons.Tuple
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class Tuple extends java.lang.Object implements java.lang.Cloneable, java.io.SerializableA 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:
Hashtable,Object.hashCode(),Object.equals(Object), Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object[]entitiesThe entities of the tuple.
-
Constructor Summary
Constructors Constructor Description Tuple(java.lang.Object[] entities)Create a new tuple.Tuple(java.lang.Object entity1, java.lang.Object entity2)Convenience constructor for binary tuples.Tuple(java.lang.Object entity1, java.lang.Object entity2, java.lang.Object entity3)Convenience constructor for binary tuples.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Clone this tuple.booleanequals(java.lang.Object o)Test two tuples for equality.java.lang.Objectget(int n)Get an entity.java.lang.Object[]getEntities()Get entitiesjava.lang.ObjectgetEntity(int n)Get an entity.inthashCode()Compute the hashcode of the tuple.static voidmain(java.lang.String[] args)intsize()Get the size.java.lang.StringtoString()Convert this tuple to a string representation.
-
-
-
Constructor Detail
-
Tuple
public Tuple(java.lang.Object entity1, java.lang.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(java.lang.Object entity1, java.lang.Object entity2, java.lang.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(java.lang.Object[] entities)
Create a new tuple.- Parameters:
entities- The objects in the tuple.
-
-
Method Detail
-
getEntity
public java.lang.Object getEntity(int n)
Get an entity.- Parameters:
n- The entities position.- Returns:
- The entity.
-
getEntities
public java.lang.Object[] getEntities()
Get entities- Returns:
- The entities.
-
get
public java.lang.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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
Test two tuples for equality.- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
Convert this tuple to a string representation.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of this tuple.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionClone this tuple.- Overrides:
clonein classjava.lang.Object- Returns:
- A shallow copy of this tuple.
- Throws:
java.lang.CloneNotSupportedException
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception- Throws:
java.lang.Exception
-
-