1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.themis.xanalysis.solver.proj;
18
19 import io.github.tonywasher.joceanus.themis.xanalysis.parser.base.ThemisXAnalysisInstance;
20 import io.github.tonywasher.joceanus.themis.xanalysis.parser.base.ThemisXAnalysisInstance.ThemisXAnalysisClassInstance;
21 import io.github.tonywasher.joceanus.themis.xanalysis.parser.base.ThemisXAnalysisInstance.ThemisXAnalysisMethodInstance;
22 import io.github.tonywasher.joceanus.themis.xanalysis.solver.proj.ThemisXAnalysisSolverDef.ThemisXAnalysisSolverClassDef;
23 import io.github.tonywasher.joceanus.themis.xanalysis.solver.proj.ThemisXAnalysisSolverDef.ThemisXAnalysisSolverFileDef;
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28
29
30
31 public class ThemisXAnalysisSolverClass
32 implements ThemisXAnalysisSolverClassDef {
33
34
35
36 private final String theFullName;
37
38
39
40
41 private final ThemisXAnalysisSolverFileDef theFile;
42
43
44
45
46 private final ThemisXAnalysisClassInstance theClass;
47
48
49
50
51 private final List<ThemisXAnalysisSolverMethod> theMethods;
52
53
54
55
56 private boolean isCircular;
57
58
59
60
61
62
63
64 ThemisXAnalysisSolverClass(final ThemisXAnalysisSolverFileDef pFile,
65 final ThemisXAnalysisClassInstance pClass) {
66
67 theFile = pFile;
68 theClass = pClass;
69
70
71 theFullName = theClass.getFullName();
72
73
74 theMethods = new ArrayList<>();
75 final ThemisXAnalysisInstance myNode = (ThemisXAnalysisInstance) theClass;
76 for (ThemisXAnalysisInstance myMethod : myNode.discoverChildren(ThemisXAnalysisMethodInstance.class::isInstance)) {
77 final ThemisXAnalysisSolverMethod mySolverMethod = new ThemisXAnalysisSolverMethod(this, (ThemisXAnalysisMethodInstance) myMethod);
78 theMethods.add(mySolverMethod);
79 }
80 }
81
82
83
84
85
86
87 public String getName() {
88 return theClass.getName();
89 }
90
91 @Override
92 public String getFullName() {
93 return theFullName;
94 }
95
96 @Override
97 public ThemisXAnalysisSolverFileDef getOwningFile() {
98 return theFile;
99 }
100
101 @Override
102 public ThemisXAnalysisClassInstance getUnderlyingClass() {
103 return theClass;
104 }
105
106
107
108
109
110
111 public boolean isTopLevel() {
112 return theClass.isTopLevel();
113 }
114
115
116
117
118
119
120 public List<ThemisXAnalysisSolverMethod> getMethods() {
121 return theMethods;
122 }
123
124
125
126
127
128
129 public String getPackageName() {
130 return theFile.getOwningPackage().toString();
131 }
132
133 @Override
134 public boolean equals(final Object pThat) {
135
136 if (this == pThat) {
137 return true;
138 }
139 if (pThat == null) {
140 return false;
141 }
142
143
144 if (!(pThat instanceof ThemisXAnalysisSolverClass myThat)) {
145 return false;
146 }
147
148
149 return theFullName.equals(myThat.getFullName());
150 }
151
152 @Override
153 public int hashCode() {
154 return theFullName.hashCode();
155 }
156
157 @Override
158 public String toString() {
159 return theFullName;
160 }
161 }