Class ModelContainer<M extends IModel>

    • Constructor Detail

      • ModelContainer

        protected ModelContainer​(M model,
                                 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,
                                 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 Version getVersion()
        Returns the version of the model.
        Specified by:
        getVersion in interface IModelData
        Returns:
        the version, may be null if no version is specified
      • getName

        public java.lang.String getName()
        Returns the name of the model.
        Specified by:
        getName in interface IModelData
        Returns:
        the name
      • 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)
        Is called to notify that oldModel is replaced by newModel. The listener registrations for oldModel will be adjusted accordingly.
        Do not modify the the listeners of oldModel or newModel during this method. 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 IModelListener<M extends IModel>
        Parameters:
        oldModel - the old model being replaced
        newModel - the new model (the replacement)
      • getHighestVersion

        public 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<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​(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​(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()