1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.themis.solver.reflect;
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.base.ThemisDataResource;
22 import io.github.tonywasher.joceanus.themis.parser.base.ThemisInstance.ThemisClassInstance;
23 import io.github.tonywasher.joceanus.themis.parser.base.ThemisModifierList;
24 import io.github.tonywasher.joceanus.themis.parser.node.ThemisNodeImport;
25 import io.github.tonywasher.joceanus.themis.parser.node.ThemisNodeModifierList;
26
27 import java.util.ArrayList;
28 import java.util.List;
29
30
31
32
33 public class ThemisReflectExternal
34 implements ThemisClassInstance {
35
36
37
38 private static final MetisFieldSet<ThemisReflectExternal> FIELD_DEFS = MetisFieldSet.newFieldSet(ThemisReflectExternal.class);
39
40
41
42
43 static {
44 FIELD_DEFS.declareLocalField(ThemisDataResource.DATA_NAME, ThemisReflectExternal::getName);
45 }
46
47
48
49
50 static final String JAVALANG = "java.lang.";
51
52
53
54
55 private final String theName;
56
57
58
59
60 private final String theFullName;
61
62
63
64
65 private final ThemisModifierList theModifiers;
66
67
68
69
70 private final List<String> theAncestors;
71
72
73
74
75 private ThemisClassInstance theClassInstance;
76
77
78
79
80
81
82 public ThemisReflectExternal(final ThemisNodeImport pImport) {
83 theName = pImport.getShortName();
84 theFullName = pImport.getFullName();
85 theModifiers = new ThemisNodeModifierList(new ArrayList<>());
86 theAncestors = new ArrayList<>();
87 }
88
89
90
91
92
93
94 ThemisReflectExternal(final ThemisClassInstance pClazz) {
95 theName = pClazz.getName();
96 theFullName = pClazz.getFullName();
97 theModifiers = pClazz.getModifiers();
98 theAncestors = new ArrayList<>();
99 theClassInstance = pClazz;
100 }
101
102 @Override
103 public MetisFieldSet<ThemisReflectExternal> getDataFieldSet() {
104 return FIELD_DEFS;
105 }
106
107 @Override
108 public String formatObject(final OceanusDataFormatter pFormatter) {
109 return getName();
110 }
111
112 @Override
113 public String getName() {
114 return theName;
115 }
116
117 @Override
118 public String getFullName() {
119 return theFullName;
120 }
121
122 @Override
123 public ThemisModifierList getModifiers() {
124 return theModifiers;
125 }
126
127 @Override
128 public boolean isTopLevel() {
129 return true;
130 }
131
132
133
134
135
136
137 public ThemisClassInstance getClassInstance() {
138 return theClassInstance;
139 }
140
141
142
143
144
145
146 public void setClassInstance(final ThemisClassInstance pClassInstance) {
147 theClassInstance = pClassInstance;
148 }
149
150
151
152
153
154
155 public List<String> getAncestors() {
156 return theAncestors;
157 }
158
159
160
161
162
163
164 public void addAncestor(final ThemisReflectExternal pAncestor) {
165 theAncestors.add(pAncestor.getFullName());
166 }
167 }