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 Object
Stores 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 Details

  • Constructor Details

    • AvailableModels

      AvailableModels(IModelManagementRepository<M> repository)
      Creates an instance of this class.
      Parameters:
      repository - the underlying repository instance
  • Method Details

    • clear

      void clear()
      Clears all loaded model infos.
    • versionedModelInfos

      public Collection<List<VersionedModelInfos<M>>> versionedModelInfos()
      Returns all versioned model information objects.
      Returns:
      all known versioned model information objects
    • modelNames

      public Set<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:
      true in 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(URI uri)
      Returns the (visible) information object at uri.
      Parameters:
      uri - the URI to look for
      Returns:
      the found information object or null if not found
    • getVisibleModelInfo

      public List<ModelInfo<M>> getVisibleModelInfo(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 List<ModelInfo<M>> getVisibleModelInfo(String name, Version version, 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 then version is ignored and all visible model information objects are returned as done in getVisibleModelInfo(URI)).
      version - the version of the model (may be null)
      uri - the URI to match
      Returns:
      the available information objects matching uri
    • getVisibleModelInfo

      public List<ModelInfo<M>> getVisibleModelInfo(String name, 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 then version is ignored and all visible model information objects are returned as done in getVisibleModelInfo(URI)).
      uri - the URI to match
      Returns:
      the available information objects matching uri
    • getModelInfoWith

      List<ModelInfo<M>> getModelInfoWith(URI uri)
      Returns the available model information objects which are located at uri.
      Parameters:
      uri - the URI to match
      Returns:
      the available information objects matching uri
    • getResolvedModelInfo

      public ModelInfo<M> getResolvedModelInfo(M model, URI uri)
      Returns the model information object for model while considering uri as location of model. This method emulates an import.
      Parameters:
      model - the model to search the info for
      uri - 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 resolves model
      Returns:
      the related model information object or null if there is none
    • getModelInfo

      public ModelInfo<M> getModelInfo(String name, Version version, URI uri)
      Returns a known model information object via its URI.
      Parameters:
      name - the name of the model to search for
      version - the version of the model to search for
      uri - the URI to search for
      Returns:
      the related model information object (or null if not found)
    • getModelInfo

      public List<ModelInfo<M>> getModelInfo(String name, Version version)
      Returns the model information objects for the specified model.
      Parameters:
      name - the name of the model to search for
      version - the version of the model to search for
      Returns:
      the model information objects (may have different URLs) or null if unknown
    • getModelInfos

      public 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 to model, 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 List<ModelInfo<M>> getModelInfo(String name, String version) throws VersionFormatException
      Returns the model information object for the specified model.
      Parameters:
      name - the name of the model to search for
      version - 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(String name)
      Returns whether there are known model information objects for the specified model.
      Parameters:
      name - the name of the model
      Returns:
      true if model information is known (at least on model but multiple in different versions may exist), false else
    • getModelInfo

      public List<ModelInfo<M>> getModelInfo(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(String name, String version, URI uri) throws VersionFormatException
      Returns a known model object via its URI.
      Parameters:
      name - the name of the model to search for
      version - the version of the model to search for
      uri - the URI to search for
      Returns:
      the related model object (or null if not found or not yet resolved)
      Throws:
      VersionFormatException - in case that version is in wrong format (see Version
    • getModel

      public M getModel(String name, Version version, URI uri) throws VersionFormatException
      Returns a known model object via its URI.
      Parameters:
      name - the name of the model to search for
      version - the version of the model to search for
      uri - the URI to search for
      Returns:
      the related model object (or null if not found or not yet resolved)
      Throws:
      VersionFormatException - in case that version is in wrong format (see Version
    • getModelInfo

      public ModelInfo<M> getModelInfo(String name, String version, URI uri) throws VersionFormatException
      Returns a known model information object via its URI.
      Parameters:
      name - the name of the model to search for
      version - the version of the model to search for
      uri - the URI to search for
      Returns:
      the related model information object (or null if not found)
      Throws:
      VersionFormatException - in case that version is in wrong format (see Version
    • getAvailable

      List<VersionedModelInfos<M>> getAvailable(String name)
      Returns models available for a given model name.
      Parameters:
      name - the name to search for
      Returns:
      the available models or null
    • putAvailable

      void putAvailable(String name, List<VersionedModelInfos<M>> infos)
      Puts available model information objects for a given model name.
      Parameters:
      name - the name of the model
      infos - the associated model information objects
    • removeAvailable

      void removeAvailable(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, URI location)
      Creates a temporary resolved model information without model loader. Do not use the result for regular models! Call releaseTempInfo(ModelInfo) if the model is not used anymore. Affects only getInfo(URI).
      Parameters:
      model - the model
      location - 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)
    • isTempInfo

      public boolean isTempInfo(ModelInfo<M> info)
      Returns whether info is a temporary model.
      Parameters:
      info - the information object to check (may be null)
      Returns:
      true if info points to a temporary model, false else (also if info is null)