Class ModelContainer<M extends net.ssehub.easy.basics.modelManagement.IModel>

  • Type Parameters:
    M - the specific model type
    All Implemented Interfaces:
    net.ssehub.easy.basics.modelManagement.IModelData, net.ssehub.easy.basics.modelManagement.IModelListener<M>
    Direct Known Subclasses:
    ProjectContainer, ScriptContainer

    public abstract class ModelContainer<M extends net.ssehub.easy.basics.modelManagement.IModel>
    extends java.lang.Object
    implements net.ssehub.easy.basics.modelManagement.IModelListener<M>, net.ssehub.easy.basics.modelManagement.IModelData
    Extended capabilities for IModels.
    Author:
    El-Sharkawy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private SemanticErrorDescription description
      A optional description of exceptions, caught during parsing the model.
      private net.ssehub.easy.basics.modelManagement.IModelListener<M> listener
      Optional IModelListener for getting informed whenever the managed model was replaced by the parser.
      private Configuration location
      The location (folder) of the managed model.
      private static net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLogger LOGGER  
      private M model
      The model which should be managed by this container.
      private net.ssehub.easy.basics.modelManagement.ModelManagement<M> modelManager
      The container holding and managing all models of type <M>.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ModelContainer​(M model, net.ssehub.easy.basics.modelManagement.ModelManagement<M> modelManager, Configuration location)
      Default constructor of this class.
      protected ModelContainer​(M model, SemanticErrorDescription description, net.ssehub.easy.basics.modelManagement.ModelManagement<M> modelManager, Configuration location)
      Constructor if an Exception occurred during parsing the model.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      SemanticErrorDescription getDescription()
      Getter for the SemanticErrorDescription (describing a caught exception).
      net.ssehub.easy.basics.modelManagement.Version getHighestVersion()
      Returns the highest Version that is available for the managed model.
      abstract java.io.File getLocation()
      Returns the location, where the model is loaded from.
      protected java.io.File getLocation​(Configuration.PathKind kind)
      Returns the location, where the model is loaded from.
      M getModel()
      Getter for the model.
      java.lang.String getName()
      net.ssehub.easy.basics.modelManagement.Version getVersion()
      boolean isSaveable()
      Checks whether the model works and can be saved, or if a dummy was used to avoid NullPointerExceptions.
      java.util.List<net.ssehub.easy.basics.modelManagement.ModelInfo<M>> listAvailableModels()
      Returns a list with all (alternative) models of this model.
      void notifyReplaced​(M oldModel, M newModel)
      If this method is called, the stored getDescription() will be set to null as this is usually only called if the parser has parsed the model successfully.
      void registerModelListener​(net.ssehub.easy.basics.modelManagement.IModelListener<M> listener)
      Sets the IModelListener for the managed model, to get informed when the model was replaced by the parser.
      void setMainModel​(net.ssehub.easy.basics.modelManagement.ModelInfo<M> newMainModel)
      Changes the managed Model.
      void unregisterModelListener()
      Removes the registered IModelListener.
      • Methods inherited from class java.lang.Object

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

      • LOGGER

        private static final net.ssehub.easy.basics.logger.EASyLoggerFactory.EASyLogger LOGGER
      • model

        private M extends net.ssehub.easy.basics.modelManagement.IModel model
        The model which should be managed by this container.
      • description

        private SemanticErrorDescription description
        A optional description of exceptions, caught during parsing the model.
      • modelManager

        private net.ssehub.easy.basics.modelManagement.ModelManagement<M extends net.ssehub.easy.basics.modelManagement.IModel> modelManager
        The container holding and managing all models of type <M>.
      • location

        private Configuration location
        The location (folder) of the managed model.
      • listener

        private net.ssehub.easy.basics.modelManagement.IModelListener<M extends net.ssehub.easy.basics.modelManagement.IModel> listener
        Optional IModelListener for getting informed whenever the managed model was replaced by the parser.
    • Constructor Detail

      • ModelContainer

        protected ModelContainer​(M model,
                                 net.ssehub.easy.basics.modelManagement.ModelManagement<M> modelManager,
                                 Configuration location)
        Default constructor of this class.
        Parameters:
        model - The model, which should be managed by this container.
        modelManager - The container holding and managing all models of type <M>.
        location - The location (folder) of the managed model.
      • ModelContainer

        protected ModelContainer​(M model,
                                 SemanticErrorDescription description,
                                 net.ssehub.easy.basics.modelManagement.ModelManagement<M> modelManager,
                                 Configuration location)
        Constructor if an Exception occurred during parsing the model. The model can be used but not be saved, as long the semantic error is not solved.
        Parameters:
        model - The model, which should be managed by this container.
        description - A description of an occurred semantic error while parsing the model. Can be null, then this constructor has the same behavior as #ModelContainer(IModel).
        modelManager - The container holding and managing all models of type <M>.
        location - The location (folder) of the managed model.
    • Method Detail

      • getModel

        public M getModel()
        Getter for the model.
        Returns:
        Returns the managed model.
      • getVersion

        public net.ssehub.easy.basics.modelManagement.Version getVersion()
        Specified by:
        getVersion in interface net.ssehub.easy.basics.modelManagement.IModelData
      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface net.ssehub.easy.basics.modelManagement.IModelData
      • getLocation

        protected final java.io.File getLocation​(Configuration.PathKind kind)
        Returns the location, where the model is loaded from.
        Parameters:
        kind - Must match to the type of the model (getModel())
        Returns:
        The location of the loaded model.
      • getLocation

        public abstract java.io.File getLocation()
        Returns the location, where the model is loaded from.
        Returns:
        The location of the loaded model.
      • isSaveable

        public boolean isSaveable()
        Checks whether the model works and can be saved, or if a dummy was used to avoid NullPointerExceptions.
        Returns:
        true if a loaded model is used and can be saved, false if a dummy was used, which should not be saved.
      • notifyReplaced

        public void notifyReplaced​(M oldModel,
                                   M newModel)
        If this method is called, the stored getDescription() will be set to null as this is usually only called if the parser has parsed the model successfully.
        Specified by:
        notifyReplaced in interface net.ssehub.easy.basics.modelManagement.IModelListener<M extends net.ssehub.easy.basics.modelManagement.IModel>
      • getHighestVersion

        public net.ssehub.easy.basics.modelManagement.Version getHighestVersion()
        Returns the highest Version that is available for the managed model.
        Returns:
        The highest version that exists within all models stored at the same configFolder (or null if no model exists).
        See Also:
        listAvailableModels()
      • listAvailableModels

        public java.util.List<net.ssehub.easy.basics.modelManagement.ModelInfo<M>> listAvailableModels()
        Returns a list with all (alternative) models of this model.
        Returns:
        A list with all (alternative) models of this model.
        See Also:
        setMainModel(ModelInfo)
      • setMainModel

        public void setMainModel​(net.ssehub.easy.basics.modelManagement.ModelInfo<M> newMainModel)
        Changes the managed Model. The model should be add the specified location (getLocation().
        Parameters:
        newMainModel - The model that should be used by this container.
        See Also:
        listAvailableModels()
      • registerModelListener

        public void registerModelListener​(net.ssehub.easy.basics.modelManagement.IModelListener<M> listener)
        Sets the IModelListener for the managed model, to get informed when the model was replaced by the parser.
        Parameters:
        listener - A listener for the managed model.
        See Also:
        unregisterModelListener()