org.glassfish.jersey.internal.util.collection
Class InstanceTypePair<T>

java.lang.Object
  extended by org.glassfish.jersey.internal.util.collection.InstanceTypePair<T>
Type Parameters:
T - instance type.
All Implemented Interfaces:
Pair<T,Type>

public final class InstanceTypePair<T>
extends Object
implements Pair<T,Type>

A pair of instance and the public (official) Java type of the instance.

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

Method Summary
 T instance()
          Get stored instance.
 T left()
          Left-hand instance in the Pair.
static
<T> InstanceTypePair<T>
of(T instance)
          Create new instance-type pair from an instance.
static
<T> InstanceTypePair<T>
of(T instance, Type type)
          Create new instance-type pair from an instance.
static
<T> InstanceTypePair<T>
of(T instance, org.glassfish.hk2.TypeLiteral<T> type)
          Create new instance-type pair from an instance.
 Type right()
          Right-hand instance in the Pair.
 String toString()
           
 Type type()
          Get the public type of the stored instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

left

public T left()
Description copied from interface: Pair
Left-hand instance in the Pair.

Specified by:
left in interface Pair<T,Type>
Returns:
left-hand instance in the Pair

right

public Type right()
Description copied from interface: Pair
Right-hand instance in the Pair.

Specified by:
right in interface Pair<T,Type>
Returns:
right-hand instance in the Pair

instance

public T instance()
Get stored instance.

Returns:
stored instance.

type

public Type type()
Get the public type of the stored instance.

Returns:
public type of the stored instance.

toString

public String toString()
Overrides:
toString in class Object

of

public static <T> InstanceTypePair<T> of(T instance)
Create new instance-type pair from an instance.

Type Parameters:
T - instance type.
Parameters:
instance - instance.
Returns:
new instance-type pair.

of

public static <T> InstanceTypePair<T> of(T instance,
                                         org.glassfish.hk2.TypeLiteral<T> type)
Create new instance-type pair from an instance.

Type Parameters:
T - instance type.
Parameters:
instance - instance.
type - type literal representing the generic public type of the instance.
Returns:
new instance-type pair.

of

public static <T> InstanceTypePair<T> of(T instance,
                                         Type type)
Create new instance-type pair from an instance.

Type Parameters:
T - instance type.
Parameters:
instance - instance.
type - public type of the instance.
Returns:
new instance-type pair.


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