Class Pair<T1,T2>
- java.lang.Object
-
- com.saperion.common.lang.encapsulation.Pair<T1,T2>
-
- Type Parameters:
T1- type of first objectT2- type of second object
- All Implemented Interfaces:
java.io.Serializable
public class Pair<T1,T2> extends java.lang.Object implements java.io.SerializableA simple immutable encapsulation for 2 objects.
An instance of this
Paircan be used in several threads concurrently.- Author:
- agz
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)T1getFirst()Returns the first object.T2getSecond()Returns the second object.inthashCode()static <T1,T2>
Pair<T1,T2>newInstance(T1 first, T2 second)Convenience factory method for letting the compiler do the type inference.java.lang.StringtoString()
-
-
-
Method Detail
-
getFirst
public final T1 getFirst()
Returns the first object.- Returns:
- first object
-
getSecond
public final T2 getSecond()
Returns the second object.- Returns:
- second object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
newInstance
public static <T1,T2> Pair<T1,T2> newInstance(T1 first, T2 second)
Convenience factory method for letting the compiler do the type inference.- Parameters:
first- The first object in the pairsecond- The second object in the pair- Returns:
- A pair consisting of the given objects
-
-