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.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:
Hashtable
,Object.hashCode()
,Object.equals(Object)
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object[]
entities
The 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.Object
clone()
Clone this tuple.boolean
equals(java.lang.Object o)
Test two tuples for equality.java.lang.Object
get(int n)
Get an entity.java.lang.Object[]
getEntities()
Get entitiesjava.lang.Object
getEntity(int n)
Get an entity.int
hashCode()
Compute the hashcode of the tuple.static void
main(java.lang.String[] args)
int
size()
Get the size.java.lang.String
toString()
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:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
Test two tuples for equality.- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
Convert this tuple to a string representation.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of this tuple.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Clone this tuple.- Overrides:
clone
in 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
-
-