Package spoon.metamodel
Class MetamodelProperty
- java.lang.Object
-
- spoon.metamodel.MetamodelProperty
-
public class MetamodelProperty extends Object
Represents a property of the Spoon metamodel. A property: - is an abstraction of a concrete field in an implementation class - theMetamodelConcept
is the owner of this role, it models the implementation class that contains the field. - encapsulates a pair (CtRole
,MetamodelConcept
). - captures both the type of the field (eg list) and the type of items (eg String).
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContainerKind
getContainerKind()
returns the kind of property (list, value, etc)MMMethod
getMethod(MMMethodKind kind)
MMMethod
getMethodBySignature(String signature)
Set<MMMethod>
getMethods()
List<MMMethod>
getMethods(MMMethodKind kind)
String
getName()
MetamodelConcept
getOwner()
returns the concept that holds this propertyCtRole
getRole()
RoleHandler
getRoleHandler()
MetamodelProperty
getSuperProperty()
CtTypeReference<?>
getTypeOfField()
Return the type of the field for List<String> field the ValueType is List for String field the ValueType is StringCtTypeReference<?>
getTypeofItems()
Returns the type of the property for List<String> field the ValueType is String for String field the ValueType is String (when getContainerKind ==ContainerKind.SINGLE
,getTypeofItems()
==getTypeOfField()
.<T,U>
UgetValue(T element)
boolean
isDerived()
boolean
isUnsettable()
<T,U>
voidsetValue(T element, U value)
String
toString()
-
-
-
Method Detail
-
getName
public String getName()
-
getRole
public CtRole getRole()
-
getOwner
public MetamodelConcept getOwner()
returns the concept that holds this property
-
getContainerKind
public ContainerKind getContainerKind()
returns the kind of property (list, value, etc)
-
getTypeOfField
public CtTypeReference<?> getTypeOfField()
Return the type of the field for List<String> field the ValueType is List for String field the ValueType is String
-
getTypeofItems
public CtTypeReference<?> getTypeofItems()
Returns the type of the property for List<String> field the ValueType is String for String field the ValueType is String (when getContainerKind ==ContainerKind.SINGLE
,getTypeofItems()
==getTypeOfField()
.
-
getMethod
public MMMethod getMethod(MMMethodKind kind)
-
getMethodBySignature
public MMMethod getMethodBySignature(String signature)
- Returns:
MMMethod
accessing this property, which has signature `signature`
-
getMethods
public List<MMMethod> getMethods(MMMethodKind kind)
- Parameters:
kind
-MMMethodKind
- Returns:
- methods of required `kind`
-
isDerived
public boolean isDerived()
- Returns:
- true if this
MetamodelProperty
is derived in owner concept, ig has the annotation @DerivedProperty
.
-
isUnsettable
public boolean isUnsettable()
- Returns:
- true if this
MetamodelProperty
is unsettable in owner concept ie. if the property has the annotation @UnsettableProperty
-
getSuperProperty
public MetamodelProperty getSuperProperty()
- Returns:
- the super
MetamodelProperty
which has same valueType and which is upper in the metamodel hierarchy For example: The super property ofCtField
#NAME isCtNamedElement
#NAME This method can be used to optimize generated code.
-
getRoleHandler
public RoleHandler getRoleHandler()
- Returns:
RoleHandler
which can access runtime data of this Property
-
getValue
public <T,U> U getValue(T element)
- Parameters:
element
- an instance whose attribute value is read- Returns:
- a value of attribute defined by this
MetamodelProperty
from the provided `element`
-
setValue
public <T,U> void setValue(T element, U value)
- Parameters:
element
- an instance whose attribute value is setvalue
- to be set value of attribute defined by thisMetamodelProperty
on the provided `element`
-
-