Class Type

Direct Known Subclasses:
PolicyCmptType, ProductCmptType

public abstract class Type extends ModelElement
A Type represents a design time type of Faktor-IPS. It provides all meta data for the type as well as for properties like attributes or associations.
  • Constructor Details

  • Method Details

    • getKindName

      protected abstract String getKindName()
    • getMessageKey

      protected String getMessageKey(DocumentationKind messageType)
      Specified by:
      getMessageKey in class ModelElement
    • getMessageHelper

      protected MessagesHelper getMessageHelper()
      Specified by:
      getMessageHelper in class ModelElement
    • getDeclaredAssociation

      public Association getDeclaredAssociation(int index)
      Returns the association at the given index. Associations defined in the type's super types are not returned.
      Throws:
      IndexOutOfBoundsException - if no association exists for the given index.
    • getDeclaredAttribute

      public Attribute getDeclaredAttribute(int index)
      Returns the declared attribute at the given index.
      Throws:
      IndexOutOfBoundsException - if no attribute exists for the given index.
    • getAssociation

      public Association getAssociation(String name)
      Returns the association with the given name declared in this type or one of it's super types. The name could either be the singular or the plural name.
      Throws:
      IllegalArgumentException - if no association with the given name exists.
    • getAttribute

      public Attribute getAttribute(String name)
      Returns the attribute with the given name declared in this type or one of it's super types.
      Throws:
      IllegalArgumentException - if no attribute with the given name exists.
    • getAnnotatedDeclaration

      protected AnnotatedDeclaration getAnnotatedDeclaration()
      Returns the AnnotatedDeclaration object for this model type that should be used to read all annotations.
    • getJavaClass

      public Class<?> getJavaClass()
      Returns the Java class for this type.
    • getJavaInterface

      public Class<?> getJavaInterface()
      Returns the published interface for this type. Returns null if published interfaces are not generated.
      See Also:
    • findJavaInterface

      public Optional<Class<?>> findJavaInterface()
      Returns the published interface for this type. if published interfaces are generated, otherwise an empty Optional.
    • getDeclarationClass

      public Class<?> getDeclarationClass()
    • toString

      public String toString()
      Overrides:
      toString in class ModelElement
    • searchDeclaredMethod

      public <T extends Annotation> Method searchDeclaredMethod(Class<T> annotationClass, Type.AnnotatedElementMatcher<T> matcher)
      Searches for a method with the given annotation that matches the condition defined by a matcher. Only methods in this type's declaration class are considered, thus no methods from super classes are found.
      Parameters:
      annotationClass - the class of the annotation the method must be annotated with
      matcher - matcher to determine if the annotation has the correct properties
      Returns:
      the first method that is both annotated with the given annotation and has the correct annotated properties. null if no such method can be found.
      See Also:
    • findDeclaredMethod

      public <T extends Annotation> Optional<Method> findDeclaredMethod(Class<T> annotationClass, Type.AnnotatedElementMatcher<T> matcher)
      Searches for a method with the given annotation that matches the condition defined by a matcher. Only methods in this type's declaration class are considered, thus no methods from super classes are found.
      Parameters:
      annotationClass - the class of the annotation the method must be annotated with
      matcher - matcher to determine if the annotation has the correct properties
      Returns:
      the first method that is both annotated with the given annotation and has the correct annotated properties. Optional.empty() if no such method can be found.
    • getDeclaredMethods

      protected List<Method> getDeclaredMethods()
    • findDeclaredField

      public <T extends Annotation> Optional<Field> findDeclaredField(Class<T> annotationClass, Type.AnnotatedElementMatcher<T> matcher)
      Searches for a field with the given annotation that matches the condition defined by a matcher. Only fields in this type's declaration class are considered, thus no fields from super classes are found.
      Parameters:
      annotationClass - the class of the annotation the field must be annotated with
      matcher - matcher to determine if the annotation has the correct properties
      Returns:
      the first field that is both annotated with the given annotation and has the correct annotated properties. Optional.empty() if no such field can be found.
    • getDeclaredFields

      protected List<Field> getDeclaredFields()
    • getDeclaredAssociations

      public abstract List<? extends Association> getDeclaredAssociations()
      Returns a list containing all associations declared in this type. Associations defined in the type's super types are not returned.
      Returns:
      the list of associations declared in this type
    • getAssociations

      public abstract List<? extends Association> getAssociations()
      Returns the type's associations including those defined in it's super types.
      Returns:
      the list of all associations declared in this type or in any super type
    • getDeclaredAssociation

      public abstract Association getDeclaredAssociation(String name)
      Returns the association with the given name declared in this type. Associations defined in the type's super types are not considered. The name could either be the singular or the plural name.
      Parameters:
      name - the name of the association
      Returns:
      the association if it was found in this type
      Throws:
      IllegalArgumentException - if no association with the given name exists
      See Also:
    • isAssociationDeclared

      public abstract boolean isAssociationDeclared(String name)
      Returns whether the association with the given name is declared in this type. Associations defined in the type's super types are not considered.
      Parameters:
      name - the name of the association
      Returns:
      true if the association is declared in this type, false if not
      See Also:
    • isAssociationPresent

      public boolean isAssociationPresent(String name)
      Returns whether the association with the given name is declared in this type or in any supertype.
      Parameters:
      name - the name of the association
      Returns:
      true if the association is declared in this type or in any supertype, false if not
      See Also:
    • getDeclaredAttributes

      public abstract List<? extends Attribute> getDeclaredAttributes()
      Returns a list containing all attributes declared in this model type. Attributes defined in the type's super types are not returned.
      Returns:
      the list of attributes declared in this type
    • isAttributeDeclared

      public abstract boolean isAttributeDeclared(String name)
      Returns whether the attribute with the given name is declared in this type. Attributes defined in the type's super types are not considered.
      Parameters:
      name - the name of the attribute
      Returns:
      true if the attribute is declared in this type, false if not
    • isAttributePresent

      public boolean isAttributePresent(String name)
      Returns whether the attribute with the given name is declared in this type or in any supertype.
      Parameters:
      name - the name of the attribute
      Returns:
      true if the attribute is declared in this type or in any supertype, false if not
    • getAttributes

      public abstract List<? extends Attribute> getAttributes()
      Returns a list containing the type's attributes including those defined in the type's super types.
      Returns:
      the list of all attributes declared in this type or in any supertype
    • getDeclaredAttribute

      public abstract Attribute getDeclaredAttribute(String name)
      Returns the attribute with the given name declared in this type. Attributes defined in the type's super types are not returned.
      Parameters:
      name - the name of the attribute
      Returns:
      the attribute if it was found in this type
      Throws:
      IllegalArgumentException - if no attribute with the given name exists
      See Also:
    • isSuperTypePresent

      public boolean isSuperTypePresent()
      Returns whether this type has a super type.
      Returns:
      true if this type has a supertype, false if not
    • getSuperType

      public abstract Type getSuperType()
      Returns this type's super type or null if it has none.
      See Also:
    • findSuperType

      public Optional<? extends Type> findSuperType()
      Returns this type's super type if present, otherwise an empty Optional.
    • getDocumentation

      public String getDocumentation(Locale locale, DocumentationKind type, String fallback)
      Overrides:
      getDocumentation in class ModelElement