org.omnaest.utils.tuple
Class Tuple2<T1,T2>

java.lang.Object
  extended by org.omnaest.utils.tuple.Tuple2<T1,T2>
All Implemented Interfaces:
Serializable, Tuple
Direct Known Subclasses:
MapDelta.Values, MapJoiner.JoinedValue

public class Tuple2<T1,T2>
extends Object
implements Tuple

Two arguments Tuple supporting hashCode(), equals(Object) and toString() using the values of the given elements.

Author:
Omnaest
See Also:
Tuple, Tuple3, Serialized Form

Field Summary
protected  T1 valueFirst
           
protected  T2 valueSecond
           
 
Constructor Summary
Tuple2()
           
Tuple2(T1 valueFirst, T2 valueSecond)
           
Tuple2(Tuple2<T1,T2> tuple2)
          Creates a new Tuple2 instance based on the values of an already existing instance
 
Method Summary
 Map<T1,T2> asMap()
          Returns a Map containing an entry based on this Tuple.
 boolean equals(Object obj)
           
 T1 getValueFirst()
          Returns the first value of the Tuple.
 T2 getValueSecond()
          Returns the second value of the Tuple.
 int hashCode()
           
 Tuple2<T2,T1> newInvertedInstance()
          Returns a new Tuple2 instance with inverted first and second value
 void setValueFirst(T1 valueFirst)
          Sets the first value of the Tuple.
 void setValueSecond(T2 valueSecond)
          Sets the second value of the Tuple.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

valueFirst

protected T1 valueFirst

valueSecond

protected T2 valueSecond
Constructor Detail

Tuple2

public Tuple2()
See Also:
Tuple2

Tuple2

public Tuple2(T1 valueFirst,
              T2 valueSecond)
Parameters:
valueFirst -
valueSecond -
See Also:
Tuple2

Tuple2

public Tuple2(Tuple2<T1,T2> tuple2)
Creates a new Tuple2 instance based on the values of an already existing instance

Parameters:
tuple2 -
See Also:
Tuple2
Method Detail

newInvertedInstance

public Tuple2<T2,T1> newInvertedInstance()
Returns a new Tuple2 instance with inverted first and second value

Returns:
Tuple2

getValueFirst

public T1 getValueFirst()
Returns the first value of the Tuple.

Returns:

setValueFirst

public void setValueFirst(T1 valueFirst)
Sets the first value of the Tuple.

Parameters:
valueFirst -

getValueSecond

public T2 getValueSecond()
Returns the second value of the Tuple.

Returns:

setValueSecond

public void setValueSecond(T2 valueSecond)
Sets the second value of the Tuple.

Parameters:
valueSecond -

asMap

public Map<T1,T2> asMap()
Returns a Map containing an entry based on this Tuple.

Returns:

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2013. All Rights Reserved.