Class ModelUpdateUtils

java.lang.Object
net.ssehub.easy.basics.modelManagement.ModelUpdateUtils

class ModelUpdateUtils extends 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
  • Constructor Details

    • ModelUpdateUtils

      ModelUpdateUtils()
  • Method Details

    • addReplacing

      static <M extends IModel> 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> Map<M,M> addReplacing(M old, M model, 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> Map<M,List<M>> collectImporting(List<M> models, 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> List<M> determineUpdateSeqence(M model, Map<M,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, Map<M,List<M>> using, Map<M,Integer> sequence, int start, 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