Class EObjectLoader

    • Field Detail

      • LATE_PROXY_RESOLUTION_URI_PREFIX

        public static final String LATE_PROXY_RESOLUTION_URI_PREFIX
        If proxy URI is prefixed with ./ then the URI is not resolved relative to the context resource at the load time. Rather the prefix is removed and a URI created from the tail is passed to the proxy object to be used at proxy resolution time.
        See Also:
        Constant Field Values
      • LOAD_KEY

        public static final String LOAD_KEY
        Use this annotation to customize load keys. Use feature-key annotation for features to also customize containment path calculation.
        See Also:
        Constant Field Values
      • LOAD_DOC

        public static final String LOAD_DOC
        Information about how element is loaded in markdown. For EStructuralFeatures overrides feature documentation if present.
        See Also:
        Constant Field Values
      • LOAD_DOC_REF

        public static final String LOAD_DOC_REF
        Reference to a resource with information about how element is loaded in markdown. For EStructuralFeatures overrides feature documentation if present.
        See Also:
        Constant Field Values
      • IS_DEFAULT_FEATURE

        public static final String IS_DEFAULT_FEATURE
        If this Nasdanika annotation details is set to "true" on a EStructuralFeature and configuration object is not a map then the configuration object is loaded into this feature.
        See Also:
        Constant Field Values
      • VALUE_FEATURE

        public static final String VALUE_FEATURE
        EReference annotation with a name of value feature as a value. Value feature is loaded with the configuration map value for reference with eKeys. If this annotation is not set then the object itself is loaded with the value.
        See Also:
        Constant Field Values
      • IS_RESOLVE_URI

        public static final String IS_RESOLVE_URI
        If this Nasdanika annotation details is set to "true" on a EAttribute and configuration object is a String then the configuration object is resolved relative to the model resource URI (base).
        See Also:
        Constant Field Values
      • REFERENCE_TYPES

        public static final String REFERENCE_TYPES
        This annotation allows to override element types for homogenous references. The value shall be a YAML map of reference names to types. If entry value is a string it is treated as a class name from the same EPackage as the annotated EClass. If it is a map then it shall contain ns-uri and name keys. EClass is looked up in the loader's ResourceSet package registry.
        See Also:
        Constant Field Values
      • REFERENCE_TYPE

        public static final String REFERENCE_TYPE
        This annotation allows to customize element types for homogenous references based on configuration element type The value shall be a YAML map of configuration types (string, map, list, number, boolean) to reference types. If entry value is a string it is treated as a class name from the same EPackage as the annotated EReference's EClass. If it is a map then it shall contain ns-uri and name keys. EClass is looked up in the loader's ResourceSet package registry.
        See Also:
        Constant Field Values
      • LOAD_KEYS

        public static final String LOAD_KEYS
        This annotation allows to load keys for features. The value shall be a YAML map of feature names to keys. If entry value is a string it is treated as a key name.
        See Also:
        Constant Field Values
      • IS_COMPUTED

        public static final String IS_COMPUTED
        If true, feature is loaded even if it not changeable, but it is not injected into the object. In this case the getter can access loaded value using LoadTracker adapter get() method.
        See Also:
        Constant Field Values
      • IS_LOADABLE

        public static final String IS_LOADABLE
        If this Nasdanika annotation details is set to "false" on a EStructuralFeature or EClass then this feature or class is not loaded from configuration.
        See Also:
        Constant Field Values
      • IS_HOMOGENOUS

        public static final String IS_HOMOGENOUS
        If this Nasdanika annotation details is set to "true" on a EReference with a concrete element type then reference element(s) are loaded using the reference type and they shall be a maps of features as opposed of a map of type to a map of features.
        See Also:
        Constant Field Values
      • IS_STRICT_CONTAINMENT

        public static final String IS_STRICT_CONTAINMENT
        If this Nasdanika annotation details is set to "true" on a homogenous EReference then string values are treated as default features, not as object references.
        See Also:
        Constant Field Values
      • LOAD_KEY_PROVIDER

        public static final BiFunction<org.eclipse.emf.ecore.EClass,​org.eclipse.emf.ecore.ENamedElement,​String> LOAD_KEY_PROVIDER
        Default implementation of load key provider - gets load key from the Nasdanika annotation (urn:org.nasdanika) load-key details if it is present. For features delegates to NcoreUtil getFeatureKey. Otherwise converts ENamedElement element name from camel case to lower-cased kebab case. E.g. firstName is converted first-name.
    • Constructor Detail

      • EObjectLoader

        public EObjectLoader​(ObjectLoader chain,
                             BiFunction<org.eclipse.emf.ecore.EClass,​org.eclipse.emf.ecore.ENamedElement,​String> keyProvider,
                             org.eclipse.emf.ecore.EPackage... ePackages)
      • EObjectLoader

        public EObjectLoader​(org.eclipse.emf.ecore.EPackage... ePackages)
      • EObjectLoader

        public EObjectLoader​(ObjectLoader chain,
                             BiFunction<org.eclipse.emf.ecore.EClass,​org.eclipse.emf.ecore.ENamedElement,​String> keyProvider,
                             org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
      • EObjectLoader

        public EObjectLoader​(org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
    • Method Detail

      • setThreadConstructor

        public void setThreadConstructor​(Function<org.eclipse.emf.ecore.EClass,​org.eclipse.emf.ecore.EObject> constructor)
        Sets thread constructor for creation of
        Parameters:
        constructor -
      • getExclusiveWith

        public static Object[] getExclusiveWith​(org.eclipse.emf.ecore.EClass eClass,
                                                org.eclipse.emf.ecore.EStructuralFeature feature,
                                                BiFunction<org.eclipse.emf.ecore.EClass,​org.eclipse.emf.ecore.ENamedElement,​String> keyProvider)
        Parameters:
        eClass -
        feature -
        Returns:
        Features in the argument class the argument feature is exclusive with.
      • isDefaultFeature

        public static boolean isDefaultFeature​(org.eclipse.emf.ecore.EClass eClass,
                                               org.eclipse.emf.ecore.EStructuralFeature feature)
      • getValueFeature

        public static String getValueFeature​(org.eclipse.emf.ecore.EReference eReference)
      • register

        public void register​(org.eclipse.emf.ecore.EPackage ePackage,
                             BiFunction<org.eclipse.emf.ecore.EClass,​org.eclipse.emf.ecore.ENamedElement,​String> keyProvider)
      • register

        public void register​(org.eclipse.emf.ecore.EPackage ePackage)
      • create

        public Object create​(ObjectLoader loader,
                             String type,
                             Object config,
                             Function<org.eclipse.emf.ecore.EClass,​org.eclipse.emf.ecore.EObject> constructor,
                             org.eclipse.emf.common.util.URI base,
                             ProgressMonitor progressMonitor,
                             List<? extends Marker> markers)
        Creates a new EObject from a prototype.
        Parameters:
        loader -
        type -
        config -
        prototype - Prototype EObject, can be null.
        base -
        progressMonitor -
        marker -
        Returns:
      • resolveEClass

        public BiSupplier<org.eclipse.emf.ecore.EClass,​BiFunction<org.eclipse.emf.ecore.EClass,​org.eclipse.emf.ecore.ENamedElement,​String>> resolveEClass​(String type)
        Resolves EClass and key provider from type name.
        Parameters:
        type -
        Returns:
      • create

        public Object create​(ObjectLoader loader,
                             org.eclipse.emf.ecore.EClass eClass,
                             Object config,
                             org.eclipse.emf.common.util.URI base,
                             ProgressMonitor progressMonitor,
                             List<? extends Marker> markers,
                             BiFunction<org.eclipse.emf.ecore.EClass,​org.eclipse.emf.ecore.ENamedElement,​String> keyProvider,
                             Function<org.eclipse.emf.ecore.EClass,​org.eclipse.emf.ecore.EObject> constructor)
        Creates an instance of EClass or a supplier factory
        Parameters:
        loader -
        eClass -
        config -
        base -
        progressMonitor -
        marker -
        ePackageEntry -
        eClassifier -
        Returns:
      • createProxy

        public org.eclipse.emf.ecore.EObject createProxy​(org.eclipse.emf.ecore.EClass eClass,
                                                         Object config,
                                                         org.eclipse.emf.common.util.URI base,
                                                         List<? extends Marker> markers,
                                                         ProgressMonitor progressMonitor)
        Creates a proxy object if config is a singleton map with "href" key.
        Parameters:
        eClass -
        config -
        base -
        Returns:
        Proxy object or null if config is not a proxy config.
      • mark

        public void mark​(org.eclipse.emf.ecore.EObject eObject,
                         List<? extends Marker> markers,
                         ProgressMonitor progressMonitor)
        If marker is not null adds marked adapter. If eObject is instance of Marked creates and sets Marker.
        Parameters:
        eObject -
        marker -
      • resolve

        public org.eclipse.emf.ecore.EObject resolve​(org.eclipse.emf.ecore.EObject proxy)
        Resolves proxy using the loader's resource set. Does not suppress exceptions.
      • getResourceSet

        public org.eclipse.emf.ecore.resource.ResourceSet getResourceSet()
      • getLoadKey

        public static String getLoadKey​(org.eclipse.emf.ecore.EClass eClass,
                                        org.eclipse.emf.ecore.EStructuralFeature feature)
        Returns:
        Load key from load-keys annotation.