Package org.eclipse.emf.cdo.common.model

## Class EMFUtil

- java.lang.Object
- - org.eclipse.emf.cdo.common.model.EMFUtil

-     public final class EMFUtil
      extends java.lang.Object

  Various static helper methods for dealing with EMF meta models.
  Since:
    2.0
  Author:
    Eike Stepper

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `EMFUtil.ExtResourceSet` | An extension of `ResourceSetImpl` that allows demandLoading of resources and delegation of resource lookups, to be switched on/off as desired.

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static org.eclipse.net4j.util.Predicate<org.eclipse.emf.ecore.EStructuralFeature>` | `ATTRIBUTES` | Deprecated. As of 4.9 use `EMFPredicates.ATTRIBUTES`.
    `static java.lang.String` | `CDO_ANNOTATION_KEY_PERSISTENT` |
    `static java.lang.String` | `CDO_ANNOTATION_SOURCE` |
    `static org.eclipse.net4j.util.Predicate<org.eclipse.emf.ecore.EStructuralFeature>` | `CONTAINER_REFERENCES` | Deprecated. As of 4.9 use `EMFPredicates.CONTAINER_REFERENCES`.
    `static org.eclipse.net4j.util.Predicate<org.eclipse.emf.ecore.EStructuralFeature>` | `CONTAINMENT_REFERENCES` | Deprecated. As of 4.9 use `EMFPredicates.CONTAINMENT_REFERENCES`.
    `static org.eclipse.net4j.util.Predicate<org.eclipse.emf.ecore.EStructuralFeature>` | `CROSS_REFERENCES` | Deprecated. As of 4.9 use `EMFPredicates.CROSS_REFERENCES`.
    `static org.eclipse.emf.ecore.EReference` | `ECLASS_EGENERIC_SUPER_TYPES` |
    `static org.eclipse.emf.ecore.EReference` | `ECLASS_ESUPER_TYPES` |
    `static org.eclipse.emf.ecore.EAttribute` | `ECLASSIFIER_INSTANCE_CLASS_NAME` |
    `static org.eclipse.emf.ecore.EAttribute` | `ECLASSIFIER_INSTANCE_TYPE_NAME` |
    `static org.eclipse.emf.ecore.EReference` | `EOPERATION_EEXCEPTIONS` |
    `static org.eclipse.emf.ecore.EReference` | `EOPERATION_EGENERIC_EXCEPTIONS` |
    `static org.eclipse.emf.ecore.EReference` | `ETYPED_ELEMENT_EGENERIC_TYPE` |
    `static org.eclipse.emf.ecore.EReference` | `ETYPED_ELEMENT_ETYPE` |
    `static org.eclipse.net4j.util.Predicate<org.eclipse.emf.ecore.EStructuralFeature>` | `REFERENCES` | Deprecated. As of 4.9 use `EMFPredicates.REFERENCES`.

  - ### Method Summary

    All Methods Static Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static void` | `addAdapter​(org.eclipse.emf.common.notify.Notifier notifier, org.eclipse.emf.common.notify.Adapter adapter)` |
    `static org.eclipse.emf.ecore.EAttribute` | `createEAttribute​(org.eclipse.emf.ecore.EClass eClass, java.lang.String name, org.eclipse.emf.ecore.EClassifier type)` |
    `static org.eclipse.emf.ecore.EClass` | `createEClass​(org.eclipse.emf.ecore.EPackage ePackage, java.lang.String name, boolean isAbstract, boolean isInterface)` |
    `static org.eclipse.emf.ecore.EPackage` | `createEPackage​(java.lang.String uri, byte[] bytes, boolean zipped, org.eclipse.emf.ecore.resource.ResourceSet resourceSet, boolean lookForResource)` |
    `static org.eclipse.emf.ecore.EPackage` | `createEPackage​(java.lang.String name, java.lang.String nsPrefix, java.lang.String nsURI)` |
    `static org.eclipse.emf.ecore.EReference` | `createEReference​(org.eclipse.emf.ecore.EClass eClass, java.lang.String name, org.eclipse.emf.ecore.EClassifier type, boolean isRequired, boolean isMany)` |
    `static EMFUtil.ExtResourceSet` | `createExtResourceSet​(InternalCDOPackageRegistry packageRegistry, boolean delegating, boolean demandLoading)` |
    `static void` | `forAllConcreteClasses​(org.eclipse.emf.ecore.EPackage ePackage, boolean includeSubPackages, java.util.function.Consumer<org.eclipse.emf.ecore.EClass> consumer)` |
    `static <T> T` | `getAdapter​(org.eclipse.emf.common.notify.Notifier notifier, java.lang.Class<T> type)` |
    `static org.eclipse.emf.ecore.EPackage[]` | `getAllPackages​(org.eclipse.emf.ecore.EPackage ePackage)` |
    `static org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EAnnotation>` | `getAnnotations​(org.eclipse.emf.ecore.EClass eClass, java.lang.String sourceURI)` |
    `static org.eclipse.emf.ecore.EClass` | `getAnyConcreteEClass​(org.eclipse.emf.ecore.EPackage ePackage, boolean includeSubPackages)` |
    `static org.eclipse.emf.ecore.EClass[]` | `getConcreteClasses​(org.eclipse.emf.ecore.EPackage ePackage)` |
    `static org.eclipse.emf.ecore.EClass[]` | `getConcreteClasses​(org.eclipse.emf.ecore.EPackage ePackage, boolean includeSubPackages)` |
    `static byte[]` | `getEPackageBytes​(org.eclipse.emf.ecore.EPackage ePackage, boolean zipped, org.eclipse.emf.ecore.EPackage.Registry packageRegistry)` |
    `static org.eclipse.emf.ecore.EPackage` | `getGeneratedEPackage​(org.eclipse.emf.ecore.EPackage ePackage)` |
    `static java.lang.String` | `getParentURI​(org.eclipse.emf.ecore.EPackage ePackage)` |
    `static org.eclipse.emf.ecore.EClass[]` | `getPersistentClasses​(org.eclipse.emf.ecore.EPackage ePackage)` |
    `static java.util.List<org.eclipse.emf.ecore.EStructuralFeature>` | `getPersistentFeatures​(org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EStructuralFeature> eFeatures)` | Deprecated. This method is expensive and will be removed in the future.
    `static org.eclipse.emf.common.util.URI` | `getPositionalURI​(org.eclipse.emf.ecore.InternalEObject internalEObject)` |
    `static java.lang.String` | `getQualifiedName​(org.eclipse.emf.ecore.EClassifier classifier, java.lang.String separator)` |
    `static java.lang.String` | `getQualifiedName​(org.eclipse.emf.ecore.EPackage ePackage, java.lang.String separator)` |
    `static java.util.Map.Entry<java.lang.String,​java.lang.Object>[]` | `getSortedRegistryEntries​(org.eclipse.emf.ecore.EPackage.Registry packageRegistry)` |
    `static org.eclipse.emf.ecore.EPackage` | `getTopLevelPackage​(org.eclipse.emf.ecore.EPackage ePackage)` |
    `static boolean` | `isDynamicEPackage​(java.lang.Object value)` |
    `static boolean` | `isPersistent​(org.eclipse.emf.ecore.EStructuralFeature feature)` | Returns `true` if CDO considers the given feature persistent, `false` otherwise.
    `static org.eclipse.emf.ecore.resource.ResourceSet` | `newEcoreResourceSet()` |
    `static org.eclipse.emf.ecore.resource.ResourceSet` | `newEcoreResourceSet​(org.eclipse.emf.ecore.EPackage.Registry packageRegistry)` |
    `static org.eclipse.emf.ecore.resource.ResourceSet` | `newResourceSet​(org.eclipse.emf.ecore.resource.Resource.Factory resourceFactory)` |
    `static void` | `registerPackage​(org.eclipse.emf.ecore.EPackage ePackage, org.eclipse.emf.ecore.EPackage.Registry... packageRegistries)` |
    `static org.eclipse.emf.ecore.EObject` | `safeResolve​(org.eclipse.emf.ecore.EObject proxy, org.eclipse.emf.ecore.resource.ResourceSet resourceSet)` |
    `static void` | `safeResolveAll​(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### CDO_ANNOTATION_SOURCE

          public static final java.lang.String CDO_ANNOTATION_SOURCE

      Since:
        3.0
      See Also:
        Constant Field Values

    - #### CDO_ANNOTATION_KEY_PERSISTENT

          public static final java.lang.String CDO_ANNOTATION_KEY_PERSISTENT

      Since:
        3.0
      See Also:
        Constant Field Values

    - #### EOPERATION_EEXCEPTIONS

          public static final org.eclipse.emf.ecore.EReference EOPERATION_EEXCEPTIONS

      Since:
        4.2

    - #### ETYPED_ELEMENT_ETYPE

          public static final org.eclipse.emf.ecore.EReference ETYPED_ELEMENT_ETYPE

      Since:
        4.2

    - #### ECLASS_ESUPER_TYPES

          public static final org.eclipse.emf.ecore.EReference ECLASS_ESUPER_TYPES

      Since:
        4.2

    - #### ECLASSIFIER_INSTANCE_CLASS_NAME

          public static final org.eclipse.emf.ecore.EAttribute ECLASSIFIER_INSTANCE_CLASS_NAME

      Since:
        4.2

    - #### EOPERATION_EGENERIC_EXCEPTIONS

          public static final org.eclipse.emf.ecore.EReference EOPERATION_EGENERIC_EXCEPTIONS

      Since:
        4.2

    - #### ETYPED_ELEMENT_EGENERIC_TYPE

          public static final org.eclipse.emf.ecore.EReference ETYPED_ELEMENT_EGENERIC_TYPE

      Since:
        4.2

    - #### ECLASS_EGENERIC_SUPER_TYPES

          public static final org.eclipse.emf.ecore.EReference ECLASS_EGENERIC_SUPER_TYPES

      Since:
        4.2

    - #### ECLASSIFIER_INSTANCE_TYPE_NAME

          public static final org.eclipse.emf.ecore.EAttribute ECLASSIFIER_INSTANCE_TYPE_NAME

      Since:
        4.2

    - #### ATTRIBUTES

          @Deprecated
          public static final org.eclipse.net4j.util.Predicate<org.eclipse.emf.ecore.EStructuralFeature> ATTRIBUTES

      Deprecated.
      As of 4.9 use `EMFPredicates.ATTRIBUTES`.
      Since:
        4.2

    - #### REFERENCES

          @Deprecated
          public static final org.eclipse.net4j.util.Predicate<org.eclipse.emf.ecore.EStructuralFeature> REFERENCES

      Deprecated.
      As of 4.9 use `EMFPredicates.REFERENCES`.
      Since:
        4.2

    - #### CONTAINER_REFERENCES

          @Deprecated
          public static final org.eclipse.net4j.util.Predicate<org.eclipse.emf.ecore.EStructuralFeature> CONTAINER_REFERENCES

      Deprecated.
      As of 4.9 use `EMFPredicates.CONTAINER_REFERENCES`.
      Since:
        4.2

    - #### CROSS_REFERENCES

          @Deprecated
          public static final org.eclipse.net4j.util.Predicate<org.eclipse.emf.ecore.EStructuralFeature> CROSS_REFERENCES

      Deprecated.
      As of 4.9 use `EMFPredicates.CROSS_REFERENCES`.
      Since:
        4.2

    - #### CONTAINMENT_REFERENCES

          @Deprecated
          public static final org.eclipse.net4j.util.Predicate<org.eclipse.emf.ecore.EStructuralFeature> CONTAINMENT_REFERENCES

      Deprecated.
      As of 4.9 use `EMFPredicates.CONTAINMENT_REFERENCES`.
      Since:
        4.2

  - ### Method Detail

    - #### getPositionalURI

          public static org.eclipse.emf.common.util.URI getPositionalURI​(org.eclipse.emf.ecore.InternalEObject internalEObject)

      Since:
        4.2

    - #### getGeneratedEPackage

          public static org.eclipse.emf.ecore.EPackage getGeneratedEPackage​(org.eclipse.emf.ecore.EPackage ePackage)

    - #### getSortedRegistryEntries

          public static java.util.Map.Entry<java.lang.String,​java.lang.Object>[] getSortedRegistryEntries​(org.eclipse.emf.ecore.EPackage.Registry packageRegistry)

    - #### getAnnotations

          public static org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EAnnotation> getAnnotations​(org.eclipse.emf.ecore.EClass eClass,
                                                                                                            java.lang.String sourceURI)

      Since:
        4.6

    - #### getTopLevelPackage

          public static org.eclipse.emf.ecore.EPackage getTopLevelPackage​(org.eclipse.emf.ecore.EPackage ePackage)

    - #### createEPackage

          public static org.eclipse.emf.ecore.EPackage createEPackage​(java.lang.String name,
                                                                      java.lang.String nsPrefix,
                                                                      java.lang.String nsURI)

      Since:
        2.0

    - #### createEClass

          public static org.eclipse.emf.ecore.EClass createEClass​(org.eclipse.emf.ecore.EPackage ePackage,
                                                                  java.lang.String name,
                                                                  boolean isAbstract,
                                                                  boolean isInterface)

      Since:
        2.0

    - #### createEAttribute

          public static org.eclipse.emf.ecore.EAttribute createEAttribute​(org.eclipse.emf.ecore.EClass eClass,
                                                                          java.lang.String name,
                                                                          org.eclipse.emf.ecore.EClassifier type)

      Since:
        2.0

    - #### createEReference

          public static org.eclipse.emf.ecore.EReference createEReference​(org.eclipse.emf.ecore.EClass eClass,
                                                                          java.lang.String name,
                                                                          org.eclipse.emf.ecore.EClassifier type,
                                                                          boolean isRequired,
                                                                          boolean isMany)

      Since:
        2.0

    - #### getConcreteClasses

          public static org.eclipse.emf.ecore.EClass[] getConcreteClasses​(org.eclipse.emf.ecore.EPackage ePackage)

      Since:
        4.2

    - #### getConcreteClasses

          public static org.eclipse.emf.ecore.EClass[] getConcreteClasses​(org.eclipse.emf.ecore.EPackage ePackage,
                                                                          boolean includeSubPackages)

      Since:
        4.10

    - #### forAllConcreteClasses

          public static void forAllConcreteClasses​(org.eclipse.emf.ecore.EPackage ePackage,
                                                   boolean includeSubPackages,
                                                   java.util.function.Consumer<org.eclipse.emf.ecore.EClass> consumer)

      Since:
        4.10

    - #### getAnyConcreteEClass

          public static org.eclipse.emf.ecore.EClass getAnyConcreteEClass​(org.eclipse.emf.ecore.EPackage ePackage,
                                                                          boolean includeSubPackages)

      Since:
        4.13

    - #### getPersistentClasses

          public static org.eclipse.emf.ecore.EClass[] getPersistentClasses​(org.eclipse.emf.ecore.EPackage ePackage)

    - #### getPersistentFeatures

          @Deprecated
          public static java.util.List<org.eclipse.emf.ecore.EStructuralFeature> getPersistentFeatures​(org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EStructuralFeature> eFeatures)

      Deprecated.
      This method is expensive and will be removed in the future.
      Since:
        3.0
      See Also:
        `isPersistent(EStructuralFeature)`

    - #### isPersistent

          public static boolean isPersistent​(org.eclipse.emf.ecore.EStructuralFeature feature)

      Returns `true` if CDO considers the given feature persistent, `false` otherwise.

      Note that CDO persistent is not identical to `non-transient` because that can be overridden with `CDO_ANNOTATION_KEY_PERSISTENT`. Another reason for possible deviations is that CDO considers transient `references` persistent if they have a persistent `opposite`.

      Note also that the checks for the aforementioned deviations from `EStructuralFeature.isTransient()` make this method somewhat expensive. Whenever possible `CDOClassInfo.isPersistent()` should be called instead.

      Since:
        3.0

    - #### isDynamicEPackage

          public static boolean isDynamicEPackage​(java.lang.Object value)

    - #### getParentURI

          public static java.lang.String getParentURI​(org.eclipse.emf.ecore.EPackage ePackage)

    - #### registerPackage

          public static void registerPackage​(org.eclipse.emf.ecore.EPackage ePackage,
                                             org.eclipse.emf.ecore.EPackage.Registry... packageRegistries)

    - #### getEPackageBytes

          public static byte[] getEPackageBytes​(org.eclipse.emf.ecore.EPackage ePackage,
                                                boolean zipped,
                                                org.eclipse.emf.ecore.EPackage.Registry packageRegistry)

    - #### createEPackage

          public static org.eclipse.emf.ecore.EPackage createEPackage​(java.lang.String uri,
                                                                      byte[] bytes,
                                                                      boolean zipped,
                                                                      org.eclipse.emf.ecore.resource.ResourceSet resourceSet,
                                                                      boolean lookForResource)

      Since:
        3.0

    - #### getAdapter

          public static <T> T getAdapter​(org.eclipse.emf.common.notify.Notifier notifier,
                                         java.lang.Class<T> type)

      Since:
        4.2

    - #### addAdapter

          public static void addAdapter​(org.eclipse.emf.common.notify.Notifier notifier,
                                        org.eclipse.emf.common.notify.Adapter adapter)

    - #### getAllPackages

          public static org.eclipse.emf.ecore.EPackage[] getAllPackages​(org.eclipse.emf.ecore.EPackage ePackage)

    - #### getQualifiedName

          public static java.lang.String getQualifiedName​(org.eclipse.emf.ecore.EPackage ePackage,
                                                          java.lang.String separator)

    - #### getQualifiedName

          public static java.lang.String getQualifiedName​(org.eclipse.emf.ecore.EClassifier classifier,
                                                          java.lang.String separator)

    - #### newResourceSet

          public static org.eclipse.emf.ecore.resource.ResourceSet newResourceSet​(org.eclipse.emf.ecore.resource.Resource.Factory resourceFactory)

    - #### newEcoreResourceSet

          public static org.eclipse.emf.ecore.resource.ResourceSet newEcoreResourceSet​(org.eclipse.emf.ecore.EPackage.Registry packageRegistry)

    - #### newEcoreResourceSet

          public static org.eclipse.emf.ecore.resource.ResourceSet newEcoreResourceSet()

    - #### safeResolve

          public static org.eclipse.emf.ecore.EObject safeResolve​(org.eclipse.emf.ecore.EObject proxy,
                                                                  org.eclipse.emf.ecore.resource.ResourceSet resourceSet)

      Since:
        3.0

    - #### safeResolveAll

          public static void safeResolveAll​(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)

      Since:
        3.0

    - #### createExtResourceSet

          public static EMFUtil.ExtResourceSet createExtResourceSet​(InternalCDOPackageRegistry packageRegistry,
                                                                    boolean delegating,
                                                                    boolean demandLoading)

      Since:
        4.0
      See Also:
        `EMFUtil.ExtResourceSet`