Package org.faktorips.runtime.model.type
Class Type
java.lang.Object
org.faktorips.runtime.model.type.ModelElement
org.faktorips.runtime.model.type.Type
- Direct Known Subclasses:
PolicyCmptType,ProductCmptType
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceType.AnnotatedElementMatcher<T extends Annotation>Matcher for methods or fields based on annotation properties. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<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 amatcher.<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 amatcher.Returns the published interface for this type.Returns this type's super type ifpresent, otherwise anempty Optional.protected AnnotatedDeclarationReturns theAnnotatedDeclarationobject for this model type that should be used to read all annotations.getAssociation(String name) Returns the association with the givennamedeclared in this type or one of it's super types.abstract List<? extends Association>Returns the type's associations including those defined in it's super types.getAttribute(String name) Returns the attribute with the givennamedeclared in this type or one of it's super types.Returns a list containing the type's attributes including those defined in the type's super types.Class<?>getDeclaredAssociation(int index) Returns the association at the givenindex.abstract AssociationgetDeclaredAssociation(String name) Returns the association with the givennamedeclared in this type.abstract List<? extends Association>Returns a list containing all associations declared in this type.getDeclaredAttribute(int index) Returns the declared attribute at the givenindex.abstract AttributegetDeclaredAttribute(String name) Returns the attribute with the givennamedeclared in this type.Returns a list containing all attributes declared in this model type.getDocumentation(Locale locale, DocumentationKind type, String fallback) Class<?>Returns the Java class for this type.Class<?>Returns the published interface for this type.protected abstract Stringprotected MessagesHelperprotected StringgetMessageKey(DocumentationKind messageType) abstract TypeReturns this type's super type ornullif it has none.abstract booleanisAssociationDeclared(String name) Returns whether the association with the givennameis declared in this type.booleanisAssociationPresent(String name) Returns whether the association with the givennameis declared in this type or in any supertype.abstract booleanisAttributeDeclared(String name) Returns whether the attribute with the givennameis declared in this type.booleanisAttributePresent(String name) Returns whether the attribute with the givennameis declared in this type or in any supertype.booleanReturns whether this type has a super type.<T extends Annotation>
MethodsearchDeclaredMethod(Class<T> annotationClass, Type.AnnotatedElementMatcher<T> matcher) Searches for a method with the given annotation that matches the condition defined by amatcher.toString()Methods inherited from class org.faktorips.runtime.model.type.ModelElement
createMessageHelper, getDeprecation, getDescription, getExtensionPropertyIds, getExtensionPropertyValue, getLabel, getName, getRelevantProductObject, invokeField, invokeMethod, isDeprecated
-
Constructor Details
-
Type
-
-
Method Details
-
getKindName
-
getMessageKey
- Specified by:
getMessageKeyin classModelElement
-
getMessageHelper
- Specified by:
getMessageHelperin classModelElement
-
getDeclaredAssociation
Returns the association at the givenindex. Associations defined in the type's super types are not returned.- Throws:
IndexOutOfBoundsException- if no association exists for the givenindex.
-
getDeclaredAttribute
Returns the declared attribute at the givenindex.- Throws:
IndexOutOfBoundsException- if no attribute exists for the givenindex.
-
getAssociation
Returns the association with the givennamedeclared 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 givennameexists.
-
getAttribute
Returns the attribute with the givennamedeclared in this type or one of it's super types.- Throws:
IllegalArgumentException- if no attribute with the givennameexists.
-
getAnnotatedDeclaration
Returns theAnnotatedDeclarationobject for this model type that should be used to read all annotations. -
getJavaClass
Returns the Java class for this type. -
getJavaInterface
Returns the published interface for this type. Returnsnullif published interfaces are not generated. -
findJavaInterface
Returns the published interface for this type. if published interfaces are generated, otherwise anempty Optional. -
getDeclarationClass
-
toString
- Overrides:
toStringin classModelElement
-
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 amatcher. 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 withmatcher- 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.
nullif 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 amatcher. 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 withmatcher- 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
-
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 amatcher. 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 withmatcher- 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
-
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
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
Returns the association with the givennamedeclared 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 givennameexists- See Also:
-
isAssociationDeclared
Returns whether the association with the givennameis declared in this type. Associations defined in the type's super types are not considered.- Parameters:
name- the name of the association- Returns:
trueif the association is declared in this type,falseif not- See Also:
-
isAssociationPresent
Returns whether the association with the givennameis declared in this type or in any supertype.- Parameters:
name- the name of the association- Returns:
trueif the association is declared in this type or in any supertype,falseif not- See Also:
-
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
Returns whether the attribute with the givennameis declared in this type. Attributes defined in the type's super types are not considered.- Parameters:
name- the name of the attribute- Returns:
trueif the attribute is declared in this type,falseif not
-
isAttributePresent
Returns whether the attribute with the givennameis declared in this type or in any supertype.- Parameters:
name- the name of the attribute- Returns:
trueif the attribute is declared in this type or in any supertype,falseif not
-
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
Returns the attribute with the givennamedeclared 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 givennameexists- See Also:
-
isSuperTypePresent
public boolean isSuperTypePresent()Returns whether this type has a super type.- Returns:
trueif this type has a supertype,falseif not
-
getSuperType
Returns this type's super type ornullif it has none.- See Also:
-
findSuperType
Returns this type's super type ifpresent, otherwise anempty Optional. -
getDocumentation
- Overrides:
getDocumentationin classModelElement
-