Package de.scravy.bedrock
Class Pair<A,B>
java.lang.Object
de.scravy.bedrock.Pair<A,B>
- Type Parameters:
A- The first component of the tuple.B- The second component of the tuple.
- All Implemented Interfaces:
Tuple2<A,B>,Serializable,Comparable<Pair<A,B>>,Map.Entry<A,B>
@Immutable public class Pair<A,B> extends Object implements Map.Entry<A,B>, Serializable, Comparable<Pair<A,B>>, Tuple2<A,B>
An immutable tuple.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description Pair() -
Method Summary
Modifier and Type Method Description intcompareTo(Pair<A,B> p)static <A, B, L extends HList<L>>
Pair<A,B>fromHList(C<A,C<B,L>> hlist)Afst()AgetKey()BgetValue()<C, D> Pair<C,D>map(Function<A,C> f, Function<B,D> g)<C> Pair<C,B>mapFirst(Function<A,C> f)<C> Pair<A,C>mapSecond(Function<B,C> f)static <A, B> Pair<A,B>of(A a, B b)static <A, B> Pair<A,B>of(Map.Entry<A,B> entry)static <A, B> Pair<A,B>pair(A a, B b)BsetValue(B value)Since tuples are immutable this method will throw an UnsupportedOperationException.Bsnd()Pair<B,A>swapped()C<A,C<B,Nil>>toHList()static <C, A extends C, B extends C>
List<C>toList(Tuple2<A,B> pair)static <C, A extends C, B extends C>
Seq<C>toSeq(Tuple2<A,B> pair)<C> Pair<C,B>withFirst(C v)<C> Pair<A,C>withSecond(C v)
-
Constructor Details
-
Pair
public Pair()
-
-
Method Details
-
fst
-
snd
-
getKey
-
getValue
-
setValue
Since tuples are immutable this method will throw an UnsupportedOperationException. It is only defined to implement the Map.Entry interface.- Specified by:
setValuein interfaceMap.Entry<A,B>- Parameters:
value- No matter what you throw in, this method is not supported.- Returns:
- Nothing, it throws an UnsupportedOperationException.
- Throws:
UnsupportedOperationException- Thrown always.
-
compareTo
- Specified by:
compareToin interfaceComparable<A>
-
pair
-
of
-
of
-
toList
-
swapped
-
toHList
-
fromHList
-
toSeq
-
map
-
mapFirst
-
mapSecond
-
withFirst
-
withSecond
-