Class TypeDescription


  • public class TypeDescription
    extends Object
    Provides additional runtime information necessary to create a custom Java instance. In general this class is thread-safe and can be used as a singleton, the only exception being the PropertyUtils field. A singleton PropertyUtils should be constructed and shared between all YAML Constructors used if a singleton TypeDescription is used, since Constructor sets its propertyUtils to the TypeDescription that is passed to it, hence you may end up in a situation when propertyUtils in TypeDescription is from different Constructor.
    • Constructor Detail

      • TypeDescription

        public TypeDescription​(Class<? extends Object> clazz,
                               Tag tag)
      • TypeDescription

        public TypeDescription​(Class<? extends Object> clazz,
                               Tag tag,
                               Class<?> impl)
      • TypeDescription

        public TypeDescription​(Class<? extends Object> clazz,
                               String tag)
      • TypeDescription

        public TypeDescription​(Class<? extends Object> clazz)
      • TypeDescription

        public TypeDescription​(Class<? extends Object> clazz,
                               Class<?> impl)
    • Method Detail

      • getTag

        public Tag getTag()
        Get tag which shall be used to load or dump the type (class).
        Returns:
        tag to be used. It may be a tag for Language-Independent Types (http://www.yaml.org/type/)
      • getType

        public Class<? extends Object> getType()
        Get represented type (class)
        Returns:
        type (class) to be described.
      • putListPropertyType

        @Deprecated
        public void putListPropertyType​(String property,
                                        Class<? extends Object> type)
        Deprecated.
        Specify that the property is a type-safe List.
        Parameters:
        property - name of the JavaBean property
        type - class of List values
      • putMapPropertyType

        @Deprecated
        public void putMapPropertyType​(String property,
                                       Class<? extends Object> key,
                                       Class<? extends Object> value)
        Deprecated.
        Specify that the property is a type-safe Map.
        Parameters:
        property - property name of this JavaBean
        key - class of keys in Map
        value - class of values in Map
      • addPropertyParameters

        public void addPropertyParameters​(String pName,
                                          Class<?>... classes)
        Adds new substitute for property pName parameterized by classes to this TypeDescription. If pName has been added before - updates parameters with classes.
        Parameters:
        pName - - parameter name
        classes - - parameterized by
      • substituteProperty

        public void substituteProperty​(String pName,
                                       Class<?> pType,
                                       String getter,
                                       String setter,
                                       Class<?>... argParams)
        Adds property substitute for pName
        Parameters:
        pName - property name
        pType - property type
        getter - method name for getter
        setter - method name for setter
        argParams - actual types for parameterized type (List<?>, Map<?>)
      • setPropertyUtils

        public void setPropertyUtils​(PropertyUtils propertyUtils)
      • setIncludes

        public void setIncludes​(String... propNames)
      • setExcludes

        public void setExcludes​(String... propNames)
      • setupPropertyType

        public boolean setupPropertyType​(String key,
                                         Node valueNode)
      • newInstance

        public Object newInstance​(Node node)
        This method should be overridden for TypeDescription implementations that are supposed to implement instantiation logic that is different from default one as implemented in YAML constructors. Note that even if you override this method, default filling of fields with variables from parsed YAML will still occur later.
        Parameters:
        node - - node to construct the instance from
        Returns:
        new instance
      • finalizeConstruction

        public Object finalizeConstruction​(Object obj)
        Is invoked after entity is filled with values from deserialized YAML
        Parameters:
        obj - - deserialized entity
        Returns:
        postprocessed deserialized entity