Class Classifiers

java.lang.Object
com.nomagic.magicdraw.uml2.Classifiers

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

    • Classifiers

      public Classifiers()
  • Method Details

    • getDerivedClassifiers

      public static 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
    • collectDerivedClassifiers

      public static <T extends Classifier> void collectDerivedClassifiers(Classifier general, Collection<T> result)
      Collect all derived classifiers recursively (not only the direct children).
      Parameters:
      general - general classifier
      result - collection of all derived classifiers
      See Also:
    • isClassifierOfType

      public static boolean isClassifierOfType(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

      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:
    • getDirectDerivedClassifiers

      public static 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(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 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:
    • collectGeneralClassifiersRecursively

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

      public static Collection<Classifier> collectGeneralClassifiersRecursively(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:
    • getDirectGeneralClassifiers

      public static 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:
    • 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 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(Collection<? extends Classifier> classifiers, 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 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, 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, 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 List<EnumerationLiteral> getAllLiterals(Enumeration enumeration)
      Return owned and inherited enumeration literals
      Parameters:
      enumeration - enumeration
      Returns:
      literals
    • getPropertiesWithoutRedefined

      public static 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(Collection<? extends RedefinableElement> major, 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.