org.glassfish.jersey.internal.util.collection
Class Tuples

java.lang.Object
  extended by org.glassfish.jersey.internal.util.collection.Tuples

public final class Tuples
extends java.lang.Object

Utility class with methods for working with tuples, such as Pair and Ref.

Author:
Paul Sandoz, Marek Potociar (marek.potociar at oracle.com)

Method Summary
static
<T> Ref<T>
emptyRef()
          Constructs a new empty mutable Ref instance.
static
<T> Ref<T>
immutableRef(T value)
          Constructs a new immutable Ref instance referencing the given input reference.
static
<L,R> Pair<L,R>
of(L left, R right)
          Constructs Pair of the given values.
static
<T> Ref<T>
of(T value)
          Constructs a new mutable Ref instance referencing the given input reference.
static
<L,R> Pair<R,L>
swap(Pair<L,R> pair)
          Constructs a new Pair instance with values of the input pair instance swapped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

of

public static <L,R> Pair<L,R> of(L left,
                                 R right)
Constructs Pair of the given values.

Type Parameters:
L - left-hand reference type
R - right-hand reference type
Parameters:
left - left-hand reference in the pair
right - right-hand reference in the pair
Returns:
Pair of input values
See Also:
swap(Pair)

swap

public static <L,R> Pair<R,L> swap(Pair<L,R> pair)
Constructs a new Pair instance with values of the input pair instance swapped.

Type Parameters:
L - left-hand reference type
R - right-hand reference type
Parameters:
pair - instance whose values are to be swapped
Returns:
a new Pair instance with values of the input pair instance swapped.
See Also:
of(java.lang.Object, java.lang.Object)

of

public static <T> Ref<T> of(T value)
Constructs a new mutable Ref instance referencing the given input reference.

Type Parameters:
T - type of the referenced instance
Parameters:
value - reference of the newly constructed reference
Returns:
a new mutable Ref instance referencing the given input reference.
See Also:
immutableRef(java.lang.Object), emptyRef()

emptyRef

public static <T> Ref<T> emptyRef()
Constructs a new empty mutable Ref instance.

Type Parameters:
T - type of the referenced instance
Returns:
a new mutable empty Ref instance
See Also:
immutableRef(java.lang.Object), of(java.lang.Object)

immutableRef

public static <T> Ref<T> immutableRef(T value)
Constructs a new immutable Ref instance referencing the given input reference.

Invoking a Ref.set(java.lang.Object) on the returned instance will result in a IllegalStateException being thrown.

Type Parameters:
T - type of the referenced instance
Parameters:
value - reference of the newly constructed reference
Returns:
a new immutable Ref instance referencing the given input reference.
See Also:
emptyRef(), of(java.lang.Object)


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.