Class AspectModelLoader
java.lang.Object
org.eclipse.esmf.metamodel.loader.AspectModelLoader
Provides functionality to load an Aspect Model from a
VersionedModel and use the correct SAMM resources to
instantiate it. To load a regular Aspect Model, use getElements(VersionedModel) or
getElementsUnchecked(VersionedModel).
To load elements from an RDF model that might contain elements from multiple namespaces, use getNamespaces(VersionedModel).
Instances of VersionedModel are gained through an AspectModelResolver.
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.vavr.control.Try<AspectContext>getAspectContext(File input) Convenience method to create anAspectContextdirectly from a model file.getAspects(VersionedModel versionedModel) Convenience method that does the same asgetElements(VersionedModel)except it will return only the aspects contained in the model.getAspectsUnchecked(VersionedModel versionedModel) Does the same asgetAspects(VersionedModel)but throws an exception in case of failures.static io.vavr.control.Try<List<ModelElement>>getElements(VersionedModel versionedModel) Creates Java instances for model element classes from the RDF input modelstatic List<ModelElement>getElementsUnchecked(VersionedModel versionedModel) Does the same asgetElements(VersionedModel)but throws an exception in case of failures.static io.vavr.control.Try<List<ModelNamespace>>getNamespaces(VersionedModel versionedModel) Loads elements from an RDF model that possibly contains multiple namespaces, and organize the result into a collection ofModelNamespace.static io.vavr.control.Try<Aspect>getSingleAspect(VersionedModel versionedModel) Convenience method to load the single Aspect from a model, when the model contains exactly one Aspect.static io.vavr.control.Try<Aspect>getSingleAspect(VersionedModel versionedModel, Predicate<Aspect> selector) Similar togetSingleAspect(VersionedModel), except that a predicate can be provided to select which of potentially multiple aspects should be selectedstatic AspectgetSingleAspectUnchecked(VersionedModel versionedModel) Convenience method to load the single Aspect from a model, when the model contains exactly one Aspect.
-
Method Details
-
getNamespaces
public static io.vavr.control.Try<List<ModelNamespace>> getNamespaces(VersionedModel versionedModel) Loads elements from an RDF model that possibly contains multiple namespaces, and organize the result into a collection ofModelNamespace. Use this method only when you expect the RDF model to contain more than one namespace (which is not the case when aspect models contain the usual element definitions with one namespace per file), otherwise usegetElements(VersionedModel).- Parameters:
versionedModel- The RDF model representation of the Aspect model- Returns:
- the list of namespaces
-
getElements
Creates Java instances for model element classes from the RDF input model- Parameters:
versionedModel- The RDF model representation of the Aspect model- Returns:
- the list of loaded model elements on success
-
getElementsUnchecked
Does the same asgetElements(VersionedModel)but throws an exception in case of failures.- Parameters:
versionedModel- The RDF model representation of the Aspect model- Returns:
- the list of model elements
- Throws:
AspectLoadingException- when elements can not be loaded
-
getAspects
Convenience method that does the same asgetElements(VersionedModel)except it will return only the aspects contained in the model.- Parameters:
versionedModel- The RDF model representation of the Aspect model- Returns:
- the list of model aspects
-
getAspectsUnchecked
Does the same asgetAspects(VersionedModel)but throws an exception in case of failures.- Parameters:
versionedModel- The RDF model representation of the Aspect model- Returns:
- the list of model aspects
- Throws:
AspectLoadingException- when elements can not be loaded
-
getSingleAspect
Convenience method to load the single Aspect from a model, when the model contains exactly one Aspect. Caution: The method handles this special case. Aspect Models are allowed to contain any number of Aspects (including zero), so for the general case you should usegetElements(VersionedModel)instead.- Parameters:
versionedModel- The RDF model representation of the Aspect model- Returns:
- the single Aspect contained in the model
-
getSingleAspectUnchecked
Convenience method to load the single Aspect from a model, when the model contains exactly one Aspect. Does the same asgetSingleAspect(VersionedModel)but throws an exception on failure. Caution: The method handles this special case. Aspect Models are allowed to contain any number of Aspects (including zero), so for the general case you should usegetElementsUnchecked(VersionedModel)instead.- Parameters:
versionedModel- The RDF model representation of the Aspect model- Returns:
- the single Aspect contained in the model
-
getSingleAspect
public static io.vavr.control.Try<Aspect> getSingleAspect(VersionedModel versionedModel, Predicate<Aspect> selector) Similar togetSingleAspect(VersionedModel), except that a predicate can be provided to select which of potentially multiple aspects should be selected- Parameters:
versionedModel- the RDF model reprensentation of the Aspect modelselector- the predicate to select an Aspect- Returns:
- the selected Aspect, or a failure if 0 or more than 1 matching Aspects were found
-
getAspectContext
Convenience method to create anAspectContextdirectly from a model file. This method makes the following assumptions:- The model file is located in a directory structure as required by the
FileSystemStrategy - The closure of the loaded model contains exactly one Aspect
- The Aspect has the same name as the file's basename
- Parameters:
input- the model file- Returns:
- the loaded Aspect Context
- The model file is located in a directory structure as required by the
-