This class is an abstract implementation defining the basic API.
It refers to the elements as 'left' and 'right'. It also implements the
Map.Entry interface where the key is 'left' and the value is 'right'.
Subclass implementations may be mutable or immutable. However, there is no restriction on the type of the stored objects that may be stored. If mutable objects are stored in the pair, then the pair itself effectively becomes mutable.
| Modifier and Type | Field and Description |
|---|---|
| public static final Pair | EMPTY_ARRAY
An empty array. |
| private static final long | serialVersionUID
Serialization version |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public < The kind of thrown exception or error. E extends Throwable> void | accept(final FailableBiConsumer<L, R, E>
the consumer to call. consumer)Accepts this key and value as arguments to the given consumer. |
| public < The function return type. V, The kind of thrown exception or error. E extends Throwable> V | Returns: the function's return value.the consumer to call. function)Applies this key and value as arguments to the given function. |
| public int | Returns: negative if this is less, zero if equal, positive if greater.the other pair, not null. other)Implements java. Compares the pair based on the left element followed by the right element. |
| public static < the left element type. L, the right element type. R> Pair | Returns: the empty array singleton that can be assigned without compiler warning.Returns the empty array singleton that can be assigned without compiler warning. |
| public boolean | Returns: true if the elements of the pair are equal.the object to compare to, null returns false. obj)Overrides java. Implements java. Compares this pair to another based on the two elements. |
| public final L | Returns: the left element as the key, may be null.Implements java. Gets the key from this pair. |
| public abstract L | |
| public abstract R | |
| public R | Returns: the right element as the value, may be null.Implements java. Gets the value from this pair. |
| public int | Returns: the hash code.Overrides java. Implements java. Returns a suitable hash code. |
| public static < the left element type. L, the right element type. R> Pair | Returns: an immutable pair formed from the two parameters, not null.the left element, may be null. left, final R the right element, may be null. right)Creates an immutable pair of two objects inferring the generic types. |
| public static < the left element type. L, the right element type. R> Pair | |
| public static < the left element type. L, the right element type. R> Pair | Returns: an immutable pair formed from the two parameters, not null.the left element, may not be null. left, final R the right element, may not be null. right)Creates an immutable pair of two non-null objects inferring the generic types. |
| public String | Returns: a string describing this object, not null.Overrides java. Returns a String representation of this pair using the format |
| public String |
| EMPTY_ARRAY | back to summary |
|---|---|
| public static final Pair<?, ?>[] EMPTY_ARRAY An empty array.
Consider using
| |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serialization version | |
| Pair | back to summary |
|---|---|
| public Pair() Constructs a new instance. | |
| accept | back to summary |
|---|---|
| public <E extends Throwable> void accept(final FailableBiConsumer<L, R, E> consumer) throws FailableBiConsumer:E Accepts this key and value as arguments to the given consumer.
| |
| apply | back to summary |
|---|---|
| public <V, E extends Throwable> V apply(final FailableBiFunction<L, R, V, E> function) throws FailableBiConsumer:E Applies this key and value as arguments to the given function.
| |
| compareTo | back to summary |
|---|---|
| public int compareTo(final Pair<L, R> other) Implements java. Compares the pair based on the left element followed by the right element.
The types must be | |
| emptyArray | back to summary |
|---|---|
| public static <L, R> Pair Returns the empty array singleton that can be assigned without compiler warning.
| |
| equals | back to summary |
|---|---|
| public boolean equals(final Object obj) Overrides java. Implements java. Compares this pair to another based on the two elements. | |
| getKey | back to summary |
|---|---|
| public final L getKey() Implements java. Gets the key from this pair. This method implements the
| |
| getLeft | back to summary |
|---|---|
| public abstract L getLeft() Gets the left element from this pair. When treated as a key-value pair, this is the key.
| |
| getRight | back to summary |
|---|---|
| public abstract R getRight() Gets the right element from this pair. When treated as a key-value pair, this is the value.
| |
| getValue | back to summary |
|---|---|
| public R getValue() Implements java. Gets the value from this pair. This method implements the
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Returns a suitable hash code.
The hash code follows the definition in
| |
| of | back to summary |
|---|---|
| public static <L, R> Pair Creates an immutable pair of two objects inferring the generic types.
| |
| of | back to summary |
|---|---|
| public static <L, R> Pair Creates an immutable pair from a map entry. | |
| ofNonNull | back to summary |
|---|---|
| public static <L, R> Pair Creates an immutable pair of two non-null objects inferring the generic types.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a String representation of this pair using the format | |
| toString | back to summary |
|---|---|
| public String toString(final String format) Formats the receiver using the given format.
This uses
| |