Class AvailableModels<M extends IModel>
- java.lang.Object
-
- net.ssehub.easy.basics.modelManagement.AvailableModels<M>
-
- Type Parameters:
M- the specific type of model
public class AvailableModels<M extends IModel> extends java.lang.ObjectStores information about available models, i.e., the relation between model names and all available model information objects. This class provides several methods to query model information objects.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.util.List<VersionedModelInfos<M>>>availableModelsprivate java.util.Map<java.net.URI,ModelInfo<M>>tmpInfo
-
Constructor Summary
Constructors Constructor Description AvailableModels(IModelManagementRepository<M> repository)Creates an instance of this class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidclear()Clears all loaded model infos.ModelInfo<M>createTempInfo(M model, java.net.URI location)Creates a temporary resolved model information without model loader.(package private) java.util.List<VersionedModelInfos<M>>getAvailable(java.lang.String name)Returns models available for a given modelname.ModelInfo<M>getInfo(java.net.URI uri)Returns the (visible) information object aturi.MgetModel(java.lang.String name, java.lang.String version, java.net.URI uri)Returns a known model object via its URI.MgetModel(java.lang.String name, Version version, java.net.URI uri)Returns a known model object via its URI.java.util.List<ModelInfo<M>>getModelInfo(java.lang.String name)Returns all known model information objects for the specified model.java.util.List<ModelInfo<M>>getModelInfo(java.lang.String name, java.lang.String version)Returns the model information object for the specified model.ModelInfo<M>getModelInfo(java.lang.String name, java.lang.String version, java.net.URI uri)Returns a known model information object via its URI.java.util.List<ModelInfo<M>>getModelInfo(java.lang.String name, Version version)Returns the model information objects for the specified model.ModelInfo<M>getModelInfo(java.lang.String name, Version version, java.net.URI uri)Returns a known model information object via its URI.ModelInfo<M>getModelInfo(M model)Returns the model information object for the specified model.ModelInfo<M>getModelInfo(ModelInfo<M> info)Returns the matching available model information instance.intgetModelInfoCount(boolean differURIs)Returns the number of different model information objects known in this class.java.util.List<ModelInfo<M>>getModelInfos(M model)Returns the model information objects for the specified model.(package private) java.util.List<ModelInfo<M>>getModelInfoWith(java.net.URI uri)Returns the available model information objects which are located aturi.ModelInfo<M>getResolvedModelInfo(M model)Returns the model information object for the given model by considering resolved models.ModelInfo<M>getResolvedModelInfo(M model, java.net.URI uri)Returns the model information object formodelwhile consideringurias location ofmodel.java.util.List<ModelInfo<M>>getVisibleModelInfo(java.lang.String name, java.net.URI uri)Returns the available model information objects which are available for and visible from the given URI, i.e.java.util.List<ModelInfo<M>>getVisibleModelInfo(java.lang.String name, Version version, java.net.URI uri)Returns the available model information objects which are available for and visible from the given URI, i.e.java.util.List<ModelInfo<M>>getVisibleModelInfo(java.net.URI uri)Returns the available model information objects which are available for and visible from the given URI, i.e.booleanhasModelInfo(java.lang.String name)Returns whether there are known model information objects for the specified model.booleanisTempInfo(ModelInfo<M> info)Returns whetherinfois a temporary model.(package private) java.util.Set<java.lang.String>modelNames()Returns the known model names.(package private) voidputAvailable(java.lang.String name, java.util.List<VersionedModelInfos<M>> infos)Puts available model information objects for a given model name.voidreleaseTempInfo(ModelInfo<M> info)Releases a temporary model information object.(package private) voidremoveAvailable(java.lang.String name)Removes a model information object for a given model name.(package private) voidremoveAvailable(ModelInfo<M> info)Removes a model information object for a given information object.(package private) booleanupdateAvailableModel(ModelInfo<M> info)Updates the list of available models.(package private) java.util.Collection<java.util.List<VersionedModelInfos<M>>>versionedModelInfos()Returns all versioned model information objects.
-
-
-
Constructor Detail
-
AvailableModels
AvailableModels(IModelManagementRepository<M> repository)
Creates an instance of this class.- Parameters:
repository- the underlying repository instance
-
-
Method Detail
-
clear
void clear()
Clears all loaded model infos.
-
versionedModelInfos
java.util.Collection<java.util.List<VersionedModelInfos<M>>> versionedModelInfos()
Returns all versioned model information objects.- Returns:
- all known versioned model information objects
-
modelNames
java.util.Set<java.lang.String> modelNames()
Returns the known model names.- Returns:
- the model names
-
updateAvailableModel
boolean updateAvailableModel(ModelInfo<M> info)
Updates the list of available models.- Parameters:
info- the model information to be added/updated- Returns:
truein case of inconsistencies,false
-
getModelInfoCount
public int getModelInfoCount(boolean differURIs)
Returns the number of different model information objects known in this class.- Parameters:
differURIs- if the result should count different URIs or just different versions- Returns:
- the number of different model information objects
-
getInfo
public ModelInfo<M> getInfo(java.net.URI uri)
Returns the (visible) information object aturi.- Parameters:
uri- the URI to look for- Returns:
- the found information object or null if not found
-
getVisibleModelInfo
public java.util.List<ModelInfo<M>> getVisibleModelInfo(java.net.URI uri)
Returns the available model information objects which are available for and visible from the given URI, i.e. either same path, containing or contained path.- Parameters:
uri- the URI to match- Returns:
- the available information objects matching
uri
-
getVisibleModelInfo
public java.util.List<ModelInfo<M>> getVisibleModelInfo(java.lang.String name, Version version, java.net.URI uri)
Returns the available model information objects which are available for and visible from the given URI, i.e. either same path, containing or contained path.- Parameters:
name- the name of the model (may be null but thenversionis ignored and all visible model information objects are returned as done ingetVisibleModelInfo(URI)).version- the version of the model (may be null)uri- the URI to match- Returns:
- the available information objects matching
uri
-
getVisibleModelInfo
public java.util.List<ModelInfo<M>> getVisibleModelInfo(java.lang.String name, java.net.URI uri)
Returns the available model information objects which are available for and visible from the given URI, i.e. either same path, containing or contained path.- Parameters:
name- the name of the model (may be null but thenversionis ignored and all visible model information objects are returned as done ingetVisibleModelInfo(URI)).uri- the URI to match- Returns:
- the available information objects matching
uri
-
getModelInfoWith
java.util.List<ModelInfo<M>> getModelInfoWith(java.net.URI uri)
Returns the available model information objects which are located aturi.- Parameters:
uri- the URI to match- Returns:
- the available information objects matching
uri
-
getResolvedModelInfo
public ModelInfo<M> getResolvedModelInfo(M model, java.net.URI uri)
Returns the model information object formodelwhile consideringurias location ofmodel. This method emulates an import.- Parameters:
model- the model to search the info foruri- the URI to consider as starting point- Returns:
- the model information object or null if there is none
-
getResolvedModelInfo
public ModelInfo<M> getResolvedModelInfo(M model)
Returns the model information object for the given model by considering resolved models.- Parameters:
model- the model to search an information object for which resolvesmodel- Returns:
- the related model information object or null if there is none
-
getModelInfo
public ModelInfo<M> getModelInfo(java.lang.String name, Version version, java.net.URI uri)
Returns a known model information object via its URI.- Parameters:
name- the name of the model to search forversion- the version of the model to search foruri- the URI to search for- Returns:
- the related model information object (or null if not found)
-
getModelInfo
public java.util.List<ModelInfo<M>> getModelInfo(java.lang.String name, Version version)
Returns the model information objects for the specified model.- Parameters:
name- the name of the model to search forversion- the version of the model to search for- Returns:
- the model information objects (may have different URLs) or null if unknown
-
getModelInfos
public java.util.List<ModelInfo<M>> getModelInfos(M model)
Returns the model information objects for the specified model. However, unless the information objects are not directly tested for a reference tomodel, all those with matching name / version will be returned.- Parameters:
model- the model to search for- Returns:
- the model information objects (may have different URLs) or null if unknown
-
getModelInfo
public ModelInfo<M> getModelInfo(M model)
Returns the model information object for the specified model.- Parameters:
model- the model to search for- Returns:
- the model information pointing to
model, null if unknown
-
getModelInfo
public java.util.List<ModelInfo<M>> getModelInfo(java.lang.String name, java.lang.String version) throws VersionFormatException
Returns the model information object for the specified model.- Parameters:
name- the name of the model to search forversion- the version of the model to search for- Returns:
- the model information objects (may have different URLs) or null if unknown
- Throws:
VersionFormatException- in case of an erroneous version string
-
hasModelInfo
public boolean hasModelInfo(java.lang.String name)
Returns whether there are known model information objects for the specified model.- Parameters:
name- the name of the model- Returns:
trueif model information is known (at least on model but multiple in different versions may exist),falseelse
-
getModelInfo
public java.util.List<ModelInfo<M>> getModelInfo(java.lang.String name)
Returns all known model information objects for the specified model.- Parameters:
name- the name of the model- Returns:
- the available information objects (may be unmodifiable) or null
-
getModelInfo
public ModelInfo<M> getModelInfo(ModelInfo<M> info)
Returns the matching available model information instance. This method does not consider the loader. This method is helpful when a model information object is created twice and shall be internalized with respect to the available model information objects.- Parameters:
info- the information object to be internalized- Returns:
- the matching object or null if unknown
-
getModel
public M getModel(java.lang.String name, java.lang.String version, java.net.URI uri) throws VersionFormatException
Returns a known model object via its URI.- Parameters:
name- the name of the model to search forversion- the version of the model to search foruri- the URI to search for- Returns:
- the related model object (or null if not found or not yet resolved)
- Throws:
VersionFormatException- in case thatversionis in wrong format (seeVersion
-
getModel
public M getModel(java.lang.String name, Version version, java.net.URI uri) throws VersionFormatException
Returns a known model object via its URI.- Parameters:
name- the name of the model to search forversion- the version of the model to search foruri- the URI to search for- Returns:
- the related model object (or null if not found or not yet resolved)
- Throws:
VersionFormatException- in case thatversionis in wrong format (seeVersion
-
getModelInfo
public ModelInfo<M> getModelInfo(java.lang.String name, java.lang.String version, java.net.URI uri) throws VersionFormatException
Returns a known model information object via its URI.- Parameters:
name- the name of the model to search forversion- the version of the model to search foruri- the URI to search for- Returns:
- the related model information object (or null if not found)
- Throws:
VersionFormatException- in case thatversionis in wrong format (seeVersion
-
getAvailable
java.util.List<VersionedModelInfos<M>> getAvailable(java.lang.String name)
Returns models available for a given modelname.- Parameters:
name- the name to search for- Returns:
- the available models or null
-
putAvailable
void putAvailable(java.lang.String name, java.util.List<VersionedModelInfos<M>> infos)Puts available model information objects for a given model name.- Parameters:
name- the name of the modelinfos- the associated model information objects
-
removeAvailable
void removeAvailable(java.lang.String name)
Removes a model information object for a given model name.- Parameters:
name- the name of the model
-
removeAvailable
void removeAvailable(ModelInfo<M> info)
Removes a model information object for a given information object.- Parameters:
info- the information object
-
createTempInfo
public ModelInfo<M> createTempInfo(M model, java.net.URI location)
Creates a temporary resolved model information without model loader. Do not use the result for regular models! CallreleaseTempInfo(ModelInfo)if the model is not used anymore. Affects onlygetInfo(URI).- Parameters:
model- the modellocation- the location- Returns:
- the model information
-
releaseTempInfo
public void releaseTempInfo(ModelInfo<M> info)
Releases a temporary model information object.- Parameters:
info- the information object to release (may be null, ignored)
-
-