Class EMFUtils


  • public final class EMFUtils
    extends java.lang.Object
    Util class for basic EMF.
    Since:
    1.5
    Author:
    Eugen Neufeld
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <A> java.util.Optional<A> adapt​(org.eclipse.emf.ecore.EObject object, java.lang.Class<A> adapter)
      Tries to adapt the given EObject to the given class.
      static boolean filteredEquals​(org.eclipse.emf.ecore.EObject property, org.eclipse.emf.ecore.EObject other, org.eclipse.emf.ecore.EStructuralFeature... filteredFeatures)
      Check two EObjects for equality by comparing their EClass and all their features' values.
      static java.util.Set<org.eclipse.emf.ecore.EPackage> getAllRegisteredEPackages()
      Returns the set of all known EPackages.
      static java.util.Collection<org.eclipse.emf.ecore.EClass> getSubClasses​(org.eclipse.emf.ecore.EClass superClass)
      This method looks through all known EPackages to find all concrete subclasses for the provided super class (abstract classes and interfaces will be ignored).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getSubClasses

        public static java.util.Collection<org.eclipse.emf.ecore.EClass> getSubClasses​(org.eclipse.emf.ecore.EClass superClass)
        This method looks through all known EPackages to find all concrete subclasses for the provided super class (abstract classes and interfaces will be ignored). If the EClass is EObject, all non abstract and non interface classes will be returned.
        Parameters:
        superClass - - the class for which to get the subclasses
        Returns:
        a Collection of EClasses
      • getAllRegisteredEPackages

        public static java.util.Set<org.eclipse.emf.ecore.EPackage> getAllRegisteredEPackages()
        Returns the set of all known EPackages.
        Returns:
        the Set of all known Epackages
      • filteredEquals

        public static boolean filteredEquals​(org.eclipse.emf.ecore.EObject property,
                                             org.eclipse.emf.ecore.EObject other,
                                             org.eclipse.emf.ecore.EStructuralFeature... filteredFeatures)
        Check two EObjects for equality by comparing their EClass and all their features' values. Additionally, an arbitrary number of features can be supplied whose values will not be compared to determine equality. This can be used to implement a custom equality check in the client.
        Parameters:
        property - The EObject triggering the comparison, might be null.
        other - The other style EObject, might be null
        filteredFeatures - Features that are ignored in the equality check.
        Returns:
        true if the EClass and the values of all features are equal or if both EObjects are null, false otherwise
        Since:
        1.18
      • adapt

        public static <A> java.util.Optional<A> adapt​(org.eclipse.emf.ecore.EObject object,
                                                      java.lang.Class<A> adapter)
        Tries to adapt the given EObject to the given class. This is done with help of the EObject's AdapterFactoryEditingDomain.
        Type Parameters:
        A - The adapter type
        Parameters:
        object - The EObject to adapt
        adapter - The adapter class
        Returns:
        The adapted EObject or nothing if the EObjects AdapterFactoryEditingDomain could not be determined or the EObject could not be adapted to the target type.
        Since:
        1.21