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 - the MetamodelConcept 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 Details

    • 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`
    • getMethods

      public Set<MMMethod> getMethods()
      Returns:
      all methods which are accessing this property
    • 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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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 of CtField#NAME is CtNamedElement#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 set
      value - to be set value of attribute defined by this MetamodelProperty on the provided `element`