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 and 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 and Description
    --- | ---
    `static Predicate<EStructuralFeature>` | `ATTRIBUTES`
    `static java.lang.String` | `CDO_ANNOTATION_KEY_PERSISTENT`
    `static java.lang.String` | `CDO_ANNOTATION_SOURCE`
    `static Predicate<EStructuralFeature>` | `CONTAINER_REFERENCES`
    `static Predicate<EStructuralFeature>` | `CONTAINMENT_REFERENCES`
    `static Predicate<EStructuralFeature>` | `CROSS_REFERENCES`
    `static EReference` | `ECLASS_EGENERIC_SUPER_TYPES`
    `static EReference` | `ECLASS_ESUPER_TYPES`
    `static EAttribute` | `ECLASSIFIER_INSTANCE_CLASS_NAME`
    `static EAttribute` | `ECLASSIFIER_INSTANCE_TYPE_NAME`
    `static EReference` | `EOPERATION_EEXCEPTIONS`
    `static EReference` | `EOPERATION_EGENERIC_EXCEPTIONS`
    `static EReference` | `ETYPED_ELEMENT_EGENERIC_TYPE`
    `static EReference` | `ETYPED_ELEMENT_ETYPE`
    `static Predicate<EStructuralFeature>` | `REFERENCES`

  - ### Method Summary

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

      Since:
        4.2

    - #### ETYPED_ELEMENT_ETYPE

          public static final EReference ETYPED_ELEMENT_ETYPE

      Since:
        4.2

    - #### ECLASS_ESUPER_TYPES

          public static final EReference ECLASS_ESUPER_TYPES

      Since:
        4.2

    - #### ECLASSIFIER_INSTANCE_CLASS_NAME

          public static final EAttribute ECLASSIFIER_INSTANCE_CLASS_NAME

      Since:
        4.2

    - #### EOPERATION_EGENERIC_EXCEPTIONS

          public static final EReference EOPERATION_EGENERIC_EXCEPTIONS

      Since:
        4.2

    - #### ETYPED_ELEMENT_EGENERIC_TYPE

          public static final EReference ETYPED_ELEMENT_EGENERIC_TYPE

      Since:
        4.2

    - #### ECLASS_EGENERIC_SUPER_TYPES

          public static final EReference ECLASS_EGENERIC_SUPER_TYPES

      Since:
        4.2

    - #### ECLASSIFIER_INSTANCE_TYPE_NAME

          public static final EAttribute ECLASSIFIER_INSTANCE_TYPE_NAME

      Since:
        4.2

    - #### ATTRIBUTES

          public static final Predicate<EStructuralFeature> ATTRIBUTES

      Since:
        4.2

    - #### REFERENCES

          public static final Predicate<EStructuralFeature> REFERENCES

      Since:
        4.2

    - #### CONTAINER_REFERENCES

          public static final Predicate<EStructuralFeature> CONTAINER_REFERENCES

      Since:
        4.2

    - #### CROSS_REFERENCES

          public static final Predicate<EStructuralFeature> CROSS_REFERENCES

      Since:
        4.2

    - #### CONTAINMENT_REFERENCES

          public static final Predicate<EStructuralFeature> CONTAINMENT_REFERENCES

      Since:
        4.2

  - ### Method Detail

    - #### getPositionalURI

          public static URI getPositionalURI(InternalEObject internalEObject)

      Since:
        4.2

    - #### getGeneratedEPackage

          public static EPackage getGeneratedEPackage(EPackage ePackage)

    - #### getSortedRegistryEntries

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

    - #### getAnnotations

          public static EList<EAnnotation> getAnnotations(EClass eClass,
                                                          java.lang.String sourceURI)

      Since:
        4.6

    - #### getTopLevelPackage

          public static EPackage getTopLevelPackage(EPackage ePackage)

    - #### createEPackage

          public static EPackage createEPackage(java.lang.String name,
                                                java.lang.String nsPrefix,
                                                java.lang.String nsURI)

      Since:
        2.0

    - #### createEClass

          public static EClass createEClass(EPackage ePackage,
                                            java.lang.String name,
                                            boolean isAbstract,
                                            boolean isInterface)

      Since:
        2.0

    - #### createEAttribute

          public static EAttribute createEAttribute(EClass eClass,
                                                    java.lang.String name,
                                                    EClassifier type)

      Since:
        2.0

    - #### createEReference

          public static EReference createEReference(EClass eClass,
                                                    java.lang.String name,
                                                    EClassifier type,
                                                    boolean isRequired,
                                                    boolean isMany)

      Since:
        2.0

    - #### getConcreteClasses

          public static EClass[] getConcreteClasses(EPackage ePackage)

      Since:
        4.2

    - #### getPersistentClasses

          public static EClass[] getPersistentClasses(EPackage ePackage)

    - #### getPersistentFeatures

          @Deprecated
          public static java.util.List<EStructuralFeature> getPersistentFeatures(EList<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(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(EPackage ePackage)

    - #### registerPackage

          public static void registerPackage(EPackage ePackage,
                                             EPackage.Registry... packageRegistries)

    - #### getEPackageBytes

          public static byte[] getEPackageBytes(EPackage ePackage,
                                                boolean zipped,
                                                EPackage.Registry packageRegistry)

    - #### createEPackage

          public static EPackage createEPackage(java.lang.String uri,
                                                byte[] bytes,
                                                boolean zipped,
                                                ResourceSet resourceSet,
                                                boolean lookForResource)

      Since:
        3.0

    - #### getAdapter

          public static <T> T getAdapter(Notifier notifier,
                                         java.lang.Class<T> type)

      Since:
        4.2

    - #### addAdapter

          public static void addAdapter(Notifier notifier,
                                        Adapter adapter)

    - #### getAllPackages

          public static EPackage[] getAllPackages(EPackage ePackage)

    - #### getQualifiedName

          public static java.lang.String getQualifiedName(EPackage ePackage,
                                                          java.lang.String separator)

    - #### getQualifiedName

          public static java.lang.String getQualifiedName(EClassifier classifier,
                                                          java.lang.String separator)

    - #### newResourceSet

          public static ResourceSet newResourceSet(Resource.Factory resourceFactory)

    - #### newEcoreResourceSet

          public static ResourceSet newEcoreResourceSet(EPackage.Registry packageRegistry)

    - #### newEcoreResourceSet

          public static ResourceSet newEcoreResourceSet()

    - #### safeResolve

          public static EObject safeResolve(EObject proxy,
                                            ResourceSet resourceSet)

      Since:
        3.0

    - #### safeResolveAll

          public static void safeResolveAll(ResourceSet resourceSet)

      Since:
        3.0

    - #### createExtResourceSet

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

      Since:
        4.0
      See Also:
        `EMFUtil.ExtResourceSet`

Copyright (c) 2004-2019 Eike Stepper (Loehne, Germany) and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html