1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.themis.solver.proj;
18
19 import io.github.tonywasher.joceanus.metis.field.MetisFieldSet;
20 import io.github.tonywasher.joceanus.oceanus.format.OceanusDataFormatter;
21 import io.github.tonywasher.joceanus.themis.parser.ThemisParser;
22 import io.github.tonywasher.joceanus.themis.parser.base.ThemisDataResource;
23 import io.github.tonywasher.joceanus.themis.parser.project.ThemisModule;
24 import io.github.tonywasher.joceanus.themis.parser.project.ThemisProject;
25 import io.github.tonywasher.joceanus.themis.solver.proj.ThemisSolverDef.ThemisSolverProjectDef;
26
27 import java.util.ArrayList;
28 import java.util.List;
29
30
31
32
33 public class ThemisSolverProject
34 implements ThemisSolverProjectDef {
35
36
37
38 private static final MetisFieldSet<ThemisSolverProject> FIELD_DEFS = MetisFieldSet.newFieldSet(ThemisSolverProject.class);
39
40
41
42
43 static {
44 FIELD_DEFS.declareLocalField(ThemisDataResource.DATA_MODULES, ThemisSolverProject::getModules);
45 FIELD_DEFS.declareLocalField(ThemisDataResource.DATA_UNDERLYING, ThemisSolverProject::getUnderlyingProject);
46 }
47
48
49
50
51 private final ThemisParser theParser;
52
53
54
55
56 private final ThemisProject theProject;
57
58
59
60
61 private final List<ThemisSolverModule> theModules;
62
63
64
65
66
67
68 public ThemisSolverProject(final ThemisParser pParser) {
69
70 theParser = pParser;
71 theProject = theParser.getProject();
72
73
74 theModules = new ArrayList<>();
75
76
77 for (ThemisModule myModule : theProject.getModules()) {
78 theModules.add(new ThemisSolverModule(this, myModule));
79 }
80 }
81
82 @Override
83 public MetisFieldSet<ThemisSolverProject> getDataFieldSet() {
84 return FIELD_DEFS;
85 }
86
87 @Override
88 public String formatObject(final OceanusDataFormatter pFormatter) {
89 return toString();
90 }
91
92
93
94
95
96
97 public ThemisParser getProjectParser() {
98 return theParser;
99 }
100
101 @Override
102 public ThemisProject getUnderlyingProject() {
103 return theProject;
104 }
105
106
107
108
109
110
111 public List<ThemisSolverModule> getModules() {
112 return theModules;
113 }
114
115 @Override
116 public String toString() {
117 return theProject.toString();
118 }
119 }