View Javadoc
1   /*
2    * Themis: Java Project Framework
3    * Copyright 2012-2026. Tony Washer
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6    * use this file except in compliance with the License.  You may obtain a copy
7    * of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
14   * License for the specific language governing permissions and limitations under
15   * the License.
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   * Solver Project.
32   */
33  public class ThemisSolverProject
34          implements ThemisSolverProjectDef {
35      /**
36       * Report fields.
37       */
38      private static final MetisFieldSet<ThemisSolverProject> FIELD_DEFS = MetisFieldSet.newFieldSet(ThemisSolverProject.class);
39  
40      /*
41       * Declare Fields.
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       * The project parser.
50       */
51      private final ThemisParser theParser;
52  
53      /**
54       * The underlying project.
55       */
56      private final ThemisProject theProject;
57  
58      /**
59       * The list of modules.
60       */
61      private final List<ThemisSolverModule> theModules;
62  
63      /**
64       * Constructor.
65       *
66       * @param pParser the analysis parser
67       */
68      public ThemisSolverProject(final ThemisParser pParser) {
69          /* Store the parameters */
70          theParser = pParser;
71          theProject = theParser.getProject();
72  
73          /* Create the Module list and parser */
74          theModules = new ArrayList<>();
75  
76          /* Initialise the modules */
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       * Obtain the project parser.
94       *
95       * @return the parser
96       */
97      public ThemisParser getProjectParser() {
98          return theParser;
99      }
100 
101     @Override
102     public ThemisProject getUnderlyingProject() {
103         return theProject;
104     }
105 
106     /**
107      * Obtain the modules.
108      *
109      * @return the modules
110      */
111     public List<ThemisSolverModule> getModules() {
112         return theModules;
113     }
114 
115     @Override
116     public String toString() {
117         return theProject.toString();
118     }
119 }