Package org.yaml.snakeyaml
Class TypeDescription
- java.lang.Object
-
- org.yaml.snakeyaml.TypeDescription
-
public class TypeDescription extends java.lang.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 Summary
Fields Modifier and Type Field Description protected BeanAccess
beanAccess
private boolean
delegatesChecked
private java.util.Set<Property>
dumpProperties
protected java.util.Set<java.lang.String>
excludes
private java.lang.Class<?>
impl
protected java.lang.String[]
includes
private static Logger
log
private java.util.Map<java.lang.String,PropertySubstitute>
properties
private PropertyUtils
propertyUtils
private Tag
tag
private java.lang.Class<? extends java.lang.Object>
type
-
Constructor Summary
Constructors Constructor Description TypeDescription(java.lang.Class<? extends java.lang.Object> clazz)
TypeDescription(java.lang.Class<? extends java.lang.Object> clazz, java.lang.Class<?> impl)
TypeDescription(java.lang.Class<? extends java.lang.Object> clazz, java.lang.String tag)
TypeDescription(java.lang.Class<? extends java.lang.Object> clazz, Tag tag)
TypeDescription(java.lang.Class<? extends java.lang.Object> clazz, Tag tag, java.lang.Class<?> impl)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addPropertyParameters(java.lang.String pName, java.lang.Class<?>... classes)
Adds new substitute for propertypName
parameterized byclasses
to thisTypeDescription
.private void
checkDelegates()
private Property
discoverProperty(java.lang.String name)
java.lang.Object
finalizeConstruction(java.lang.Object obj)
Is invoked after entity is filled with values from deserialized YAMLjava.util.Set<Property>
getProperties()
Property
getProperty(java.lang.String name)
Tag
getTag()
Get tag which shall be used to load or dump the type (class).java.lang.Class<? extends java.lang.Object>
getType()
Get represented type (class)java.lang.Object
newInstance(java.lang.String propertyName, Node node)
java.lang.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.void
putListPropertyType(java.lang.String property, java.lang.Class<? extends java.lang.Object> type)
Deprecated.void
putMapPropertyType(java.lang.String property, java.lang.Class<? extends java.lang.Object> key, java.lang.Class<? extends java.lang.Object> value)
Deprecated.void
setExcludes(java.lang.String... propNames)
void
setIncludes(java.lang.String... propNames)
boolean
setProperty(java.lang.Object targetBean, java.lang.String propertyName, java.lang.Object value)
void
setPropertyUtils(PropertyUtils propertyUtils)
boolean
setupPropertyType(java.lang.String key, Node valueNode)
void
substituteProperty(java.lang.String pName, java.lang.Class<?> pType, java.lang.String getter, java.lang.String setter, java.lang.Class<?>... argParams)
Adds property substitute forpName
void
substituteProperty(PropertySubstitute substitute)
java.lang.String
toString()
-
-
-
Field Detail
-
log
private static final Logger log
-
type
private final java.lang.Class<? extends java.lang.Object> type
-
impl
private java.lang.Class<?> impl
-
tag
private final Tag tag
-
dumpProperties
private transient java.util.Set<Property> dumpProperties
-
propertyUtils
private transient PropertyUtils propertyUtils
-
delegatesChecked
private transient boolean delegatesChecked
-
properties
private java.util.Map<java.lang.String,PropertySubstitute> properties
-
excludes
protected java.util.Set<java.lang.String> excludes
-
includes
protected java.lang.String[] includes
-
beanAccess
protected BeanAccess beanAccess
-
-
Constructor Detail
-
TypeDescription
public TypeDescription(java.lang.Class<? extends java.lang.Object> clazz, Tag tag)
-
TypeDescription
public TypeDescription(java.lang.Class<? extends java.lang.Object> clazz, Tag tag, java.lang.Class<?> impl)
-
TypeDescription
public TypeDescription(java.lang.Class<? extends java.lang.Object> clazz, java.lang.String tag)
-
TypeDescription
public TypeDescription(java.lang.Class<? extends java.lang.Object> clazz)
-
TypeDescription
public TypeDescription(java.lang.Class<? extends java.lang.Object> clazz, java.lang.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 java.lang.Class<? extends java.lang.Object> getType()
Get represented type (class)- Returns:
- type (class) to be described.
-
putListPropertyType
@Deprecated public void putListPropertyType(java.lang.String property, java.lang.Class<? extends java.lang.Object> type)
Deprecated.Specify that the property is a type-safeList
.- Parameters:
property
- name of the JavaBean propertytype
- class of List values
-
putMapPropertyType
@Deprecated public void putMapPropertyType(java.lang.String property, java.lang.Class<? extends java.lang.Object> key, java.lang.Class<? extends java.lang.Object> value)
Deprecated.Specify that the property is a type-safeMap
.- Parameters:
property
- property name of this JavaBeankey
- class of keys in Mapvalue
- class of values in Map
-
addPropertyParameters
public void addPropertyParameters(java.lang.String pName, java.lang.Class<?>... classes)
Adds new substitute for propertypName
parameterized byclasses
to thisTypeDescription
. IfpName
has been added before - updates parameters withclasses
.- Parameters:
pName
- - parameter nameclasses
- - parameterized by
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
checkDelegates
private void checkDelegates()
-
discoverProperty
private Property discoverProperty(java.lang.String name)
-
getProperty
public Property getProperty(java.lang.String name)
-
substituteProperty
public void substituteProperty(java.lang.String pName, java.lang.Class<?> pType, java.lang.String getter, java.lang.String setter, java.lang.Class<?>... argParams)
Adds property substitute forpName
- Parameters:
pName
- property namepType
- property typegetter
- method name for gettersetter
- method name for setterargParams
- actual types for parameterized type (List<?>, Map<?>)
-
substituteProperty
public void substituteProperty(PropertySubstitute substitute)
-
setPropertyUtils
public void setPropertyUtils(PropertyUtils propertyUtils)
-
setIncludes
public void setIncludes(java.lang.String... propNames)
-
setExcludes
public void setExcludes(java.lang.String... propNames)
-
getProperties
public java.util.Set<Property> getProperties()
-
setupPropertyType
public boolean setupPropertyType(java.lang.String key, Node valueNode)
-
setProperty
public boolean setProperty(java.lang.Object targetBean, java.lang.String propertyName, java.lang.Object value) throws java.lang.Exception
- Throws:
java.lang.Exception
-
newInstance
public java.lang.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 java.lang.Object newInstance(java.lang.String propertyName, Node node)
-
finalizeConstruction
public java.lang.Object finalizeConstruction(java.lang.Object obj)
Is invoked after entity is filled with values from deserialized YAML- Parameters:
obj
- - deserialized entity- Returns:
- postprocessed deserialized entity
-
-