com.atlassian.jira.util.lang
Class Pair<F,S>

java.lang.Object
  extended by com.atlassian.jira.util.lang.Pair<F,S>
Type Parameters:
F - type of the first element
S - type of the second element

@ThreadSafe
public final class Pair<F,S>
extends Object

Immutable, generic pair of values. How coool is that!

Since:
v4.2

Method Summary
 boolean equals(Object o)
           
 F first()
           
 int hashCode()
           
static
<U,V> Pair<U,V>
nicePairOf(U first, V second)
          A pair that does allows null values.
static
<U,V> Pair<U,V>
of(U first, V second)
          By default we create a strict pair of non-null values.
 S second()
           
static
<U,V> Pair<U,V>
strictPairOf(U first, V second)
          A pair that doesn't allow null values.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

of

public static <U,V> Pair<U,V> of(U first,
                                 V second)
By default we create a strict pair of non-null values.

Type Parameters:
U - type of first value
V - type of second value
Parameters:
first - first value
second - second value
Returns:
new pair
See Also:
strictPairOf(Object, Object)

strictPairOf

public static <U,V> Pair<U,V> strictPairOf(@NotNull
                                           U first,
                                           @NotNull
                                           V second)
A pair that doesn't allow null values.

Type Parameters:
U - type of first value
V - type of second value
Parameters:
first - first value, may not be null
second - second value, may not be null
Returns:
new strict pair

nicePairOf

public static <U,V> Pair<U,V> nicePairOf(@Nullable
                                         U first,
                                         @Nullable
                                         V second)
A pair that does allows null values.

Type Parameters:
U - type of first value
V - type of second value
Parameters:
first - first value, may be null
second - second value, may be null
Returns:
new nice pair

first

public F first()

second

public S second()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002-2012 Atlassian. All Rights Reserved.