T1
- type of the pair's first component.T2
- type of the pair's second component.public final class Pair<T1,T2> extends AbstractPrintable implements Serializable
Note: this class should only be used for internal representations of tuples with value type semantics (e.g. equality, only if all components are equal).
Whenever a public interface returns an aggregation of individual objects, a separate class should be created/used that has meaningful identifiers for the individual components.
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
T1 |
getFirst() |
T2 |
getSecond() |
int |
hashCode() |
static <T1,T2> Pair<T1,T2> |
of(T1 first,
T2 second)
Convenience function for creating a pair, allowing the user to omit the type parameters.
|
void |
print(Appendable a)
Outputs the current object.
|
toString
public static <T1,T2> Pair<T1,T2> of(T1 first, T2 second)
public T1 getFirst()
public T2 getSecond()
public void print(Appendable a) throws IOException
Printable
print
in interface Printable
a
- the appendable.IOException
- if an error occurs during appending.Copyright © 2019. All rights reserved.