Package com.github.javaparser.metamodel
Class PropertyMetaModel
- java.lang.Object
-
- com.github.javaparser.metamodel.PropertyMetaModel
-
public class PropertyMetaModel extends java.lang.ObjectMeta-data about a property of a node in the AST.
-
-
Field Summary
Fields Modifier and Type Field Description private BaseNodeMetaModelcontainingNodeMetaModelprivate booleanhasWildcardprivate booleanisNodeListprivate booleanisNonEmptyprivate booleanisOptionalprivate java.lang.Stringnameprivate java.util.Optional<BaseNodeMetaModel>nodeReferenceprivate java.lang.Class<?>type
-
Constructor Summary
Constructors Constructor Description PropertyMetaModel(BaseNodeMetaModel containingNodeMetaModel, java.lang.String name, java.lang.Class<?> type, java.util.Optional<BaseNodeMetaModel> nodeReference, boolean isOptional, boolean isNonEmpty, boolean isNodeList, boolean hasWildcard)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)BaseNodeMetaModelgetContainingNodeMetaModel()java.lang.StringgetGetterMethodName()java.lang.StringgetMetaModelFieldName()The name of the field in the containing BaseNodeMetaModel for this property meta model.java.lang.StringgetName()java.util.Optional<BaseNodeMetaModel>getNodeReference()java.lang.StringgetSetterMethodName()java.lang.Class<?>getType()java.lang.StringgetTypeName()java.lang.StringgetTypeNameForGetter()java.lang.StringgetTypeNameForSetter()java.lang.StringgetTypeNameGenerified()java.lang.ObjectgetValue(Node node)Introspects the node to get the value from this field.inthashCode()booleanhasWildcard()booleanis(java.lang.Class<? extends Node> c, java.lang.String fieldName)booleanis(java.lang.String fieldName)booleanisAttribute()booleanisNode()booleanisNodeList()booleanisNonEmpty()booleanisOptional()booleanisRequired()booleanisSingular()java.lang.StringtoString()
-
-
-
Field Detail
-
containingNodeMetaModel
private final BaseNodeMetaModel containingNodeMetaModel
-
name
private final java.lang.String name
-
type
private final java.lang.Class<?> type
-
nodeReference
private final java.util.Optional<BaseNodeMetaModel> nodeReference
-
isOptional
private final boolean isOptional
-
isNonEmpty
private final boolean isNonEmpty
-
isNodeList
private final boolean isNodeList
-
hasWildcard
private final boolean hasWildcard
-
-
Constructor Detail
-
PropertyMetaModel
public PropertyMetaModel(BaseNodeMetaModel containingNodeMetaModel, java.lang.String name, java.lang.Class<?> type, java.util.Optional<BaseNodeMetaModel> nodeReference, boolean isOptional, boolean isNonEmpty, boolean isNodeList, boolean hasWildcard)
-
-
Method Detail
-
is
public boolean is(java.lang.Class<? extends Node> c, java.lang.String fieldName)
- Returns:
- is this the field fieldName on class c?
-
is
public boolean is(java.lang.String fieldName)
- Returns:
- is this fields called fieldName?
-
getSetterMethodName
public java.lang.String getSetterMethodName()
- Returns:
- the name used in the AST for the setter
-
getGetterMethodName
public java.lang.String getGetterMethodName()
- Returns:
- the name used in the AST for the getter
-
getContainingNodeMetaModel
public BaseNodeMetaModel getContainingNodeMetaModel()
- Returns:
- the NodeMetaModel that "has" this property.
-
getName
public java.lang.String getName()
- Returns:
- the name of the property. This is equal to the name of the field in the AST.
-
isNonEmpty
public boolean isNonEmpty()
- Returns:
- if this property is a String or a NodeList: whether it may be empty.
-
getType
public java.lang.Class<?> getType()
- Returns:
- the class of the field.
-
getNodeReference
public java.util.Optional<BaseNodeMetaModel> getNodeReference()
- Returns:
- if this property is a Node, this will get the node meta model.
-
isOptional
public boolean isOptional()
- Returns:
- whether this property is optional.
-
isRequired
public boolean isRequired()
- Returns:
- whether this property is not optional.
-
isNodeList
public boolean isNodeList()
- Returns:
- whether this property is contained in a NodeList.
-
hasWildcard
public boolean hasWildcard()
- Returns:
- whether this property has a wildcard following it, like BodyDeclaration<?>.
-
isSingular
public boolean isSingular()
- Returns:
- whether this property is not a list or set.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getTypeNameGenerified
public java.lang.String getTypeNameGenerified()
- Returns:
- the type of a single element of this property, so no Optional or NodeList.
-
getTypeName
public java.lang.String getTypeName()
- Returns:
- the raw type of a single element of this property, so nothing but the name.
-
getTypeNameForGetter
public java.lang.String getTypeNameForGetter()
- Returns:
- the type that is returned from getters in the AST.
-
getTypeNameForSetter
public java.lang.String getTypeNameForSetter()
- Returns:
- the type that is passed to setters in the AST.
-
isNode
public boolean isNode()
- Returns:
- is this property an AST Node?
-
getMetaModelFieldName
public java.lang.String getMetaModelFieldName()
The name of the field in the containing BaseNodeMetaModel for this property meta model.
-
isAttribute
public boolean isAttribute()
- Returns:
- is this property an attribute, meaning: not a node?
-
getValue
public java.lang.Object getValue(Node node)
Introspects the node to get the value from this field. Note that an optional empty field will return null here.
-
-