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.themis.parser.base.ThemisInstance;
20 import io.github.tonywasher.joceanus.themis.parser.base.ThemisInstance.ThemisClassInstance;
21 import io.github.tonywasher.joceanus.themis.parser.base.ThemisInstance.ThemisMethodInstance;
22 import io.github.tonywasher.joceanus.themis.solver.proj.ThemisSolverDef.ThemisSolverClassDef;
23 import io.github.tonywasher.joceanus.themis.solver.proj.ThemisSolverDef.ThemisSolverFileDef;
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28
29
30
31 public class ThemisSolverClass
32 implements ThemisSolverClassDef {
33
34
35
36 private final String theFullName;
37
38
39
40
41 private final ThemisSolverFileDef theFile;
42
43
44
45
46 private final ThemisClassInstance theClass;
47
48
49
50
51 private final List<ThemisSolverMethod> theMethods;
52
53
54
55
56 private final List<String> theAncestors;
57
58
59
60
61 private final boolean isStandard;
62
63
64
65
66
67
68
69 ThemisSolverClass(final ThemisSolverFileDef pFile,
70 final ThemisClassInstance pClass) {
71
72 theFile = pFile;
73 theClass = pClass;
74 theAncestors = new ArrayList<>();
75
76
77 theFullName = theClass.getFullName();
78 isStandard = pFile.getOwningPackage().isStandard();
79
80
81 theMethods = new ArrayList<>();
82 final ThemisInstance myNode = (ThemisInstance) theClass;
83 for (ThemisInstance myMethod : myNode.discoverChildren(ThemisMethodInstance.class::isInstance)) {
84 final ThemisSolverMethod mySolverMethod = new ThemisSolverMethod(this, (ThemisMethodInstance) myMethod);
85 theMethods.add(mySolverMethod);
86 }
87 }
88
89
90
91
92
93
94 public String getName() {
95 return theClass.getName();
96 }
97
98 @Override
99 public String getFullName() {
100 return theFullName;
101 }
102
103 @Override
104 public ThemisSolverFileDef getOwningFile() {
105 return theFile;
106 }
107
108 @Override
109 public ThemisClassInstance getUnderlyingClass() {
110 return theClass;
111 }
112
113
114
115
116
117
118 public boolean isStandard() {
119 return isStandard;
120 }
121
122
123
124
125
126
127 public boolean isTopLevel() {
128 return theClass.isTopLevel();
129 }
130
131
132
133
134
135
136 public List<ThemisSolverMethod> getMethods() {
137 return theMethods;
138 }
139
140
141
142
143
144
145 public String getPackageName() {
146 return theFile.getOwningPackage().toString();
147 }
148
149 @Override
150 public boolean equals(final Object pThat) {
151
152 if (this == pThat) {
153 return true;
154 }
155 if (pThat == null) {
156 return false;
157 }
158
159
160 if (!(pThat instanceof ThemisSolverClass myThat)) {
161 return false;
162 }
163
164
165 return theFullName.equals(myThat.getFullName());
166 }
167
168 @Override
169 public int hashCode() {
170 return theFullName.hashCode();
171 }
172
173 @Override
174 public String toString() {
175 return theFullName;
176 }
177
178
179
180
181
182
183 public List<String> getAncestors() {
184 return theAncestors;
185 }
186
187
188
189
190
191
192 public void addAncestor(final String pAncestor) {
193 theAncestors.add(pAncestor);
194 }
195 }