Class MetamodelProperty


  • public class MetamodelProperty
    extends java.lang.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 Detail

      • getName

        public java.lang.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
      • getMethodBySignature

        public MMMethod getMethodBySignature​(java.lang.String signature)
        Returns:
        MMMethod accessing this property, which has signature `signature`
      • getMethods

        public java.util.Set<MMMethod> getMethods()
        Returns:
        all methods which are accessing this property
      • isUnsettable

        public boolean isUnsettable()
        Returns:
        true if this MetamodelProperty is unsettable in owner concept ie. if the property has the annotation @UnsettableProperty
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.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`