L - the type of the "left" side of the pair.R - the type of the "right" side of the pair.public abstract class Pair<L,R> extends java.lang.Object implements java.util.Map.Entry<L,R>, java.lang.Comparable<Pair<L,R>>, java.lang.Cloneable, java.io.Serializable
left" and "right". Pairs implement Map.Entry where
the key is the "left" side and the value is the "right" side.| Constructor and Description |
|---|
Pair() |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
apply(java.util.function.BiFunction<? super L,? super R,? extends T> function) |
Pair<L,R> |
clone() |
int |
compareTo(Pair<L,R> that) |
static <K,V> Pair<K,V> |
copy(java.util.Map.Entry<? extends K,? extends V> entry) |
boolean |
equals(java.lang.Object o) |
static <K,V> Pair<K,V> |
from(java.util.Map.Entry<? extends K,? extends V> entry) |
L |
getKey() |
abstract L |
getLeft() |
abstract R |
getRight() |
R |
getValue() |
int |
hashCode() |
<T> java.util.Iterator<T> |
iterator() |
<LL,RR> Pair<LL,RR> |
map(java.util.function.BiFunction<? super L,? super R,? extends Pair<LL,RR>> mapper) |
<LL,RR> Pair<LL,RR> |
map(java.util.function.Function<? super L,? extends LL> leftMapper,
java.util.function.Function<? super R,? extends RR> rightMapper) |
static <L,R> Pair<L,R> |
of(L left,
R right) |
java.util.Map<L,R> |
put(java.util.Map<L,R> map) |
R |
setValue(R value)
This operation is not supported and throws
UnsupportedOperationException. |
<RR> Pair<R,RR> |
shiftLeft(RR replacement) |
<LL> Pair<LL,L> |
shiftRight(LL replacement) |
Pair<R,L> |
swap() |
boolean |
test(java.util.function.BiPredicate<? super L,? super R> predicate) |
boolean |
test(java.util.function.Predicate<? super L> leftPredicate,
java.util.function.Predicate<? super R> rightPredicate) |
java.lang.String |
toString() |
static <T> Pair<T,T> |
unary(T item) |
<LL> Pair<LL,R> |
withLeft(LL left) |
<RR> Pair<L,RR> |
withRight(RR right) |
public static <L,R> Pair<L,R> of(L left, R right)
Pair of the two objects given.public static <K,V> Pair<K,V> from(java.util.Map.Entry<? extends K,? extends V> entry)
Pair that delegates to the given Map.Entry, key being left and value being right.public static <K,V> Pair<K,V> copy(java.util.Map.Entry<? extends K,? extends V> entry)
Pair created from the key and value of the given entry, key being left and value being right.public static <T> Pair<T,T> unary(T item)
Pair where both objects are the same.public abstract L getLeft()
Pair.public abstract R getRight()
Pair.public L getKey()
public R getValue()
public R setValue(R value)
UnsupportedOperationException.public Pair<R,L> swap()
Pair with the "left" and "right" components of this Pair swapped.public <LL> Pair<LL,R> withLeft(LL left)
Pair where the "left" component is replaced with the given value.public <RR> Pair<L,RR> withRight(RR right)
Pair where the "right" component is replaced with the given value.public <LL> Pair<LL,L> shiftRight(LL replacement)
Pair where the "left" component is shifted to the "right" component and replaced with the
given value.public <RR> Pair<R,RR> shiftLeft(RR replacement)
Pair where the "right" component is shifted to the "left" component and replaced with the
given value.public <LL,RR> Pair<LL,RR> map(java.util.function.Function<? super L,? extends LL> leftMapper, java.util.function.Function<? super R,? extends RR> rightMapper)
Pair mapped from this Pair using the given mappers.public <LL,RR> Pair<LL,RR> map(java.util.function.BiFunction<? super L,? super R,? extends Pair<LL,RR>> mapper)
Pair mapped from this Pair using the given mapper.public <T> T apply(java.util.function.BiFunction<? super L,? super R,? extends T> function)
BiFunction to the "left" and "right" components of this
Pair.public boolean test(java.util.function.Predicate<? super L> leftPredicate, java.util.function.Predicate<? super R> rightPredicate)
Predicates on the "left" and "right" components of this
Pair.public boolean test(java.util.function.BiPredicate<? super L,? super R> predicate)
BiPredicates on the "left" and "right" components of this
Pair.public <T> java.util.Iterator<T> iterator()
Pair, containing exactly two elements.public int hashCode()
public boolean equals(java.lang.Object o)
public java.lang.String toString()
toString in class java.lang.Object