Class ObjIntPair<A>
- java.lang.Object
-
- com.opengamma.strata.collect.tuple.ObjIntPair<A>
-
- Type Parameters:
A
- the type of the object
- All Implemented Interfaces:
Tuple
,java.io.Serializable
,java.lang.Comparable<ObjIntPair<A>>
,Bean
,ImmutableBean
public final class ObjIntPair<A> extends java.lang.Object implements ImmutableBean, Tuple, java.lang.Comparable<ObjIntPair<A>>, java.io.Serializable
An immutable pair consisting of anObject
and anint
.This class is similar to
Pair
but 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 class
ObjIntPair.Meta<A>
The meta-bean forObjIntPair
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(ObjIntPair<A> other)
Compares the pair based on the first element followed by the second element.com.google.common.collect.ImmutableList<java.lang.Object>
elements()
Gets the elements from this pair as a list.boolean
equals(java.lang.Object obj)
A
getFirst()
Gets the first element in this pair.int
getSecond()
Gets the second element in this pair.int
hashCode()
static ObjIntPair.Meta
meta()
The meta-bean forObjIntPair
.ObjIntPair.Meta<A>
metaBean()
static <R> ObjIntPair.Meta<R>
metaObjIntPair(java.lang.Class<R> cls)
The meta-bean forObjIntPair
.static <A> ObjIntPair<A>
of(A first, int second)
Obtains an instance from anObject
and anint
.static <A> ObjIntPair<A>
ofPair(Pair<A,java.lang.Integer> pair)
Obtains an instance from aPair
.int
size()
Gets the number of elements held by this pair.Pair<A,java.lang.Integer>
toPair()
Converts this pair to an object-basedPair
.java.lang.String
toString()
Gets the pair using a standard string format.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.joda.beans.Bean
property, propertyNames
-
-
-
-
Method Detail
-
of
public static <A> ObjIntPair<A> of(A first, int second)
Obtains an instance from anObject
and anint
.- 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> ObjIntPair<A> ofPair(Pair<A,java.lang.Integer> 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 com.google.common.collect.ImmutableList<java.lang.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,java.lang.Integer> toPair()
Converts this pair to an object-basedPair
.- Returns:
- the object-based pair
-
compareTo
public int compareTo(ObjIntPair<A> other)
Compares the pair based on the first element followed by the second element.The first element must be
Comparable
.- Specified by:
compareTo
in interfacejava.lang.Comparable<A>
- Parameters:
other
- the other pair- Returns:
- negative if this is less, zero if equal, positive if greater
- Throws:
java.lang.ClassCastException
- if the object is not comparable
-
toString
public java.lang.String toString()
Gets the pair using a standard string format.The standard format is '[$first, $second]'. Spaces around the values are trimmed.
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the pair as a string
-
meta
public static ObjIntPair.Meta meta()
The meta-bean forObjIntPair
.- Returns:
- the meta-bean, not null
-
metaObjIntPair
public static <R> ObjIntPair.Meta<R> metaObjIntPair(java.lang.Class<R> cls)
The meta-bean forObjIntPair
.- Type Parameters:
R
- the bean's generic type- Parameters:
cls
- the bean's generic type- Returns:
- the meta-bean, not null
-
metaBean
public ObjIntPair.Meta<A> metaBean()
-
getFirst
public A getFirst()
Gets the first element in this pair.- Returns:
- the value of the property, not null
-
getSecond
public int getSecond()
Gets the second element in this pair.- Returns:
- the value of the property
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-