Class ModelUpdateUtils
java.lang.Object
net.ssehub.easy.basics.modelManagement.ModelUpdateUtils
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddReplacing(M old, M model) Adds a pair of original and replacing model into a new mapping structure.addReplacing(M old, M model, Map<M, M> result) Adds a pair of original and replacing model into a new mapping structure.collectImporting(List<M> models, Map<M, M> replacing) Collects all importing models.determineUpdateSeqence(M model, Map<M, List<M>> using) Determines the update sequence formodelbased on the importing models inusing.private static <M extends IModel>
intRecursively follows the importing models provided byusingfrommodeland enumerates them fromstart.
-
Constructor Details
-
ModelUpdateUtils
ModelUpdateUtils()
-
-
Method Details
-
addReplacing
Adds a pair of original and replacing model into a new mapping structure.- Type Parameters:
M- the model type- Parameters:
old- the old modelmodel- the replacing model- Returns:
- the mapping structure containing
oldandmodel
-
addReplacing
Adds a pair of original and replacing model into a new mapping structure.- Type Parameters:
M- the model type- Parameters:
old- the old modelmodel- the replacing modelresult- the mapping structure before adding, may be null then a new one is created- Returns:
- the mapping structure containing
oldandmodel
-
collectImporting
Collects all importing models.- Type Parameters:
M- the type of model- Parameters:
models- the models to be consideredreplacing- 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
Determines the update sequence formodelbased on the importing models inusing. 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 forusing- 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 byusingfrommodeland enumerates them fromstart. 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 traversalusing- the actual importing modelssequence- the importing models and their assigned sequence numberstart- the start sequence numberdone- already processed models - cycle prevention- Returns:
- the updated start sequence number
-