Class AvailableModels<M extends IModel>

  • Type Parameters:
    M - the specific type of model

    public class AvailableModels<M extends IModel>
    extends java.lang.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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void clear()
      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 model name.
      ModelInfo<M> getInfo​(java.net.URI uri)
      Returns the (visible) information object at uri.
      M getModel​(java.lang.String name, java.lang.String version, java.net.URI uri)
      Returns a known model object via its URI.
      M getModel​(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.
      int getModelInfoCount​(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 at uri.
      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 for model while considering uri as location of model.
      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.
      boolean hasModelInfo​(java.lang.String name)
      Returns whether there are known model information objects for the specified model.
      boolean isTempInfo​(ModelInfo<M> info)
      Returns whether info is a temporary model.
      (package private) void putAvailable​(java.lang.String name, java.util.List<VersionedModelInfos<M>> infos)
      Puts available model information objects for a given model name.
      void releaseTempInfo​(ModelInfo<M> info)
      Releases a temporary model information object.
      (package private) void removeAvailable​(java.lang.String name)
      Removes a model information object for a given model name.
      (package private) void removeAvailable​(ModelInfo<M> info)
      Removes a model information object for a given information object.
      (package private) boolean updateAvailableModel​(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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • availableModels

        private java.util.Map<java.lang.String,​java.util.List<VersionedModelInfos<M extends IModel>>> availableModels
      • tmpInfo

        private java.util.Map<java.net.URI,​ModelInfo<M extends IModel>> tmpInfo
    • 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
      • 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​(java.net.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 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 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 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 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

        java.util.List<ModelInfo<M>> getModelInfoWith​(java.net.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,
                                                 java.net.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​(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 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 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 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 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 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 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 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​(java.lang.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 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 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​(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 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​(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 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

        java.util.List<VersionedModelInfos<M>> getAvailable​(java.lang.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​(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 model
        infos - 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! 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)