Class TypeUtils


  • public final class TypeUtils
    extends Object
    Helper methods for inheritance of Ecore classes
    Version:
    $Rev$
    Author:
    herrmama, $Author$
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean ancestor​(org.eclipse.emf.ecore.EClass class1, org.eclipse.emf.ecore.EClass class2)
      Decide whether the second class is an ancestor of the first class
      static org.eclipse.emf.ecore.EClass commonSuperClass​(List<org.eclipse.emf.ecore.EObject> elements)
      Calculate the common super class of a list of instances
      static boolean isCompatible​(org.eclipse.emf.ecore.EClassifier classifier, org.eclipse.emf.ecore.EClassifier withClassifier)
      Check whether a type can be used in the context where another type is expected
      static org.eclipse.emf.ecore.EClass leastCommonAncestor​(Collection<org.eclipse.emf.ecore.EClass> classes)
      Get the wrapped least common ancestor of a collection of classes
      static org.eclipse.emf.ecore.EClass leastCommonAncestor​(org.eclipse.emf.ecore.EClass class1, org.eclipse.emf.ecore.EClass class2)
      Get the wrapped least common ancestor of two classes
    • Method Detail

      • leastCommonAncestor

        public static org.eclipse.emf.ecore.EClass leastCommonAncestor​(Collection<org.eclipse.emf.ecore.EClass> classes)
        Get the wrapped least common ancestor of a collection of classes
        Parameters:
        classes - Collection of classes
        Returns:
        Wrapped least common ancestor
      • leastCommonAncestor

        public static org.eclipse.emf.ecore.EClass leastCommonAncestor​(org.eclipse.emf.ecore.EClass class1,
                                                                       org.eclipse.emf.ecore.EClass class2)
        Get the wrapped least common ancestor of two classes
        Parameters:
        class1 - First class
        class2 - Second class
        Returns:
        Wrapped least common ancestor
      • ancestor

        public static boolean ancestor​(org.eclipse.emf.ecore.EClass class1,
                                       org.eclipse.emf.ecore.EClass class2)
        Decide whether the second class is an ancestor of the first class
        Parameters:
        class1 - First class
        class2 - Second class
        Returns:
        true if the second class is an ancestor of the first class, false otherwise
      • commonSuperClass

        public static org.eclipse.emf.ecore.EClass commonSuperClass​(List<org.eclipse.emf.ecore.EObject> elements)
        Calculate the common super class of a list of instances
        Parameters:
        elements - List of instances
        Returns:
        Common super class
      • isCompatible

        public static boolean isCompatible​(org.eclipse.emf.ecore.EClassifier classifier,
                                           org.eclipse.emf.ecore.EClassifier withClassifier)
        Check whether a type can be used in the context where another type is expected
        Parameters:
        classifier - Actual type
        withClassifier - Expected type
        Returns:
        true if the actual type is compatible with the expected type, false otherwise