Interface PersistenceVersionAware

  • All Superinterfaces:
    SModel
    All Known Implementing Classes:
    DefaultSModelDescriptor

    public interface PersistenceVersionAware
    extends SModel
    PROVISIONAL API Indicator for models that track version of model persistence. Version set is specific to particular persistence, i.e. there might be range 1..8 for xml persistence and 1..2 for binary. Model implementing this interface is not necessarily persisted with the version indicated, nor is persisted at all. It's possible to save the same model with different persistence mechanisms, hence this version number is merely a hint and value tracker for persistence implementations that do recognize versions, and is useless for others. Primary purpose of this interface is to break tight coupling of general MPS code with DefaultSModelDescriptor and DefaultSModel which used to keep persistence version, and to get rid of instanceof SDefaultModelDescriptor (limits to particular model implementation). Generally, two models implementing this interface not necessarily share same persistence, thus instanceof PersistenceVersionAware is not sufficient to tell persistence version values could be directly compared. However, persistence version gets updated the model is read and written, and as such indicates version of the most recent (in case of free-floating models) or default (for regular SModel with associated DataSource) persistence mechanism.
    • Method Detail

      • setPersistenceVersion

        void setPersistenceVersion​(int version)
        Indicated persistence version for model serialization
        Parameters:
        version - persistence version number, or -1 for undefined/unknown
      • getPersistenceVersion

        int getPersistenceVersion()
        Version of persistence this model was loaded with, or desired persistence version for model save.
        Returns:
        persistence version number, or -1 when undefined
      • getModelFactory

        @Nullable
        ModelFactory getModelFactory()
        Actual ModelFactory which is currently responsible for model load/save, or null if model knowns nothing about persistence at the moment.
        Returns:
        model load/save facility or null if undefined