TypeReference (Jackson-core 2.0.2 API)
Date: 2012-05-14

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.fasterxml.jackson.core.type
Class TypeReference<T>

    java.lang.Object
      com.fasterxml.jackson.core.type.TypeReference<T>

All Implemented Interfaces:
  Comparable<TypeReference<T>>

    public abstract class TypeReference<T>

extends Object
implements Comparable<TypeReference<T>>

This generic abstract class is used for obtaining full generics type information by sub-classing; it must be converted to `ResolvedType` implementation (implemented by `JavaType` from "databind" bundle) to be used. Class is based on ideas from http://gafter.blogspot.com/2006/12/super-type-tokens.html, Additional idea (from a suggestion made in comments of the article) is to require bogus implementation of `Comparable` (any such generic interface would do, as long as it forces a method with generic type to be implemented). to ensure that a Type argument is indeed given.

Usage is by sub-classing: here is one way to instantiate reference to generic type `List<Integer>`:

      TypeReference ref = new TypeReference<List<Integer>>() { };

which can be passed to methods that accept TypeReference, or resolved using `TypeFactory` to obtain `ResolvedType`.

Field Summary
`protected Type` | `_type`

Constructor Summary
`protected` | `TypeReference()`

Method Summary
`int` | `compareTo(TypeReference<T> o)` The only reason we define this method (and require implementation of `Comparable`) is to prevent constructing a reference without type information.
`Type` | `getType()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _type

    protected final Type _type

Constructor Detail

### TypeReference

    protected TypeReference()

Method Detail

### getType

    public Type getType()

### compareTo

    public int compareTo(TypeReference<T> o)

  The only reason we define this method (and require implementation of `Comparable`) is to prevent constructing a reference without type information.

  Specified by:
    `compareTo` in interface `Comparable<TypeReference<T>>`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012 fasterxml.com. All Rights Reserved.