Class TypeBindings
java.lang.Object
tools.jackson.databind.type.TypeBindings
- All Implemented Interfaces:
Serializable
Helper class used for resolving type parameters for given class
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classHelper type used to allow caching of generic types(package private) static classHelper class that contains simple logic for avoiding repeated lookups viaClass.getTypeParameters()as that can be a performance issue for some use cases (wasteful, usually one-off or not reusing mapper). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intprivate final String[]Array of type (type variable) names.private final JavaType[]Types matching namesprivate final String[]Names of potentially unresolved type variables.private static final TypeBindingsprivate static final String[]private static final JavaType[]private static final long -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateTypeBindings(String[] names, JavaType[] types, String[] uvars) -
Method Summary
Modifier and TypeMethodDescriptionFactory method that will create an object that can be used as a key for caching purposes byTypeFactorystatic TypeBindingsFactory method for constructing bindings for given class using specified type parameters.static TypeBindingsstatic TypeBindingsstatic TypeBindingsstatic TypeBindingsFactory method for constructing bindings given names and associated types.static TypeBindingscreateIfNeeded(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.static TypeBindingscreateIfNeeded(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.static TypeBindingsbooleanfindBoundType(String name) Find type bound to specified name, if there is one; returns bound type if so, null if not.getBoundName(int index) getBoundType(int index) Get the type bound to the variable atindex.getBoundTypeOrNull(int index) Get the type bound to the variable atindex.Accessor for getting bound types in declaration orderinthashCode()booleanhasUnbound(String name) private booleanReturns true if a shallow search of the type bindings includes a placeholder type which uses reference equality, thus cannot produce cache hits.booleanisEmpty()protected Objectintsize()Returns number of bindings containedtoString()protected JavaType[]withoutVariable(String name) Create a new instance with the same bindings as this object, except with the given variable removed.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.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
NO_STRINGS
-
NO_TYPES
-
EMPTY
-
_names
Array of type (type variable) names. -
_types
Types matching names -
_unboundVariables
Names of potentially unresolved type variables. -
_hashCode
private final int _hashCode
-
-
Constructor Details
-
TypeBindings
-
-
Method Details
-
emptyBindings
-
readResolve
-
create
Factory method for constructing bindings for given class using specified type parameters. -
create
-
create
-
create
-
create
Factory method for constructing bindings given names and associated types. -
createIfNeeded
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. -
createIfNeeded
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. -
withUnboundVariable
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. -
withoutVariable
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. -
findBoundType
-
invalidCacheKey
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. -
isEmpty
public boolean isEmpty() -
size
public int size()Returns number of bindings contained -
getBoundName
-
getBoundType
Get the type bound to the variable atindex. If the type isnot boundbut the index is withinsize()constraints, this method returnsTypeFactory.unknownType()for compatibility. If the index is out ofsize()constraints, this method will still returnnull. -
getBoundTypeOrNull
-
getTypeParameters
-
hasUnbound
- Since:
- 2.3
-
asKey
Factory method that will create an object that can be used as a key for caching purposes byTypeFactory- Returns:
- An object which can be used as a key in TypeFactory, or
nullif no key can be created. - Since:
- 2.8
-
toString
-
hashCode
-
equals
-
typeParameterArray
-