Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.databind.type

public Class TypeBindings

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.lang.reflect.TypeVariable, java.util.*, com.fasterxml.jackson.databind.JavaType, com.fasterxml.jackson.databind.util.ClassUtil

Helper class used for resolving type parameters for given class

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
TypeBindings.AsKey

Helper type used to allow caching of generic types

pack-priv static class
TypeBindings.TypeParamStash

Helper class that contains simple logic for avoiding repeated lookups via Class#getTypeParameters() as that can be a performance issue for some use cases (wasteful, usually one-off or not reusing mapper).

Field Summary

Modifier and TypeField and Description
private final int
private final String[]
_names

Array of type (type variable) names.

private final JavaType[]
_types

Types matching names

private final String[]
_unboundVariables

Names of potentially unresolved type variables.

private static final TypeBindings
private static final String[]
private static final JavaType[]
private static final long

Constructor Summary

AccessConstructor and Description
private
TypeBindings(String[] names, JavaType[] types, String[] uvars)

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

An object which can be used as a key in TypeFactory, or null if no key can be created.
asKey
(Class<?> rawBase)

Factory method that will create an object that can be used as a key for caching purposes by TypeFactory

public static TypeBindings
create(Class<?> erasedType, List<JavaType> typeList)

Factory method for constructing bindings for given class using specified type parameters.

public static TypeBindings
create(Class<?> erasedType, JavaType[] types)

public static TypeBindings
create(Class<?> erasedType, JavaType typeArg1)

public static TypeBindings
create(Class<?> erasedType, JavaType typeArg1, JavaType typeArg2)

public static TypeBindings
create(List<String> names, List<JavaType> types)

Factory method for constructing bindings given names and associated types.

public static TypeBindings
createIfNeeded(Class<?> erasedType, JavaType typeArg1)

Alternate factory method that may be called if it is possible that type does or does not require type parameters; this is mostly useful for collection- and map-like types.

public static TypeBindings
createIfNeeded(Class<?> erasedType, JavaType[] types)

Alternate factory method that may be called if it is possible that type does or does not require type parameters; this is mostly useful for collection- and map-like types.

public static TypeBindings
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public JavaType
findBoundType(String name)

Find type bound to specified name, if there is one; returns bound type if so, null if not.

public String
getBoundName(int index)

public JavaType
getBoundType(int index)

Get the type bound to the variable at index.

public JavaType
getBoundTypeOrNull(int index)

Get the type bound to the variable at index.

public List<JavaType>
getTypeParameters()

Accessor for getting bound types in declaration order

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
private boolean
invalidCacheKey()

Returns true if a shallow search of the type bindings includes a placeholder type which uses reference equality, thus cannot produce cache hits.

public boolean
protected Object
public int
size()

Returns number of bindings contained

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

protected JavaType[]
public TypeBindings
withoutVariable(String name)

Create a new instance with the same bindings as this object, except with the given variable removed.

public TypeBindings
withUnboundVariable(String name)

Method for creating an instance that has same bindings as this object, plus an indicator for additional type variable that may be unbound within this context; this is needed to resolve recursive self-references.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

_hashCodeback to summary
private final int _hashCode
_namesback to summary
private final String[] _names

Array of type (type variable) names.

_typesback to summary
private final JavaType[] _types

Types matching names

_unboundVariablesback to summary
private final String[] _unboundVariables

Names of potentially unresolved type variables.

Since
2.3
EMPTYback to summary
private static final TypeBindings EMPTY
NO_STRINGSback to summary
private static final String[] NO_STRINGS
NO_TYPESback to summary
private static final JavaType[] NO_TYPES
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

TypeBindingsback to summary
private TypeBindings(String[] names, JavaType[] types, String[] uvars)

Method Detail

asKeyback to summary
public Object asKey(Class<?> rawBase)

Factory method that will create an object that can be used as a key for caching purposes by TypeFactory

Returns:Object

An object which can be used as a key in TypeFactory, or null if no key can be created.

Since
2.8
createback to summary
public static TypeBindings create(Class<?> erasedType, List<JavaType> typeList)

Factory method for constructing bindings for given class using specified type parameters.

createback to summary
public static TypeBindings create(Class<?> erasedType, JavaType[] types)
createback to summary
public static TypeBindings create(Class<?> erasedType, JavaType typeArg1)
createback to summary
public static TypeBindings create(Class<?> erasedType, JavaType typeArg1, JavaType typeArg2)
createback to summary
public static TypeBindings create(List<String> names, List<JavaType> types)

Factory method for constructing bindings given names and associated types.

createIfNeededback to summary
public static TypeBindings createIfNeeded(Class<?> erasedType, JavaType typeArg1)

Alternate factory method that may be called if it is possible that type does or does not require type parameters; this is mostly useful for collection- and map-like types.

createIfNeededback to summary
public static TypeBindings createIfNeeded(Class<?> erasedType, JavaType[] types)

