Class TypeDescription

java.lang.Object
org.yaml.snakeyaml.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.
  • Field Details

    • excludes

      protected Set<String> excludes
    • includes

      protected String[] includes
    • beanAccess

      protected BeanAccess beanAccess
  • Constructor Details

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

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

      @Deprecated public Class<? extends Object> getListPropertyType(String property)
      Deprecated.
      Get class of List values for provided JavaBean property.
      Parameters:
      property - property name
      Returns:
      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
    • getMapKeyType

      @Deprecated public Class<? extends Object> getMapKeyType(String property)
      Deprecated.
      Get keys type info for this JavaBean
      Parameters:
      property - property name of this JavaBean
      Returns:
      class of keys in the Map
    • getMapValueType

      @Deprecated public Class<? extends Object> getMapValueType(String property)
      Deprecated.
      Get values type info for this JavaBean
      Parameters:
      property - property name of this JavaBean
      Returns:
      class of values in the 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
    • toString

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

      public Property getProperty(String name)
    • 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<?>)
    • substituteProperty

      public void substituteProperty(PropertySubstitute substitute)
    • setPropertyUtils

      public void setPropertyUtils(PropertyUtils propertyUtils)
    • setIncludes

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

      public void setExcludes(String... propNames)
    • getProperties

      public Set<Property> getProperties()
    • setupPropertyType

      public boolean setupPropertyType(String key, Node valueNode)
    • setProperty

      public boolean setProperty(Object targetBean, String propertyName, Object value) throws Exception
      Throws:
      Exception
    • 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
    • newInstance

      public Object newInstance(String propertyName, Node node)
    • 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