Class Classifiers


  • public class Classifiers
    extends java.lang.Object
    Convenience utility methods that operate on or return Classifier elements.
    • Constructor Detail

      • Classifiers

        public Classifiers()
    • Method Detail

      • getDerivedClassifiers

        public static java.util.Collection<Classifier> getDerivedClassifiers​(Classifier general)
        Get all derived classifiers for given classifier recursively. Result does not include given classifier.
        Parameters:
        general - given classifier to collect specific classifiers for
        Returns:
        collection of all derived classifiers
      • internalCollectDerivedClassifiers

        public static <T extends Classifier> void internalCollectDerivedClassifiers​(Classifier general,
                                                                                    java.util.Collection<T> result)
      • isClassifierOfType

        public static boolean isClassifierOfType​(java.util.Collection<? extends Classifier> classifiers,
                                                 Classifier type)
        Tests if there is at least one classifier among given ones which isTypeOf (equals or is derived) given type.
        Parameters:
        classifiers - the given classifier
        type - the given type
        Returns:
        true if classifiers contains at least one classifier which isTypeOf type
      • isSameOrDerivedClassifier

        public static boolean isSameOrDerivedClassifier​(@CheckForNull
                                                        Classifier parent,
                                                        @CheckForNull
                                                        Classifier child)
        Checks if given classifier "child" is same as "parent" or is derived from "parent".
        Parameters:
        parent - parent classifier
        child - child classifier
        Returns:
        true if same or derived
        See Also:
        isDerivedClassifier(Classifier, Classifier)
      • isDerivedClassifier

        public static boolean isDerivedClassifier​(@CheckForNull
                                                  Classifier parent,
                                                  @CheckForNull
                                                  Classifier child)
        Checks if given classifier "child" is derived from "parent".
        Parameters:
        parent - parent classifier
        child - child classifier
        Returns:
        true if derived
        See Also:
        isDerivedClassifier(Classifier, Classifier)
      • getDirectDerivedClassifiers

        public static java.util.Collection<Classifier> getDirectDerivedClassifiers​(@CheckForNull
                                                                                   Classifier general)
        Return classifiers derived directly from the given classifier
        Parameters:
        general - general classifier
        Returns:
        collection of direct derived classifiers
      • getClassifierOrDerived

        @CheckForNull
        public static Classifier getClassifierOrDerived​(java.util.Collection<? extends Classifier> classifiers,
                                                        Classifier checkFor)
        Checks if classifier collection contains given classifier or any derived from it, and returns the first found
        Parameters:
        classifiers - collection of classifiers to look in
        checkFor - target classifier
        Returns:
        returns classifier which equals to the given or is derived
      • getGeneralClassifiersRecursively

        public static java.util.Collection<Classifier> getGeneralClassifiersRecursively​(Classifier specific)
        Returns all general classifiers including the indirect ones up to the hierarchy top.
        Parameters:
        specific - classifier
        Returns:
        general classifiers
        See Also:
        getDirectGeneralClassifiers(Classifier)
      • collectGeneralClassifiersRecursively

        public static <T extends Classifier> void collectGeneralClassifiersRecursively​(Classifier specific,
                                                                                       java.util.Collection<T> result)
        Collects all general classifiers including the indirect ones up to the hierarchy top.
        Parameters:
        specific - classifier
        result - general classifiers
      • internalCollectGeneralClassifiersRecursively

        public static <T extends Classifier> void internalCollectGeneralClassifiersRecursively​(Classifier specific,
                                                                                               java.util.Collection<T> result)
      • collectGeneralClassifiersRecursively

        public static java.util.Collection<Classifier> collectGeneralClassifiersRecursively​(java.util.Collection<? extends Classifier> classifiers)
        Returns all general classifiers including the indirect ones up to hierarchy top. Result includes given classifiers.
        Parameters:
        classifiers - classifier
        Returns:
        general elements
        See Also:
        getGeneralClassifiersRecursively(Classifier)
      • getDirectGeneralClassifiers

        public static java.util.Collection<Classifier> getDirectGeneralClassifiers​(Classifier classifier)
        Returns general classifiers from which the given classifier is directly derived.
        Parameters:
        classifier - classifier
        Returns:
        direct general classifiers
        See Also:
        getGeneralClassifiersRecursively(Classifier)
      • isDerivedOrRealizes

        public static boolean isDerivedOrRealizes​(Classifier classifier,
                                                  Classifier type)
        Checks if classifier is derived from given type or realizes the given type.
        Parameters:
        classifier - classifier to check
        type - type
        Returns:
        true if derived or realizes
      • getRealizedInterfaces

        public static java.util.List<Interface> getRealizedInterfaces​(BehavioredClassifier classifier)
        Collects all realized interfaces by the given classifier directly.
        Parameters:
        classifier - given classifier
        Returns:
        a collection of realized interfaces(may be empty)
      • collectRealizedInterfacesRecursively

        public static void collectRealizedInterfacesRecursively​(java.util.Collection<? extends Classifier> classifiers,
                                                                java.util.Collection<Interface> result)
        Collects all realized interfaces by the given classifiers and their general classifiers recursively.
        Parameters:
        classifiers - classifiers to collect realized interfaces from
        result - a collection to append interfaces to
      • collectInterfaceRealizations

        public static java.util.List<InterfaceRealization> collectInterfaceRealizations​(BehavioredClassifier classifier,
                                                                                        Interface contract)
        Collects interface realizations for the given contract
        Parameters:
        classifier - classifier that might realize the interface
        contract - interface to check realizations for
        Returns:
        a collection of interface realizations (may be empty)
      • collectInheritedRealizedInterfaces

        public static void collectInheritedRealizedInterfaces​(BehavioredClassifier classifier,
                                                              java.util.Collection<Interface> result,
                                                              boolean collectOwned)
        Collect inherited and directly realized interfaces from the given classifier
        Parameters:
        classifier - classifier
        result - result collection
        collectOwned - if true, collected also owned
      • collectInheritedEnumerationLiterals

        public static void collectInheritedEnumerationLiterals​(Enumeration enumeration,
                                                               java.util.Collection<EnumerationLiteral> result,
                                                               boolean collectOwned,
                                                               boolean collectPrivate)
        Collect inherited and owned literals from the given enumeration.
        Parameters:
        enumeration - enumeration
        result - result collection
        collectOwned - if true, collected also owned
        collectPrivate - if false, do not collect private
      • getAllLiterals

        public static java.util.List<EnumerationLiteral> getAllLiterals​(Enumeration enumeration)
        Return owned and inherited enumeration literals
        Parameters:
        enumeration - enumeration
        Returns:
        literals
      • getPropertiesWithoutRedefined

        public static java.util.List<Property> getPropertiesWithoutRedefined​(Classifier classifier)
        Gets owned and inherited properties without redefined ones.
        Parameters:
        classifier - classifiers from which properties will be collected
        Returns:
        owned and inherited properties without redefined ones.
      • removeRedefined

        public static void removeRedefined​(java.util.Collection<? extends RedefinableElement> major,
                                           java.util.Collection<? extends RedefinableElement>... additional)
        Removes redefined elements from a given major collection. Major collection is a result. Additional collections are optional and are used only for redefined elements collecting
        Parameters:
        major - elements to remove redefined elements from
        additional - elements to remove redefined elements from
      • isSameOrRedefined

        public static boolean isSameOrRedefined​(@CheckForNull
                                                Property first,
                                                @CheckForNull
                                                Property second)
        Check if given first property is the same as second property or first property is redefined by second property
        Parameters:
        first - first property
        second - second property
        Returns:
        first is the same as second or is redefined by second
      • getSameOrRedefined

        public static Property getSameOrRedefined​(Classifier classifier,
                                                  Property property)
        Resolves given property to itself or property redefined in the given classifier.
        Parameters:
        classifier - classifier
        property - property to check
        Returns:
        given property or redefined if classifier redefines given property directly or indirectly
      • isSecondTypeCompatibleToFirst

        public static boolean isSecondTypeCompatibleToFirst​(@CheckForNull
                                                            Type firstType,
                                                            @CheckForNull
                                                            Type secondType,
                                                            boolean checkRealizedInterfaces)
        Indicates if second parameter type is compatible to the first (is same type or a subtype).
        Parameters:
        firstType - parameter, to which the 2nd parameter must be compatible.
        secondType - parameter, which should be compatible to the 1st.
        checkRealizedInterfaces - indicates if realized interfaces should be taken into account when checking type compatibility.
        Returns:
        true if parameters are compatible, false otherwise.