Alternate factory method that may be called if it is possible that type does or does not require type parameters; this is mostly useful for collection- and map-like types.

emptyBindingsback to summary
public static TypeBindings emptyBindings()
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
findBoundTypeback to summary
public JavaType findBoundType(String name)

Find type bound to specified name, if there is one; returns bound type if so, null if not.

getBoundNameback to summary
public String getBoundName(int index)
getBoundTypeback to summary
public JavaType getBoundType(int index)

Get the type bound to the variable at index. If the type is not bound but the index is within size() constraints, this method returns TypeFactory#unknownType() for compatibility. If the index is out of size() constraints, this method will still return null.

getBoundTypeOrNullback to summary
public JavaType getBoundTypeOrNull(int index)

Get the type bound to the variable at index. If the type is not bound or the index is within size() constraints, this method returns null.

Since
2.16
getTypeParametersback to summary
public List<JavaType> getTypeParameters()

Accessor for getting bound types in declaration order

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
hasUnboundback to summary
public boolean hasUnbound(String name)
Since
2.3
invalidCacheKeyback to summary
private boolean invalidCacheKey()

Returns true if a shallow search of the type bindings includes a placeholder type which uses reference equality, thus cannot produce cache hits. This is an optimization to avoid churning memory in the cache unnecessarily. Note that it is still possible for nested type information to contain such placeholder types (see NestedTypes1604Test for an example) so it's vital that they produce a distribution of hashCode values, even if they may push reusable data out of the cache.

isEmptyback to summary
public boolean isEmpty()
readResolveback to summary
protected Object readResolve()
sizeback to summary
public int size()

Returns number of bindings contained

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
typeParameterArrayback to summary
protected JavaType[] typeParameterArray()
withoutVariableback to summary
public TypeBindings withoutVariable(String name)

Create a new instance with the same bindings as this object, except with the given variable removed. This is used to create generic types that are "partially raw", i.e. only have some variables bound.

Since
2.16
withUnboundVariableback to summary
public TypeBindings withUnboundVariable(String name)

Method for creating an instance that has same bindings as this object, plus an indicator for additional type variable that may be unbound within this context; this is needed to resolve recursive self-references.

com.fasterxml.jackson.databind.type back to summary

pack-priv final Class TypeBindings.AsKey

extends Object
Class Inheritance

Helper type used to allow caching of generic types
Since
2.8

Field Summary

Modifier and TypeField and Description
private final int
private final JavaType[]
private final Class<?>

Constructor Summary

AccessConstructor and Description
public
AsKey(Class<?> raw, JavaType[] params, int hash)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

_hashback to summary
private final int _hash
_paramsback to summary
private final JavaType[] _params
_rawback to summary
private final Class<?> _raw

Constructor Detail

AsKeyback to summary
public AsKey(Class<?> raw, JavaType[] params, int hash)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
com.fasterxml.jackson.databind.type back to summary

pack-priv Class TypeBindings.TypeParamStash

extends Object
Class Inheritance
  • java.lang.Object
  • com.fasterxml.jackson.databind.type.TypeBindings.TypeParamStash

Helper class that contains simple logic for avoiding repeated lookups via Class#getTypeParameters() as that can be a performance issue for some use cases (wasteful, usually one-off or not reusing mapper). Partly isolated to avoid initialization for cases where no generic types are used.

Field Summary

Modifier and TypeField and Description
private static final TypeVariable<?>[]
private static final TypeVariable<?>[]
private static final TypeVariable<?>[]
private static final TypeVariable<?>[]
private static final TypeVariable<?>[]
private static final TypeVariable<?>[]
private static final TypeVariable<?>[]
private static final TypeVariable<?>[]

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public static TypeVariable<?>[]
paramsFor1(Class<?> erasedType)

public static TypeVariable<?>[]
paramsFor2(Class<?> erasedType)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

VARS_ABSTRACT_LISTback to summary
private static final TypeVariable<?>[] VARS_ABSTRACT_LIST
VARS_ARRAY_LISTback to summary
private static final TypeVariable<?>[] VARS_ARRAY_LIST
VARS_COLLECTIONback to summary
private static final TypeVariable<?>[] VARS_COLLECTION
VARS_HASH_MAPback to summary
private static final TypeVariable<?>[] VARS_HASH_MAP
VARS_ITERABLEback to summary
private static final TypeVariable<?>[] VARS_ITERABLE
VARS_LINKED_HASH_MAPback to summary
private static final TypeVariable<?>[] VARS_LINKED_HASH_MAP
VARS_LISTback to summary
private static final TypeVariable<?>[] VARS_LIST
VARS_MAPback to summary
private static final TypeVariable<?>[] VARS_MAP

Constructor Detail

TypeParamStashback to summary
pack-priv TypeParamStash()

Method Detail

paramsFor1back to summary
public static TypeVariable<?>[] paramsFor1(Class<?> erasedType)
paramsFor2back to summary
public static TypeVariable<?>[] paramsFor2(Class<?> erasedType)