Package org.plumelib.util
Class IPair<V1,V2>
java.lang.Object
org.plumelib.util.IPair<V1,V2>
- Type Parameters:
V1
- the type of the first element of the pairV2
- the type of the second element of the pair
Immutable pair class.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptioncloneElements
(IPair<T1, T2> orig) Returns a copy of this in which each element is a clone of the corresponding element of this.static <T1 extends DeepCopyable<T1>,
T2 extends DeepCopyable<T2>>
IPair<T1,T2> Returns a deep copy of this: each element is a deep copy (according to theDeepCopyable
interface) of the corresponding element of this.static <T1 extends DeepCopyable<T1>,
T2>
IPair<T1,T2> deepCopyFirst
(IPair<T1, T2> orig) Returns a copy, where thefirst
element is deep: thefirst
element is a deep copy (according to theDeepCopyable
interface), and thesecond
element is identical to the argument.static <T1,
T2 extends DeepCopyable<T2>>
IPair<T1,T2> deepCopySecond
(IPair<T1, T2> orig) Returns a copy, where thesecond
element is deep: thefirst
element is identical to the argument, and thesecond
element is a deep copy (according to theDeepCopyable
interface).boolean
int
hashCode()
static <T1,
T2> IPair<T1, T2> of
(T1 first, T2 second) Creates a new immutable pair.toString()
-
Field Details
-
first
The first element of the pair. -
second
The second element of the pair.
-
-
Method Details
-
of
Creates a new immutable pair.- Type Parameters:
T1
- type of first argumentT2
- type of second argument- Parameters:
first
- first argumentsecond
- second argument- Returns:
- a pair of the values (first, second)
-
cloneElements
public static <T1 extends Cloneable,T2 extends Cloneable> IPair<T1,T2> cloneElements(IPair<T1, T2> orig) Returns a copy of this in which each element is a clone of the corresponding element of this.clone()
may or may not itself make a deep copy of the elements.- Type Parameters:
T1
- the type of the first element of the pairT2
- the type of the second element of the pair- Parameters:
orig
- a pair- Returns:
- a copy of
orig
, with all elements cloned
-
deepCopy
public static <T1 extends DeepCopyable<T1>,T2 extends DeepCopyable<T2>> IPair<T1,T2> deepCopy(IPair<T1, T2> orig) Returns a deep copy of this: each element is a deep copy (according to theDeepCopyable
interface) of the corresponding element of this.- Type Parameters:
T1
- the type of the first element of the pairT2
- the type of the second element of the pair- Parameters:
orig
- a pair- Returns:
- a deep copy of
orig
-
deepCopyFirst
Returns a copy, where thefirst
element is deep: thefirst
element is a deep copy (according to theDeepCopyable
interface), and thesecond
element is identical to the argument.- Type Parameters:
T1
- the type of the first element of the pairT2
- the type of the second element of the pair- Parameters:
orig
- a pair- Returns:
- a copy of
orig
, where the first element is a deep copy
-
deepCopySecond
Returns a copy, where thesecond
element is deep: thefirst
element is identical to the argument, and thesecond
element is a deep copy (according to theDeepCopyable
interface).- Type Parameters:
T1
- the type of the first element of the pairT2
- the type of the second element of the pair- Parameters:
orig
- a pair- Returns:
- a copy of
orig
, where the second element is a deep copy
-
equals
@Pure public boolean equals(@GuardSatisfied IPair<V1, V2> this, @GuardSatisfied @Nullable Object obj) -
hashCode
@Pure public int hashCode(@GuardSatisfied IPair<V1, V2> this) -
toString
-