Class EMFUtil

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

public final class EMFUtil extends Object
Various static helper methods for dealing with EMF meta models.
Since:
2.0
Author:
Eike Stepper
  • Field Details

  • Method Details

    • getNearestObject

      public static <T extends EObject> T getNearestObject(EObject object, Class<T> type)
      Since:
      4.26
    • getPositionalURI

      public static URI getPositionalURI(InternalEObject internalEObject)
      Since:
      4.2
    • getGeneratedEPackage

      public static EPackage getGeneratedEPackage(EPackage ePackage)
    • getSortedRegistryEntries

      public static Map.Entry<String,Object>[] getSortedRegistryEntries(EPackage.Registry packageRegistry)
    • getAnnotations

      public static EList<EAnnotation> getAnnotations(EClass eClass, String sourceURI)
      Since:
      4.6
    • getTopLevelPackage

      public static EPackage getTopLevelPackage(EPackage ePackage)
    • createEPackage

      public static EPackage createEPackage(String name, String nsPrefix, String nsURI)
      Since:
      2.0
    • createEClass

      public static EClass createEClass(EPackage ePackage, String name)
      Since:
      4.27
    • createEClass

      public static EClass createEClass(EPackage ePackage, String name, boolean isAbstract, boolean isInterface)
      Since:
      2.0
    • createEAttribute

      public static EAttribute createEAttribute(EClass eClass, String name, EClassifier type)
      Since:
      2.0
    • createEReference

      public static EReference createEReference(EClass eClass, String name, EClassifier type)
      Since:
      4.27
    • createEReference

      public static EReference createEReference(EClass eClass, String name, EClassifier type, boolean isRequired, boolean isMany)
      Since:
      2.0
    • createEEnum

      public static EEnum createEEnum(EPackage ePackage, String name)
      Since:
      4.27
    • createEEnum

      public static EEnum createEEnum(EPackage ePackage, String name, String... literals)
      Since:
      4.27
    • createEEnumLiteral

      public static EEnumLiteral createEEnumLiteral(EEnum eEnum, String name)
      Since:
      4.27
    • createEEnumLiteral

      public static EEnumLiteral createEEnumLiteral(EEnum eEnum, String name, int value)
      Since:
      4.27
    • getConcreteClasses

      public static EClass[] getConcreteClasses(EPackage ePackage)
      Since:
      4.2
    • getConcreteClasses

      public static EClass[] getConcreteClasses(EPackage ePackage, boolean includeSubPackages)
      Since:
      4.10
    • forAllConcreteClasses

      public static void forAllConcreteClasses(EPackage ePackage, boolean includeSubPackages, Consumer<EClass> consumer)
      Since:
      4.10
    • getAnyConcreteEClass

      public static EClass getAnyConcreteEClass(EPackage ePackage, boolean includeSubPackages)
      Since:
      4.13
    • getPersistentClasses

      public static EClass[] getPersistentClasses(EPackage ePackage)
    • getPersistentFeatures

      @Deprecated public static List<EStructuralFeature> getPersistentFeatures(EList<EStructuralFeature> eFeatures)
      Deprecated.
      This method is expensive and will be removed in the future.
      Since:
      3.0
      See Also:
    • 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
    • getCollectionLoadingChunkConfig

      public static CDOCollectionLoadingConfig.ChunkConfig getCollectionLoadingChunkConfig(EModelElement modelElement)
      Returns the explicitly configured collection-loading dimensions of an EMF model element.

      Invalid details are ignored independently and logged as warnings. A null result means that the element does not contain a valid explicitly configured dimension.

      Parameters:
      modelElement - the model element to inspect
      Returns:
      the explicit chunk configuration, or null
      Since:
      4.29
    • isDynamicEPackage

      public static boolean isDynamicEPackage(Object value)
    • getParentURI

      public static 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(String uri, byte[] bytes, ResourceSet resourceSet, boolean lookForResource)
      Creates an EPackage from the given byte array by loading it into a resource in the given resource set.

      If lookForResource is true, then an attempt is made to find an existing resource with the given URI before creating a new one.

      The method automatically detects whether the byte array is zipped.

      Note that the byte array is not copied, so it must not be modified while the resource is in use.

      Since:
      4.27
      See Also:
    • createEPackage

      public static EPackage createEPackage(String uri, byte[] bytes, boolean zipped, ResourceSet resourceSet, boolean lookForResource)
      Creates an EPackage from the given byte array by loading it into a resource in the given resource set.

      If lookForResource is true, then an attempt is made to find an existing resource with the given URI before creating a new one.

      If the byte array is zipped, then set zipped to true.

      Note that the byte array is not copied, so it must not be modified while the resource is in use.

      Since:
      3.0
      See Also:
    • getXMI

      public static String getXMI(EPackage ePackage)
      Since:
      4.27
    • getAdapter

      public static <T> T getAdapter(Notifier notifier, Class<T> type)
      Since:
      4.2
    • addAdapter

      public static void addAdapter(Notifier notifier, Adapter adapter)
    • getAllPackages

      public static EPackage[] getAllPackages(EPackage ePackage)
    • getAllPackages

      public static void getAllPackages(EPackage ePackage, Consumer<EPackage> consumer)
      Since:
      4.27
    • getQualifiedName

      public static String getQualifiedName(EPackage ePackage, String separator)
    • getQualifiedName

      public static String getQualifiedName(EClassifier classifier, String separator)
    • getQualifiedName

      public static String getQualifiedName(EStructuralFeature feature, String separator)
      Since:
      4.27
    • getFullyQualifiedName

      public static String getFullyQualifiedName(EObject modelElement)
      Since:
      4.27
    • getFullyQualifiedName

      public static String getFullyQualifiedName(EObject modelElement, String separator)
      Since:
      4.27
    • 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: