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.xanalysis.solver.proj;
18  
19  import io.github.tonywasher.joceanus.themis.xanalysis.parser.proj.ThemisXAnalysisModule;
20  import io.github.tonywasher.joceanus.themis.xanalysis.parser.proj.ThemisXAnalysisPackage;
21  import io.github.tonywasher.joceanus.themis.xanalysis.solver.proj.ThemisXAnalysisSolverDef.ThemisXAnalysisSolverModuleDef;
22  import io.github.tonywasher.joceanus.themis.xanalysis.solver.proj.ThemisXAnalysisSolverDef.ThemisXAnalysisSolverProjectDef;
23  
24  import java.util.ArrayList;
25  import java.util.List;
26  
27  /**
28   * Solver Module.
29   */
30  public class ThemisXAnalysisSolverModule
31          implements ThemisXAnalysisSolverModuleDef {
32      /**
33       * The owning project.
34       */
35      private final ThemisXAnalysisSolverProjectDef theProject;
36  
37      /**
38       * The underlying module.
39       */
40      private final ThemisXAnalysisModule theModule;
41  
42      /**
43       * The list of packages.
44       */
45      private final List<ThemisXAnalysisSolverPackage> thePackages;
46  
47      /**
48       * Constructor.
49       *
50       * @param pProject the owning project
51       * @param pModule  the parsed module
52       */
53      ThemisXAnalysisSolverModule(final ThemisXAnalysisSolverProjectDef pProject,
54                                  final ThemisXAnalysisModule pModule) {
55          /* Store the parameters */
56          theProject = pProject;
57          theModule = pModule;
58  
59          /* Initialise the packages */
60          thePackages = new ArrayList<>();
61          for (ThemisXAnalysisPackage myPackage : theModule.getPackages()) {
62              final ThemisXAnalysisSolverPackage mySolverPackage = new ThemisXAnalysisSolverPackage(this, myPackage);
63              thePackages.add(mySolverPackage);
64          }
65      }
66  
67      @Override
68      public ThemisXAnalysisSolverProjectDef getOwningProject() {
69          return theProject;
70      }
71  
72      @Override
73      public ThemisXAnalysisModule getUnderlyingModule() {
74          return theModule;
75      }
76  
77      /**
78       * Obtain the packages.
79       *
80       * @return the packages
81       */
82      public List<ThemisXAnalysisSolverPackage> getPackages() {
83          return thePackages;
84      }
85  
86      @Override
87      public String toString() {
88          return theModule.toString();
89      }
90  }