Class Triple<A,B,C>
- java.lang.Object
-
- com.opengamma.strata.collect.tuple.Triple<A,B,C>
-
- Type Parameters:
A
- the first element typeB
- the second element typeC
- the third element type
- All Implemented Interfaces:
Tuple
,Serializable
,Comparable<Triple<A,B,C>>
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class Triple<A,B,C> extends Object implements org.joda.beans.ImmutableBean, Tuple, Comparable<Triple<A,B,C>>, Serializable
An immutable triple consisting of three elements.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.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Triple.Meta<A,B,C>
The meta-bean forTriple
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 forTriple
.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 forTriple
.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.
-
-
-
Method Detail
-
of
public static <A,B,C> Triple<A,B,C> of(A first, B second, C third)
Obtains a triple inferring the types.- Type Parameters:
A
- the first element typeB
- the second element typeC
- the third element type- Parameters:
first
- the first elementsecond
- the second elementthird
- the third element- Returns:
- a triple formed from the three parameters
-
combining
public 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.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))
- Type Parameters:
A
- the type of the first valuesB
- the type of the second valuesC
- the type of the third values- Parameters:
combinerFirst
- the combiner of first valuescombinerSecond
- the combiner of second valuescombinerThird
- the combiner of third values- Returns:
- the combiner of triple instances
-
combinedWith
public <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.- Type Parameters:
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 instance- Parameters:
other
- the other triplecombinerFirst
- the combiner of first valuescombinerSecond
- the combiner of second valuescombinerThird
- the combiner of third values- Returns:
- the combined triple instance
-
size
public int size()
Gets the number of elements held by this triple.
-
elements
public ImmutableList<Object> elements()
Gets the elements from this triple as a list.The list returns each element in the triple in order.
-
compareTo
public 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.The element types must be
Comparable
.- Specified by:
compareTo
in interfaceComparable<A>
- Parameters:
other
- the other triple- Returns:
- negative if this is less, zero if equal, positive if greater
- Throws:
ClassCastException
- if either object is not comparable
-
toString
public String toString()
Gets the triple using a standard string format.The standard format is '[$first, $second, $third]'. Spaces around the values are trimmed.
-
meta
public static Triple.Meta meta()
The meta-bean forTriple
.- Returns:
- the meta-bean, not null
-
metaTriple
public static <R,S,T> Triple.Meta<R,S,T> metaTriple(Class<R> cls1, Class<S> cls2, Class<T> cls3)
The meta-bean forTriple
.- Type Parameters:
R
- the first generic typeS
- the second generic typeT
- the second generic type- Parameters:
cls1
- the first generic typecls2
- the second generic typecls3
- the third generic type- Returns:
- the meta-bean, not null
-
metaBean
public Triple.Meta<A,B,C> metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getFirst
public A getFirst()
Gets the first element in this triple.- Returns:
- the value of the property, not null
-
getSecond
public B getSecond()
Gets the second element in this triple.- Returns:
- the value of the property, not null
-
getThird
public C getThird()
Gets the third element in this triple.- Returns:
- the value of the property, not null
-
-