Package no.digipost.tuple
Interface Triple<T1,T2,T3>
- Type Parameters:
T1- The type of the first valueT2- The type of the second valueT3- The type of the third value
- All Superinterfaces:
ViewableAsTriple<T1,T2, T3>
A triple is a simple composition of three arbitrary values (objects). A triple
captures no semantics of the three values, and they are only referred to as
"the first", "the second", and "the third" value.
-
Method Summary
Modifier and TypeMethodDescriptionasTriple()first()static <T1,T2, T3> Triple<T1, T2, T3> <S1,S2, S3> Triple<S1, S2, S3> map(Function<? super T1, ? extends S1> firstMapper, Function<? super T2, ? extends S2> secondMapper, Function<? super T3, ? extends S3> thirdMapper) Create a new triple by applying a function to each element, and putting the results into a new triple.Create a new triple by applying a function to the first element, and putting the result as the first element of the new triple.Create a new triple by applying a function to the second element, and putting the result as the second element of the new triple.Create a new triple by applying a function to the third element, and putting the result as the third element of the new triple.static <T1,T2, T3> Triple<T1, T2, T3> of(T1 first, T2 second, T3 third) second()third()<R> Rto(TriFunction<? super T1, ? super T2, ? super T3, R> convertor) Convert this triple to an instance of an arbitrary type.
-
Method Details
-
of
-
flatten
-
first
T1 first()- Returns:
- the first value
-
second
T2 second()- Returns:
- the second value
-
third
T3 third()- Returns:
- the third value
-
mapFirst
Create a new triple by applying a function to the first element, and putting the result as the first element of the new triple.- Parameters:
mapper- the function to apply to the first element- Returns:
- the new triple
-
mapSecond
Create a new triple by applying a function to the second element, and putting the result as the second element of the new triple.- Parameters:
mapper- the function to apply to the second element- Returns:
- the new triple
-
mapThird
Create a new triple by applying a function to the third element, and putting the result as the third element of the new triple.- Parameters:
mapper- the function to apply to the third element- Returns:
- the new triple
-
map
<S1,S2, Triple<S1,S3> S2, mapS3> (Function<? super T1, ? extends S1> firstMapper, Function<? super T2, ? extends S2> secondMapper, Function<? super T3, ? extends S3> thirdMapper) Create a new triple by applying a function to each element, and putting the results into a new triple.- Parameters:
firstMapper- the function to apply to the first elementsecondMapper- the function to apply to the second elementthirdMapper- the function to apply to the third element- Returns:
- the new triple
-
asTriple
- Specified by:
asTriplein interfaceViewableAsTriple<T1,T2, T3> - Returns:
- this triple instance
-
to
Convert this triple to an instance of an arbitrary type.- Type Parameters:
R- The type of the resulting instance- Parameters:
convertor- the function used to convert the contained values to a resulting compound instance.- Returns:
- the result from the given function
-