Interface Pair<L,R>
- Type Parameters:
L
- the type of the left element.R
- the type of the right element.
- All Known Subinterfaces:
BooleanBooleanPair
,BooleanBytePair
,BooleanCharPair
,BooleanDoublePair
,BooleanFloatPair
,BooleanIntPair
,BooleanLongPair
,BooleanObjectPair<V>
,BooleanReferencePair<V>
,BooleanShortPair
,ByteBooleanPair
,ByteBytePair
,ByteByteSortedPair
,ByteCharPair
,ByteDoublePair
,ByteFloatPair
,ByteIntPair
,ByteLongPair
,ByteObjectPair<V>
,ByteReferencePair<V>
,ByteShortPair
,CharBooleanPair
,CharBytePair
,CharCharPair
,CharCharSortedPair
,CharDoublePair
,CharFloatPair
,CharIntPair
,CharLongPair
,CharObjectPair<V>
,CharReferencePair<V>
,CharShortPair
,DoubleBooleanPair
,DoubleBytePair
,DoubleCharPair
,DoubleDoublePair
,DoubleDoubleSortedPair
,DoubleFloatPair
,DoubleIntPair
,DoubleLongPair
,DoubleObjectPair<V>
,DoubleReferencePair<V>
,DoubleShortPair
,FloatBooleanPair
,FloatBytePair
,FloatCharPair
,FloatDoublePair
,FloatFloatPair
,FloatFloatSortedPair
,FloatIntPair
,FloatLongPair
,FloatObjectPair<V>
,FloatReferencePair<V>
,FloatShortPair
,IntBooleanPair
,IntBytePair
,IntCharPair
,IntDoublePair
,IntFloatPair
,IntIntPair
,IntIntSortedPair
,IntLongPair
,IntObjectPair<V>
,IntReferencePair<V>
,IntShortPair
,LongBooleanPair
,LongBytePair
,LongCharPair
,LongDoublePair
,LongFloatPair
,LongIntPair
,LongLongPair
,LongLongSortedPair
,LongObjectPair<V>
,LongReferencePair<V>
,LongShortPair
,ObjectBooleanPair<K>
,ObjectBytePair<K>
,ObjectCharPair<K>
,ObjectDoublePair<K>
,ObjectFloatPair<K>
,ObjectIntPair<K>
,ObjectLongPair<K>
,ObjectReferencePair<K,
,V> ObjectShortPair<K>
,ReferenceBooleanPair<K>
,ReferenceBytePair<K>
,ReferenceCharPair<K>
,ReferenceDoublePair<K>
,ReferenceFloatPair<K>
,ReferenceIntPair<K>
,ReferenceLongPair<K>
,ReferenceObjectPair<K,
,V> ReferenceReferencePair<K,
,V> ReferenceShortPair<K>
,ShortBooleanPair
,ShortBytePair
,ShortCharPair
,ShortDoublePair
,ShortFloatPair
,ShortIntPair
,ShortLongPair
,ShortObjectPair<V>
,ShortReferencePair<V>
,ShortShortPair
,ShortShortSortedPair
,SortedPair<K>
- All Known Implementing Classes:
BooleanBooleanImmutablePair
,BooleanBooleanMutablePair
,BooleanByteImmutablePair
,BooleanByteMutablePair
,BooleanCharImmutablePair
,BooleanCharMutablePair
,BooleanDoubleImmutablePair
,BooleanDoubleMutablePair
,BooleanFloatImmutablePair
,BooleanFloatMutablePair
,BooleanIntImmutablePair
,BooleanIntMutablePair
,BooleanLongImmutablePair
,BooleanLongMutablePair
,BooleanObjectImmutablePair
,BooleanObjectMutablePair
,BooleanReferenceImmutablePair
,BooleanReferenceMutablePair
,BooleanShortImmutablePair
,BooleanShortMutablePair
,ByteBooleanImmutablePair
,ByteBooleanMutablePair
,ByteByteImmutablePair
,ByteByteImmutableSortedPair
,ByteByteMutablePair
,ByteCharImmutablePair
,ByteCharMutablePair
,ByteDoubleImmutablePair
,ByteDoubleMutablePair
,ByteFloatImmutablePair
,ByteFloatMutablePair
,ByteIntImmutablePair
,ByteIntMutablePair
,ByteLongImmutablePair
,ByteLongMutablePair
,ByteObjectImmutablePair
,ByteObjectMutablePair
,ByteReferenceImmutablePair
,ByteReferenceMutablePair
,ByteShortImmutablePair
,ByteShortMutablePair
,CharBooleanImmutablePair
,CharBooleanMutablePair
,CharByteImmutablePair
,CharByteMutablePair
,CharCharImmutablePair
,CharCharImmutableSortedPair
,CharCharMutablePair
,CharDoubleImmutablePair
,CharDoubleMutablePair
,CharFloatImmutablePair
,CharFloatMutablePair
,CharIntImmutablePair
,CharIntMutablePair
,CharLongImmutablePair
,CharLongMutablePair
,CharObjectImmutablePair
,CharObjectMutablePair
,CharReferenceImmutablePair
,CharReferenceMutablePair
,CharShortImmutablePair
,CharShortMutablePair
,DoubleBooleanImmutablePair
,DoubleBooleanMutablePair
,DoubleByteImmutablePair
,DoubleByteMutablePair
,DoubleCharImmutablePair
,DoubleCharMutablePair
,DoubleDoubleImmutablePair
,DoubleDoubleImmutableSortedPair
,DoubleDoubleMutablePair
,DoubleFloatImmutablePair
,DoubleFloatMutablePair
,DoubleIntImmutablePair
,DoubleIntMutablePair
,DoubleLongImmutablePair
,DoubleLongMutablePair
,DoubleObjectImmutablePair
,DoubleObjectMutablePair
,DoubleReferenceImmutablePair
,DoubleReferenceMutablePair
,DoubleShortImmutablePair
,DoubleShortMutablePair
,FloatBooleanImmutablePair
,FloatBooleanMutablePair
,FloatByteImmutablePair
,FloatByteMutablePair
,FloatCharImmutablePair
,FloatCharMutablePair
,FloatDoubleImmutablePair
,FloatDoubleMutablePair
,FloatFloatImmutablePair
,FloatFloatImmutableSortedPair
,FloatFloatMutablePair
,FloatIntImmutablePair
,FloatIntMutablePair
,FloatLongImmutablePair
,FloatLongMutablePair
,FloatObjectImmutablePair
,FloatObjectMutablePair
,FloatReferenceImmutablePair
,FloatReferenceMutablePair
,FloatShortImmutablePair
,FloatShortMutablePair
,IntBooleanImmutablePair
,IntBooleanMutablePair
,IntByteImmutablePair
,IntByteMutablePair
,IntCharImmutablePair
,IntCharMutablePair
,IntDoubleImmutablePair
,IntDoubleMutablePair
,IntFloatImmutablePair
,IntFloatMutablePair
,IntIntImmutablePair
,IntIntImmutableSortedPair
,IntIntMutablePair
,IntLongImmutablePair
,IntLongMutablePair
,IntObjectImmutablePair
,IntObjectMutablePair
,IntReferenceImmutablePair
,IntReferenceMutablePair
,IntShortImmutablePair
,IntShortMutablePair
,LongBooleanImmutablePair
,LongBooleanMutablePair
,LongByteImmutablePair
,LongByteMutablePair
,LongCharImmutablePair
,LongCharMutablePair
,LongDoubleImmutablePair
,LongDoubleMutablePair
,LongFloatImmutablePair
,LongFloatMutablePair
,LongIntImmutablePair
,LongIntMutablePair
,LongLongImmutablePair
,LongLongImmutableSortedPair
,LongLongMutablePair
,LongObjectImmutablePair
,LongObjectMutablePair
,LongReferenceImmutablePair
,LongReferenceMutablePair
,LongShortImmutablePair
,LongShortMutablePair
,ObjectBooleanImmutablePair
,ObjectBooleanMutablePair
,ObjectByteImmutablePair
,ObjectByteMutablePair
,ObjectCharImmutablePair
,ObjectCharMutablePair
,ObjectDoubleImmutablePair
,ObjectDoubleMutablePair
,ObjectFloatImmutablePair
,ObjectFloatMutablePair
,ObjectIntImmutablePair
,ObjectIntMutablePair
,ObjectLongImmutablePair
,ObjectLongMutablePair
,ObjectObjectImmutablePair
,ObjectObjectImmutableSortedPair
,ObjectObjectMutablePair
,ObjectReferenceImmutablePair
,ObjectReferenceMutablePair
,ObjectShortImmutablePair
,ObjectShortMutablePair
,ReferenceBooleanImmutablePair
,ReferenceBooleanMutablePair
,ReferenceByteImmutablePair
,ReferenceByteMutablePair
,ReferenceCharImmutablePair
,ReferenceCharMutablePair
,ReferenceDoubleImmutablePair
,ReferenceDoubleMutablePair
,ReferenceFloatImmutablePair
,ReferenceFloatMutablePair
,ReferenceIntImmutablePair
,ReferenceIntMutablePair
,ReferenceLongImmutablePair
,ReferenceLongMutablePair
,ReferenceObjectImmutablePair
,ReferenceObjectMutablePair
,ReferenceReferenceImmutablePair
,ReferenceReferenceMutablePair
,ReferenceShortImmutablePair
,ReferenceShortMutablePair
,ShortBooleanImmutablePair
,ShortBooleanMutablePair
,ShortByteImmutablePair
,ShortByteMutablePair
,ShortCharImmutablePair
,ShortCharMutablePair
,ShortDoubleImmutablePair
,ShortDoubleMutablePair
,ShortFloatImmutablePair
,ShortFloatMutablePair
,ShortIntImmutablePair
,ShortIntMutablePair
,ShortLongImmutablePair
,ShortLongMutablePair
,ShortObjectImmutablePair
,ShortObjectMutablePair
,ShortReferenceImmutablePair
,ShortReferenceMutablePair
,ShortShortImmutablePair
,ShortShortImmutableSortedPair
,ShortShortMutablePair
This inferface gives access to a pair of elements <l, r>, where l is the left element and r is the right element. Mutability is optional.
Since pairs have many different interpretation depending on the context, this interface offers
alternative but equivalent access methods based on first/second and key/value. All
such methods have default implementations that delegates to the standard methods. Implementations
need only to provide left()
and right()
, and possibly left(Object)
and
right(Object)
for mutability.
Setters return the instance, and are thus chainable. You can write
pair.left(0).right(1)and, if necessary, pass this value to a method.
-
Method Summary
Modifier and TypeMethodDescriptiondefault L
first()
Returns the left element of this pair.Sets the left element of this pair (optional operation).default L
key()
Returns the left element of this pair.Sets the left element of this pair (optional operation).left()
Returns the left element of this pair.Sets the left element of this pair (optional operation).static <L,
R> Comparator <Pair<L, R>> Returns a lexicographical comparator for pairs.static <L,
R> Pair <L, R> of
(L l, R r) Returns a new immutablePair
with given left and right value.right()
Returns the right element of this pair.Sets the right element of this pair (optional operation).default R
second()
Returns the right element of this pair.Sets the right element of this pair (optional operation).default R
value()
Returns the right element of this pair.Sets the right element of this pair (optional operation).
-
Method Details
-
left
L left()Returns the left element of this pair.- Returns:
- the left element of this pair.
-
right
R right()Returns the right element of this pair.- Returns:
- the right element of this pair.
-
left
Sets the left element of this pair (optional operation).- Parameters:
l
- a new value for the left element.- Implementation Notes:
- This implementation throws an
UnsupportedOperationException
.
-
right
Sets the right element of this pair (optional operation).- Parameters:
r
- a new value for the right element.- Implementation Notes:
- This implementation throws an
UnsupportedOperationException
.
-
first
Returns the left element of this pair.- Returns:
- the left element of this pair.
- Implementation Notes:
- This implementation delegates to
left()
.
-
second
Returns the right element of this pair.- Returns:
- the right element of this pair.
- Implementation Notes:
- This implementation delegates to
right()
.
-
first
Sets the left element of this pair (optional operation).- Parameters:
l
- a new value for the left element.- Implementation Notes:
- This implementation delegates to
left(Object)
.
-
second
Sets the right element of this pair (optional operation).- Parameters:
r
- a new value for the right element.- Implementation Notes:
- This implementation delegates to
right(Object)
.
-
key
Sets the left element of this pair (optional operation).- Parameters:
l
- a new value for the left element.- Implementation Notes:
- This implementation delegates to
left(Object)
.
-
value
Sets the right element of this pair (optional operation).- Parameters:
r
- a new value for the right element.- Implementation Notes:
- This implementation delegates to
right(Object)
.
-
key
Returns the left element of this pair.- Returns:
- the left element of this pair.
- Implementation Notes:
- This implementation delegates to
left()
.
-
value
Returns the right element of this pair.- Returns:
- the right element of this pair.
- Implementation Notes:
- This implementation delegates to
right()
.
-
of
Returns a new immutablePair
with given left and right value.- Parameters:
l
- the left value.r
- the right value.- Implementation Notes:
- This factory method returns an instance of
ObjectObjectImmutablePair
.
-
lexComparator
Returns a lexicographical comparator for pairs.The comparator returned by this method implements lexicographical order. It compares first the left elements: if the result of the comparison is nonzero, it returns said result. Otherwise, this comparator returns the result of the comparison of the right elements.
- Returns:
- a lexicographical comparator for pairs.
-