Class MapLikeType

  • All Implemented Interfaces:
    JsonSerializable, JsonSerializableWithType
    Direct Known Subclasses:
    MapType

    public class MapLikeType
    extends TypeBase
    Type that represents Map-like types; things that consist of key/value pairs but that do not necessarily implement Map, but that do not have enough introspection functionality to allow for some level of generic handling. This specifically allows framework to check for configuration and annotation settings used for Map types, and pass these to custom handlers that may be more familiar with actual type.
    Since:
    1.8
    • Field Detail

      • _keyType

        protected final JavaType _keyType
        Type of keys of Map.
      • _valueType

        protected final JavaType _valueType
        Type of values of Map.
    • Method Detail

      • narrowKey

        public JavaType narrowKey​(Class<?> keySubclass)
      • widenKey

        public JavaType widenKey​(Class<?> keySubclass)
        Since:
        1.8
      • withTypeHandler

        public MapLikeType withTypeHandler​(Object h)
        Description copied from class: JavaType
        "Copy method" that will construct a new instance that is identical to this instance, except that it will have specified type handler assigned.
        Specified by:
        withTypeHandler in class JavaType
        Returns:
        Newly created type instance
      • withContentTypeHandler

        public MapLikeType withContentTypeHandler​(Object h)
        Description copied from class: JavaType
        "Copy method" that will construct a new instance that is identical to this instance, except that its content type will have specified type handler assigned.
        Specified by:
        withContentTypeHandler in class JavaType
        Returns:
        Newly created type instance
      • isContainerType

        public boolean isContainerType()
        Specified by:
        isContainerType in class JavaType
        Returns:
        True if type represented is a container type; this includes array, Map and Collection types.
      • isMapLikeType

        public boolean isMapLikeType()
        Overrides:
        isMapLikeType in class JavaType
        Returns:
        True if type is either true Map type, or something similar (meaning it has at least two type parameter; first one describing key type, second value type)
      • getKeyType

        public JavaType getKeyType()
        Description copied from class: JavaType
        Method for accessing key type for this type, assuming type has such a concept (only Map types do)
        Overrides:
        getKeyType in class JavaType
      • getContentType

        public JavaType getContentType()
        Description copied from class: JavaType
        Method for accessing content type of this type, if type has such a thing: simple types do not, structured types do (like arrays, Collections and Maps)
        Overrides:
        getContentType in class JavaType
      • containedTypeCount

        public int containedTypeCount()
        Description copied from class: JavaType
        Method for checking how many contained types this type has. Contained types are usually generic types, so that generic Maps have 2 contained types.
        Overrides:
        containedTypeCount in class JavaType
      • containedType

        public JavaType containedType​(int index)
        Description copied from class: JavaType
        Method for accessing definitions of contained ("child") types.
        Overrides:
        containedType in class JavaType
        Parameters:
        index - Index of contained type to return
        Returns:
        Contained type at index, or null if no such type exists (no exception thrown)
      • containedTypeName

        public String containedTypeName​(int index)
        Not sure if we should count on this, but type names for core interfaces are "K" and "V" respectively. For now let's assume this should work.
        Overrides:
        containedTypeName in class JavaType
        Parameters:
        index - Index of contained type to return
        Returns:
        Contained type at index, or null if no such type exists (no exception thrown)
      • getErasedSignature

        public StringBuilder getErasedSignature​(StringBuilder sb)
        Description copied from class: JavaType
        Method for accessing signature without generic type information, in form compatible with all versions of JVM, and specifically used for type descriptions when generating byte code.
        Specified by:
        getErasedSignature in class TypeBase
        Parameters:
        sb - StringBuilder to append signature to
        Returns:
        StringBuilder that was passed in; returned to allow call chaining
      • getGenericSignature

        public StringBuilder getGenericSignature​(StringBuilder sb)
        Specified by:
        getGenericSignature in class TypeBase
        Parameters:
        sb - StringBuilder to append signature to
        Returns:
        StringBuilder that was passed in; returned to allow call chaining
      • withKeyTypeHandler

        public MapLikeType withKeyTypeHandler​(Object h)
        Since:
        1.9
      • withKeyValueHandler

        public MapLikeType withKeyValueHandler​(Object h)
        Since:
        1.9
      • isTrueMapType

        public boolean isTrueMapType()
        Method that can be used for checking whether this type is a "real" Collection type; meaning whether it represents a parameterized subtype of Collection or just something that acts like one.
        Since:
        1.8