org.codehaus.jackson.type
Class JavaType

java.lang.Object
  extended by org.codehaus.jackson.type.JavaType
Direct Known Subclasses:
ArrayType, CollectionType, MapType, SimpleType

public abstract class JavaType
extends Object

Base class for type token classes used both to contain information and as keys for deserializers.

Instances can (only) be constructed by TypeFactory.


Field Summary
protected  Class<?> _class
          This is the nominal type-erased Class that would be close to the type represented (but not exactly type, due to type erasure: type instance may have more information on this).
protected  int _hashCode
           
 
Constructor Summary
protected JavaType(Class<?> clz)
           
 
Method Summary
protected  void _assertSubclass(Class<?> subclass, Class<?> superClass)
           
protected abstract  JavaType _narrow(Class<?> subclass)
           
protected  JavaType _widen(Class<?> superclass)
           Default implementation is just to call _narrow(java.lang.Class), since underlying type construction is usually identical
abstract  boolean equals(Object o)
           
 JavaType findVariableType(String name)
          Method that can be called to see if this type has generic type binding information for type variables, for given formal type parameter name.
 Class<?> getRawClass()
           
 int hashCode()
           
 boolean hasRawClass(Class<?> clz)
          Method that can be used to check whether this type has specified Class as its type erasure.
 boolean isAbstract()
           
 boolean isArrayType()
           
abstract  boolean isContainerType()
           
 boolean isEnumType()
           
abstract  boolean isFullyTyped()
          Method that can be used to check whether type described is fully typed, regarding the way JavaTypes are used for deserialization.
 boolean isInterface()
           
 boolean isPrimitive()
           
 JavaType narrowBy(Class<?> subclass)
          Method that can be called to do a "narrowing" conversions; that is, to return a type with a raw class that is assignable to the raw class of this type.
abstract  JavaType narrowContentsBy(Class<?> contentClass)
           
abstract  String toString()
           
 JavaType widenBy(Class<?> superclass)
          Method that can be called to do a "widening" conversions; that is, to return a type with a raw class that could be assigned from this type.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_class

protected final Class<?> _class
This is the nominal type-erased Class that would be close to the type represented (but not exactly type, due to type erasure: type instance may have more information on this). May be an interface or abstract class, so instantiation may not be possible.


_hashCode

protected int _hashCode
Constructor Detail

JavaType

protected JavaType(Class<?> clz)
Method Detail

narrowBy

public final JavaType narrowBy(Class<?> subclass)
Method that can be called to do a "narrowing" conversions; that is, to return a type with a raw class that is assignable to the raw class of this type. If this is not possible, an IllegalArgumentException is thrown. If class is same as the current raw class, instance itself is returned.


widenBy

public final JavaType widenBy(Class<?> superclass)
Method that can be called to do a "widening" conversions; that is, to return a type with a raw class that could be assigned from this type. If such conversion is not possible, an IllegalArgumentException is thrown. If class is same as the current raw class, instance itself is returned.


_narrow

protected abstract JavaType _narrow(Class<?> subclass)

_widen

protected JavaType _widen(Class<?> superclass)

Default implementation is just to call _narrow(java.lang.Class), since underlying type construction is usually identical


narrowContentsBy

public abstract JavaType narrowContentsBy(Class<?> contentClass)

getRawClass

public final Class<?> getRawClass()

hasRawClass

public final boolean hasRawClass(Class<?> clz)
Method that can be used to check whether this type has specified Class as its type erasure. Put another way, returns true if instantiation of this Type is given (type-erased) Class.


isFullyTyped

public abstract boolean isFullyTyped()
Method that can be used to check whether type described is fully typed, regarding the way JavaTypes are used for deserialization. For this to be true, all Collection and Map types must have proper element/value/key type information, and can not be plain classes.


isContainerType

public abstract boolean isContainerType()
Returns:
True if type represented is a container type; this includes array, Map and Collection types.

isAbstract

public final boolean isAbstract()

isArrayType

public final boolean isArrayType()

isEnumType

public final boolean isEnumType()

isInterface

public final boolean isInterface()

isPrimitive

public final boolean isPrimitive()

findVariableType

public JavaType findVariableType(String name)
Method that can be called to see if this type has generic type binding information for type variables, for given formal type parameter name.

Returns:
Type given formal type parameter name maps to, if any; null if this type knows of no binding for name

_assertSubclass

protected void _assertSubclass(Class<?> subclass,
                               Class<?> superClass)

toString

public abstract String toString()
Overrides:
toString in class Object

equals

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

hashCode

public final int hashCode()
Overrides:
hashCode in class Object