Package org.drasyl.util
Class Pair<A,B>
- java.lang.Object
-
- org.drasyl.util.Pair<A,B>
-
- All Implemented Interfaces:
Serializable
public class Pair<A,B> extends Object implements Serializable
A tuple of two elements.Inspired by: https://github.com/javatuples/javatuples/blob/master/src/main/java/org/javatuples/Pair.java
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
A
first()
int
hashCode()
static <A,B>
Pair<A,B>of(A first, B second)
Obtains a tuple of two elements inferring the generic types.B
second()
String
toString()
-
-
-
Method Detail
-
first
public A first()
- Returns:
- the first element
-
second
public B second()
- Returns:
- the second element
-
of
public static <A,B> Pair<A,B> of(A first, B second)
Obtains a tuple of two elements inferring the generic types.
This factory allows the pair to be created using inference to obtain the generic types.
- Type Parameters:
A
- the first element typeB
- the second element type- Parameters:
first
- the first element, may be nullsecond
- the second element, may be null- Returns:
- a pair formed from the two parameters, not null
-
-