diff options
Diffstat (limited to 'subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/internal/DesignSpaceExplorationStoreAdapterImpl.java')
-rw-r--r-- | subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/internal/DesignSpaceExplorationStoreAdapterImpl.java | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/internal/DesignSpaceExplorationStoreAdapterImpl.java b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/internal/DesignSpaceExplorationStoreAdapterImpl.java new file mode 100644 index 00000000..bd85e7a6 --- /dev/null +++ b/subprojects/store-dse/src/main/java/tools/refinery/store/dse/transition/internal/DesignSpaceExplorationStoreAdapterImpl.java | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/> | ||
3 | * | ||
4 | * SPDX-License-Identifier: EPL-2.0 | ||
5 | */ | ||
6 | package tools.refinery.store.dse.transition.internal; | ||
7 | |||
8 | import tools.refinery.store.dse.transition.DesignSpaceExplorationStoreAdapter; | ||
9 | import tools.refinery.store.dse.transition.Transformation; | ||
10 | import tools.refinery.store.dse.transition.Rule; | ||
11 | import tools.refinery.store.dse.transition.objectives.Criterion; | ||
12 | import tools.refinery.store.dse.transition.objectives.CriterionCalculator; | ||
13 | import tools.refinery.store.dse.transition.objectives.Objective; | ||
14 | import tools.refinery.store.dse.transition.objectives.ObjectiveCalculator; | ||
15 | import tools.refinery.store.model.Model; | ||
16 | import tools.refinery.store.model.ModelStore; | ||
17 | |||
18 | import java.util.List; | ||
19 | |||
20 | public class DesignSpaceExplorationStoreAdapterImpl implements DesignSpaceExplorationStoreAdapter { | ||
21 | protected final ModelStore store; | ||
22 | |||
23 | protected final List<Rule> ruleDefinitions; | ||
24 | protected final List<Criterion> accepts; | ||
25 | protected final List<Criterion> excludes; | ||
26 | protected final List<Objective> objectives; | ||
27 | |||
28 | public DesignSpaceExplorationStoreAdapterImpl( | ||
29 | ModelStore store, List<Rule> ruleDefinitions, List<Criterion> accepts, List<Criterion> excludes, | ||
30 | List<Objective> objectives) { | ||
31 | this.store = store; | ||
32 | this.ruleDefinitions = ruleDefinitions; | ||
33 | this.accepts = accepts; | ||
34 | this.excludes = excludes; | ||
35 | this.objectives = objectives; | ||
36 | } | ||
37 | |||
38 | @Override | ||
39 | public ModelStore getStore() { | ||
40 | return store; | ||
41 | } | ||
42 | |||
43 | @Override | ||
44 | public DesignSpaceExplorationAdapterImpl createModelAdapter(Model model) { | ||
45 | final List<Transformation> t = this.ruleDefinitions.stream() | ||
46 | .map(x -> new Transformation(model, x)) | ||
47 | .toList(); | ||
48 | final List<CriterionCalculator> a = this.accepts.stream().map(x -> x.createCalculator(model)).toList(); | ||
49 | final List<CriterionCalculator> e = this.excludes.stream().map(x -> x.createCalculator(model)).toList(); | ||
50 | final List<ObjectiveCalculator> o = this.objectives.stream().map(x -> x.createCalculator(model)).toList(); | ||
51 | |||
52 | return new DesignSpaceExplorationAdapterImpl(model, this, t, a, e, o); | ||
53 | } | ||
54 | |||
55 | @Override | ||
56 | public List<Rule> getTransformations() { | ||
57 | return ruleDefinitions; | ||
58 | } | ||
59 | |||
60 | @Override | ||
61 | public List<Criterion> getAccepts() { | ||
62 | return accepts; | ||
63 | } | ||
64 | |||
65 | @Override | ||
66 | public List<Criterion> getExcludes() { | ||
67 | return excludes; | ||
68 | } | ||
69 | |||
70 | @Override | ||
71 | public List<Objective> getObjectives() { | ||
72 | return objectives; | ||
73 | } | ||
74 | } | ||