A - the first element typeB - the second element typeC - the third element typepublic final class Triple<A,B,C> extends Object implements org.joda.beans.ImmutableBean, Tuple, Comparable<Triple<A,B,C>>, Serializable
This implementation refers to the elements as 'first', 'second' and 'third'. The elements cannot be null.
Although the implementation is immutable, there is no restriction on the objects that may be stored. If mutable objects are stored in the triple, then the triple itself effectively becomes mutable.
This class is immutable and thread-safe if the stored objects are immutable.
| Modifier and Type | Class and Description |
|---|---|
static class |
Triple.Meta<A,B,C>
The meta-bean for
Triple. |
| Modifier and Type | Method and Description |
|---|---|
<Q,R,S> Triple<A,B,C> |
combinedWith(Triple<Q,R,S> other,
BiFunction<? super A,? super Q,? extends A> combinerFirst,
BiFunction<? super B,? super R,? extends B> combinerSecond,
BiFunction<? super C,? super S,? extends C> combinerThird)
Combines this instance with another.
|
static <A,B,C> BinaryOperator<Triple<A,B,C>> |
combining(BiFunction<? super A,? super A,? extends A> combinerFirst,
BiFunction<? super B,? super B,? extends B> combinerSecond,
BiFunction<? super C,? super C,? extends C> combinerThird)
Returns a combiner of triple instances.
|
int |
compareTo(Triple<A,B,C> other)
Compares the triple based on the first element followed by the second
element followed by the third element.
|
ImmutableList<Object> |
elements()
Gets the elements from this triple as a list.
|
boolean |
equals(Object obj) |
A |
getFirst()
Gets the first element in this triple.
|
B |
getSecond()
Gets the second element in this triple.
|
C |
getThird()
Gets the third element in this triple.
|
int |
hashCode() |
static Triple.Meta |
meta()
The meta-bean for
Triple. |
Triple.Meta<A,B,C> |
metaBean() |
static <R,S,T> Triple.Meta<R,S,T> |
metaTriple(Class<R> cls1,
Class<S> cls2,
Class<T> cls3)
The meta-bean for
Triple. |
static <A,B,C> Triple<A,B,C> |
of(A first,
B second,
C third)
Obtains a triple inferring the types.
|
int |
size()
Gets the number of elements held by this triple.
|
String |
toString()
Gets the triple using a standard string format.
|
public static <A,B,C> Triple<A,B,C> of(A first, B second, C third)
A - the first element typeB - the second element typeC - the third element typefirst - the first elementsecond - the second elementthird - the third elementpublic static <A,B,C> BinaryOperator<Triple<A,B,C>> combining(BiFunction<? super A,? super A,? extends A> combinerFirst, BiFunction<? super B,? super B,? extends B> combinerSecond, BiFunction<? super C,? super C,? extends C> combinerThird)
This is useful if you have a stream of Triple<A, B, C> and would like to call reduce.
e.g
tripleList.stream()
.reduce(Triple.combining(A::combinedWith, B::combinedWith, C::combinedWith))
A - the type of the first valuesB - the type of the second valuesC - the type of the third valuescombinerFirst - the combiner of first valuescombinerSecond - the combiner of second valuescombinerThird - the combiner of third valuespublic <Q,R,S> Triple<A,B,C> combinedWith(Triple<Q,R,S> other, BiFunction<? super A,? super Q,? extends A> combinerFirst, BiFunction<? super B,? super R,? extends B> combinerSecond, BiFunction<? super C,? super S,? extends C> combinerThird)
Q - the type of the first value in the other instanceR - the type of the second value in the other instanceS - the type of the third value in the other instanceother - the other triplecombinerFirst - the combiner of first valuescombinerSecond - the combiner of second valuescombinerThird - the combiner of third valuespublic int size()
public ImmutableList<Object> elements()
The list returns each element in the triple in order.
public int compareTo(Triple<A,B,C> other)
The element types must be Comparable.
compareTo in interface Comparable<Triple<A,B,C>>other - the other tripleClassCastException - if either object is not comparablepublic String toString()
The standard format is '[$first, $second, $third]'. Spaces around the values are trimmed.
public static Triple.Meta meta()
Triple.public static <R,S,T> Triple.Meta<R,S,T> metaTriple(Class<R> cls1, Class<S> cls2, Class<T> cls3)
Triple.R - the first generic typeS - the second generic typeT - the second generic typecls1 - the first generic typecls2 - the second generic typecls3 - the third generic typepublic Triple.Meta<A,B,C> metaBean()
metaBean in interface org.joda.beans.Beanpublic A getFirst()
public B getSecond()
public C getThird()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.