Class ObjDoublePair<A>
- java.lang.Object
-
- com.opengamma.strata.collect.tuple.ObjDoublePair<A>
-
- Type Parameters:
A- the type of the object
- All Implemented Interfaces:
Tuple,Serializable,Comparable<ObjDoublePair<A>>,org.joda.beans.Bean,org.joda.beans.ImmutableBean
public final class ObjDoublePair<A> extends Object implements org.joda.beans.ImmutableBean, Tuple, Comparable<ObjDoublePair<A>>, Serializable
An immutable pair consisting of anObjectand adouble.This class is similar to
Pairbut includes a primitive element.This class is immutable and thread-safe.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classObjDoublePair.Meta<A>The meta-bean forObjDoublePair.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(ObjDoublePair<A> other)Compares the pair based on the first element followed by the second element.ImmutableList<Object>elements()Gets the elements from this pair as a list.booleanequals(Object obj)AgetFirst()Gets the first element in this pair.doublegetSecond()Gets the second element in this pair.inthashCode()static ObjDoublePair.Metameta()The meta-bean forObjDoublePair.ObjDoublePair.Meta<A>metaBean()static <R> ObjDoublePair.Meta<R>metaObjDoublePair(Class<R> cls)The meta-bean forObjDoublePair.static <A> ObjDoublePair<A>of(A first, double second)Obtains an instance from anObjectand adouble.static <A> ObjDoublePair<A>ofPair(Pair<A,Double> pair)Obtains an instance from aPair.intsize()Gets the number of elements held by this pair.Pair<A,Double>toPair()Converts this pair to an object-basedPair.StringtoString()Gets the pair using a standard string format.
-
-
-
Method Detail
-
of
public static <A> ObjDoublePair<A> of(A first, double second)
Obtains an instance from anObjectand adouble.- Type Parameters:
A- the first element type- Parameters:
first- the first elementsecond- the second element- Returns:
- a pair formed from the two parameters
-
ofPair
public static <A> ObjDoublePair<A> ofPair(Pair<A,Double> pair)
Obtains an instance from aPair.- Type Parameters:
A- the first element type- Parameters:
pair- the pair to convert- Returns:
- a pair formed by extracting values from the pair
-
size
public int size()
Gets the number of elements held by this pair.
-
elements
public ImmutableList<Object> elements()
Gets the elements from this pair as a list.The list returns each element in the pair in order.
-
toPair
public Pair<A,Double> toPair()
Converts this pair to an object-basedPair.- Returns:
- the object-based pair
-
compareTo
public int compareTo(ObjDoublePair<A> other)
Compares the pair based on the first element followed by the second element.The first element must be
Comparable.- Specified by:
compareToin interfaceComparable<A>- Parameters:
other- the other pair- Returns:
- negative if this is less, zero if equal, positive if greater
- Throws:
ClassCastException- if the object is not comparable
-
toString
public String toString()
Gets the pair using a standard string format.The standard format is '[$first, $second]'. Spaces around the values are trimmed.
-
meta
public static ObjDoublePair.Meta meta()
The meta-bean forObjDoublePair.- Returns:
- the meta-bean, not null
-
metaObjDoublePair
public static <R> ObjDoublePair.Meta<R> metaObjDoublePair(Class<R> cls)
The meta-bean forObjDoublePair.- Type Parameters:
R- the bean's generic type- Parameters:
cls- the bean's generic type- Returns:
- the meta-bean, not null
-
metaBean
public ObjDoublePair.Meta<A> metaBean()
- Specified by:
metaBeanin interfaceorg.joda.beans.Bean
-
getFirst
public A getFirst()
Gets the first element in this pair.- Returns:
- the value of the property, not null
-
getSecond
public double getSecond()
Gets the second element in this pair.- Returns:
- the value of the property
-
-