Class ModelUpdateUtils


  • class ModelUpdateUtils
    extends java.lang.Object
    A set of algorithms to enable recursive model updates along the imports. This implementation is initial as it rebuilds the importing model structure (to be turned into an incremental version later).
    Author:
    Holger Eichelberger
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static <M extends IModel>
      java.util.Map<M,​M>
      addReplacing​(M old, M model)
      Adds a pair of original and replacing model into a new mapping structure.
      (package private) static <M extends IModel>
      java.util.Map<M,​M>
      addReplacing​(M old, M model, java.util.Map<M,​M> result)
      Adds a pair of original and replacing model into a new mapping structure.
      (package private) static <M extends IModel>
      java.util.Map<M,​java.util.List<M>>
      collectImporting​(java.util.List<M> models, java.util.Map<M,​M> replacing)
      Collects all importing models.
      (package private) static <M extends IModel>
      java.util.List<M>
      determineUpdateSeqence​(M model, java.util.Map<M,​java.util.List<M>> using)
      Determines the update sequence for model based on the importing models in using.
      private static <M extends IModel>
      int
      followImporting​(M model, java.util.Map<M,​java.util.List<M>> using, java.util.Map<M,​java.lang.Integer> sequence, int start, java.util.Set<M> done)
      Recursively follows the importing models provided by using from model and enumerates them from start.
      • Methods inherited from class java.lang.Object

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

      • ModelUpdateUtils

        ModelUpdateUtils()
    • Method Detail

      • addReplacing

        static <M extends IModel> java.util.Map<M,​M> addReplacing​(M old,
                                                                        M model)
        Adds a pair of original and replacing model into a new mapping structure.
        Type Parameters:
        M - the model type
        Parameters:
        old - the old model
        model - the replacing model
        Returns:
        the mapping structure containing old and model
      • addReplacing

        static <M extends IModel> java.util.Map<M,​M> addReplacing​(M old,
                                                                        M model,
                                                                        java.util.Map<M,​M> result)
        Adds a pair of original and replacing model into a new mapping structure.
        Type Parameters:
        M - the model type
        Parameters:
        old - the old model
        model - the replacing model
        result - the mapping structure before adding, may be null then a new one is created
        Returns:
        the mapping structure containing old and model
      • collectImporting

        static <M extends IModel> java.util.Map<M,​java.util.List<M>> collectImporting​(java.util.List<M> models,
                                                                                            java.util.Map<M,​M> replacing)
        Collects all importing models.
        Type Parameters:
        M - the type of model
        Parameters:
        models - the models to be considered
        replacing - optional mapping of old and new models in case of updates (result will contain new models rather than old ones mentioned in the mapping), may be null
        Returns:
        all importing models, key is model, value is importing models
      • determineUpdateSeqence

        static <M extends IModel> java.util.List<M> determineUpdateSeqence​(M model,
                                                                           java.util.Map<M,​java.util.List<M>> using)
        Determines the update sequence for model based on the importing models in using. This method follows all imports and gives the imported model a sequence number. Revisited models receive a higher number in order to be later in sequence.
        Type Parameters:
        M - the type of model
        Parameters:
        model - the model to determine the update sequence for
        using - the actual importing models
        Returns:
        the update sequence (may contain null in case of models shifted in sequence)
      • followImporting

        private static <M extends IModel> int followImporting​(M model,
                                                              java.util.Map<M,​java.util.List<M>> using,
                                                              java.util.Map<M,​java.lang.Integer> sequence,
                                                              int start,
                                                              java.util.Set<M> done)
        Recursively follows the importing models provided by using from model and enumerates them from start. Revisited models receive a higher number and, thus, will be later in the update sequence.
        Type Parameters:
        M - the type of model
        Parameters:
        model - the model to start the recursive traversal
        using - the actual importing models
        sequence - the importing models and their assigned sequence number
        start - the start sequence number
        done - already processed models - cycle prevention
        Returns:
        the updated start sequence number