Class Types
java.lang.Object
com.dassault_systemes.modeler.kerml.model.Types
Utility class to work with
Type-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleananyConforms(Collection<Type> subTypes, Collection<Type> superTypes) Checks whether any subtype in the given collection conforms to any supertype in the other collection.static booleanChecks whether the given subtype conforms to the specified supertype.static <F extends Feature>
FgetFeature(Type type, Class<F> featureKind) Retrieves a feature of the given type, searching owned first, then inherited.static FeaturegetFeature(Type type, Predicate<Feature> predicate) Retrieves a feature matching the given predicate.static <F extends Feature>
FgetFeature(Type type, Predicate<F> predicate, Class<F> featureKind) Retrieves a feature of the given type matching the predicate, searching owned first, then inherited.static <T extends FeatureMembership,F extends Feature>
FgetFeatureByMembership(Type type, Class<T> membershipKind) Retrieves a feature of the given membership kind, searching owned first, then inherited.static <T extends FeatureMembership>
TgetFeatureMembership(Type type, Class<T> membershipKind) Retrieves a feature membership of the given kind, searching owned first, then inherited.static List<FeatureMembership> Retrieves all inherited feature memberships of the given type.static FeaturegetOwnedFeature(Type type, Predicate<Feature> predicate) Retrieves an owned feature matching the given predicate.static <T extends FeatureMembership,F extends Feature>
FgetOwnedFeatureByMembership(Type type, Class<T> membershipKind) Retrieves an owned feature of the given membership kind.static List<Documentation> getOwnedOrFirstInheritedDocumentationFromNonStandardLibrary(Type element, ModelElementProject project) Retrieves documentation owned by the type or the first inherited documentation from a non-standard-library supertype.static StringgetOwnedOrFirstInheritedName(Type element, ModelElementProject project) Retrieves the name owned by the type or the first inherited name from a non-standard library supertype.static StringgetOwnedOrFirstInheritedShortName(Type element, ModelElementProject project) Retrieves the short name owned by the type or the first inherited short name from a non-standard library supertype.static StringgetOwnedOrFirstInheritedStringProperty(Type element, ModelElementProject project, Function<Type, String> function) Retrieves a string property (name, short name, etc.) owned by the type or inherited from the first non-standard-library supertype.static booleanisFeatureOf(Feature feature, Type type) Checks whether the given feature belongs to the specified type.static booleanisFeatureOf(Feature feature, Type featureOwningType, Type type) Checks whether the given feature belongs to the specified type, using the owning type if available.static TyperesolveType(Type type) Resolves the underlying type if the given type is a Feature, otherwise returns it unchanged.static booleanspecializes(Type subType, Type supertype) Checks whether the given subtype specializes (is the same as or inherits from) the specified supertype.
-
Constructor Details
-
Types
public Types()
-
-
Method Details
-
specializes
Checks whether the given subtype specializes (is the same as or inherits from) the specified supertype.- Parameters:
subType- the type to checksupertype- the potential supertype- Returns:
- true if subType is the same as or specializes supertype
-
anyConforms
Checks whether any subtype in the given collection conforms to any supertype in the other collection.- Parameters:
subTypes- collection of possible subtypessuperTypes- collection of possible supertypes- Returns:
- true if at least one subtype conforms to at least one supertype
-
conforms
Checks whether the given subtype conforms to the specified supertype.- Parameters:
subtype- the type being checkedsupertype- the type to conform to- Returns:
- true if subtype conforms to supertype
-
resolveType
Resolves the underlying type if the given type is a Feature, otherwise returns it unchanged.- Parameters:
type- the type to resolve- Returns:
- the resolved type or null
-
getOwnedOrFirstInheritedShortName
@CheckForNull public static String getOwnedOrFirstInheritedShortName(Type element, ModelElementProject project) Retrieves the short name owned by the type or the first inherited short name from a non-standard library supertype.- Parameters:
element- the type whose name is requestedproject- the project context- Returns:
- the short name or null
-
getOwnedOrFirstInheritedName
@CheckForNull public static String getOwnedOrFirstInheritedName(Type element, ModelElementProject project) Retrieves the name owned by the type or the first inherited name from a non-standard library supertype.- Parameters:
element- the type whose name is requestedproject- the project context- Returns:
- the name or null
-
getOwnedOrFirstInheritedStringProperty
@CheckForNull public static String getOwnedOrFirstInheritedStringProperty(Type element, ModelElementProject project, Function<Type, String> function) Retrieves a string property (name, short name, etc.) owned by the type or inherited from the first non-standard-library supertype.- Parameters:
element- the type to inspectproject- the project contextfunction- function extracting the string property- Returns:
- the property value or null
-
getOwnedOrFirstInheritedDocumentationFromNonStandardLibrary
public static List<Documentation> getOwnedOrFirstInheritedDocumentationFromNonStandardLibrary(Type element, ModelElementProject project) Retrieves documentation owned by the type or the first inherited documentation from a non-standard-library supertype.- Parameters:
element- the type to inspectproject- the project context- Returns:
- a list of documentation entries (never null)
-
getOwnedFeatureByMembership
@CheckForNull public static <T extends FeatureMembership,F extends Feature> F getOwnedFeatureByMembership(Type type, Class<T> membershipKind) Retrieves an owned feature of the given membership kind.- Type Parameters:
T- membership typeF- feature type- Parameters:
type- the type to inspectmembershipKind- the membership class to search for- Returns:
- the owned feature or null
-
getFeatureMembership
@CheckForNull public static <T extends FeatureMembership> T getFeatureMembership(Type type, Class<T> membershipKind) Retrieves a feature membership of the given kind, searching owned first, then inherited.- Type Parameters:
T- membership type- Parameters:
type- the type to inspectmembershipKind- the membership class to search for- Returns:
- the membership or null
-
getInheritedFeatureMemberships
Retrieves all inherited feature memberships of the given type.- Parameters:
type- the type to inspect- Returns:
- list of inherited feature memberships
-
getFeatureByMembership
@CheckForNull public static <T extends FeatureMembership,F extends Feature> F getFeatureByMembership(Type type, Class<T> membershipKind) Retrieves a feature of the given membership kind, searching owned first, then inherited.- Type Parameters:
T- membership typeF- feature type- Parameters:
type- the type to inspectmembershipKind- the membership class to search for- Returns:
- the feature or null
-
getFeature
Retrieves a feature of the given type, searching owned first, then inherited.- Type Parameters:
F- feature type- Parameters:
type- the type to inspectfeatureKind- the feature class to search for- Returns:
- the feature or null
-
getFeature
Retrieves a feature matching the given predicate.- Parameters:
type- the type to inspectpredicate- the filter predicate- Returns:
- the feature or null
-
getOwnedFeature
Retrieves an owned feature matching the given predicate.- Parameters:
type- the type to inspectpredicate- the filter predicate- Returns:
- the owned feature or null
-
getFeature
@CheckForNull public static <F extends Feature> F getFeature(Type type, Predicate<F> predicate, Class<F> featureKind) Retrieves a feature of the given type matching the predicate, searching owned first, then inherited.- Type Parameters:
F- feature type- Parameters:
type- the type to inspectpredicate- the filter predicatefeatureKind- the feature class to search for- Returns:
- the feature or null
-
isFeatureOf
Checks whether the given feature belongs to the specified type.- Parameters:
feature- the feature to checktype- the type to check against- Returns:
- true if the feature belongs to the type
-
isFeatureOf
Checks whether the given feature belongs to the specified type, using the owning type if available.- Parameters:
feature- the feature to checkfeatureOwningType- the owning type of the feature (may be null)type- the type to check against- Returns:
- true if the feature belongs to the type
-