Class TypeBindings

java.lang.Object
tools.jackson.databind.type.TypeBindings
All Implemented Interfaces:
Serializable

public class TypeBindings extends Object implements Serializable
Helper class used for resolving type parameters for given class
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • NO_STRINGS

      private static final String[] NO_STRINGS
    • NO_TYPES

      private static final JavaType[] NO_TYPES
    • EMPTY

      private static final TypeBindings EMPTY
    • _names

      private final String[] _names
      Array of type (type variable) names.
    • _types

      private final JavaType[] _types
      Types matching names
    • _unboundVariables

      private final String[] _unboundVariables
      Names of potentially unresolved type variables.
    • _hashCode

      private final int _hashCode
  • Constructor Details

  • Method Details

    • emptyBindings

      public static TypeBindings emptyBindings()
    • readResolve

      protected Object readResolve()
    • create

      public static TypeBindings create(Class<?> erasedType, List<JavaType> typeList)
      Factory method for constructing bindings for given class using specified type parameters.
    • create

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

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

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

      public static TypeBindings create(List<String> names, List<JavaType> types)
      Factory method for constructing bindings given names and associated types.
    • createIfNeeded

      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.
    • createIfNeeded

      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.
    • withUnboundVariable

      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.
    • withoutVariable

      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.
    • findBoundType

      public JavaType findBoundType(String name)
      Find type bound to specified name, if there is one; returns bound type if so, null if not.
    • 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

      public String getBoundName(int index)
    • getBoundType

      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.
    • getBoundTypeOrNull

      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
    • getTypeParameters

      public List<JavaType> getTypeParameters()
      Accessor for getting bound types in declaration order
    • hasUnbound

      public boolean hasUnbound(String name)
      Since:
      2.3
    • asKey

      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:
      An object which can be used as a key in TypeFactory, or null if no key can be created.
      Since:
      2.8
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • typeParameterArray

      protected JavaType[] typeParameterArray()