1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.themis.parser.decl;
18
19 import com.github.javaparser.ast.body.EnumDeclaration;
20 import io.github.tonywasher.joceanus.metis.field.MetisFieldSet;
21 import io.github.tonywasher.joceanus.oceanus.base.OceanusException;
22 import io.github.tonywasher.joceanus.oceanus.format.OceanusDataFormatter;
23 import io.github.tonywasher.joceanus.themis.parser.base.ThemisDataResource;
24 import io.github.tonywasher.joceanus.themis.parser.base.ThemisInstance.ThemisClassInstance;
25 import io.github.tonywasher.joceanus.themis.parser.base.ThemisInstance.ThemisDeclarationInstance;
26 import io.github.tonywasher.joceanus.themis.parser.base.ThemisModifierList;
27 import io.github.tonywasher.joceanus.themis.parser.base.ThemisParserDef;
28 import io.github.tonywasher.joceanus.themis.parser.node.ThemisNodeSimpleName;
29
30 import java.util.List;
31
32
33
34
35 public class ThemisDeclEnum
36 extends ThemisBaseDeclaration<EnumDeclaration>
37 implements ThemisDeclarationInstance, ThemisClassInstance {
38
39
40
41 private static final MetisFieldSet<ThemisDeclEnum> FIELD_DEFS = MetisFieldSet.newFieldSet(ThemisDeclEnum.class);
42
43
44
45
46 static {
47 FIELD_DEFS.declareLocalField(ThemisDataResource.DATA_NAME, ThemisDeclEnum::getName);
48 }
49
50
51
52
53 private final String theName;
54
55
56
57
58 private final String theFullName;
59
60
61
62
63 private final ThemisModifierList theModifiers;
64
65
66
67
68 private final List<ThemisDeclarationInstance> theValues;
69
70
71
72
73 private final List<ThemisDeclarationInstance> theBody;
74
75
76
77
78 private final List<ThemisTypeInstance> theImplements;
79
80
81
82
83 private final List<ThemisExpressionInstance> theAnnotations;
84
85
86
87
88
89
90
91
92 ThemisDeclEnum(final ThemisParserDef pParser,
93 final EnumDeclaration pDeclaration) throws OceanusException {
94
95 super(pParser, pDeclaration);
96 theName = ((ThemisNodeSimpleName) pParser.parseNode(pDeclaration.getName())).getName();
97 theFullName = pDeclaration.getFullyQualifiedName().orElse(null);
98 theModifiers = pParser.parseModifierList(pDeclaration.getModifiers());
99 theAnnotations = pParser.parseExprList(pDeclaration.getAnnotations());
100 theImplements = pParser.parseTypeList(pDeclaration.getImplementedTypes());
101 theValues = pParser.parseDeclarationList(pDeclaration.getEntries());
102
103
104 pParser.registerClass(this);
105
106
107 theBody = pParser.parseDeclarationList(pDeclaration.getMembers());
108 }
109
110 @Override
111 public MetisFieldSet<ThemisDeclEnum> getDataFieldSet() {
112 return FIELD_DEFS;
113 }
114
115 @Override
116 public String formatObject(final OceanusDataFormatter pFormatter) {
117 return getName();
118 }
119
120 @Override
121 public String getName() {
122 return theName;
123 }
124
125 @Override
126 public String getFullName() {
127 return theFullName;
128 }
129
130 @Override
131 public boolean isTopLevel() {
132 return getNode().isTopLevelType();
133 }
134
135 @Override
136 public ThemisModifierList getModifiers() {
137 return theModifiers;
138 }
139
140
141
142
143
144
145 public List<ThemisDeclarationInstance> getValues() {
146 return theValues;
147 }
148
149 @Override
150 public List<ThemisDeclarationInstance> getBody() {
151 return theBody;
152 }
153
154 @Override
155 public List<ThemisTypeInstance> getImplements() {
156 return theImplements;
157 }
158
159 @Override
160 public List<ThemisExpressionInstance> getAnnotations() {
161 return theAnnotations;
162 }
163 }