Skip to content

Commit 4585209

Browse files
committed
purged EnumEntry and replaced by EnumerationDescription
1 parent 9d8b659 commit 4585209

File tree

2 files changed

+6
-25
lines changed

2 files changed

+6
-25
lines changed

jmolecules-bytebuddy/src/main/java/org/jmolecules/bytebuddy/vaadoo/Parameters.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,6 @@
4141

4242
public class Parameters implements Iterable<Parameter> {
4343

44-
static class EnumEntry {
45-
private final Type type;
46-
private final String value;
47-
48-
private EnumEntry(Type type, String value) {
49-
this.type = type;
50-
this.value = value;
51-
}
52-
53-
Type type() {
54-
return type;
55-
}
56-
57-
String value() {
58-
return value;
59-
}
60-
}
61-
6244
public static Parameters of(ParameterList<InDefinedShape> parameterList) {
6345
return new Parameters(parameterList);
6446
}

jmolecules-bytebuddy/src/main/java/org/jmolecules/bytebuddy/vaadoo/ValidationCodeInjector.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,10 @@ public void visitMethodInsn(int opcode, String owner, String name, String descri
201201
if (isFirstParamLoad) {
202202
Type returnType = getReturnType(descriptor);
203203
if (isArray(returnType)) {
204-
@SuppressWarnings("unchecked")
205-
List<EnumEntry> annotationValues = (List<EnumEntry>) targetParam
204+
EnumerationDescription[] annotationValues = (EnumerationDescription[]) targetParam
206205
.annotationValue(currentAnnotationType, name);
207206
writeArray(returnType.getElementType(),
208-
annotationValues == null ? emptyList() : annotationValues);
207+
annotationValues == null ? emptyList() : Arrays.asList(annotationValues));
209208
} else {
210209
visitLdcInsn(annotationsLdcInsnValue(targetParam, owner, name, returnType));
211210
}
@@ -216,18 +215,18 @@ public void visitMethodInsn(int opcode, String owner, String name, String descri
216215
}
217216
}
218217

219-
private void writeArray(Type arrayElementType, List<EnumEntry> annotationValues) {
218+
private void writeArray(Type arrayElementType, List<EnumerationDescription> annotationValues) {
220219
int intInsn = annotationValues.size() <= 127 ? BIPUSH : SIPUSH;
221220
mv.visitIntInsn(intInsn, annotationValues.size());
222221
// TODO this only works for objects but not primitive arrays
223222
mv.visitTypeInsn(ANEWARRAY, arrayElementType.getInternalName());
224223

225224
int idx = 0;
226-
for (EnumEntry entry : annotationValues) {
225+
for (EnumerationDescription entry : annotationValues) {
227226
mv.visitInsn(DUP);
228227
mv.visitIntInsn(intInsn, idx++);
229-
mv.visitFieldInsn(GETSTATIC, entry.type().getInternalName(), entry.value(),
230-
entry.type().getDescriptor());
228+
mv.visitFieldInsn(GETSTATIC, entry.getEnumerationType().getInternalName(), entry.getValue(),
229+
entry.getEnumerationType().getDescriptor());
231230
mv.visitInsn(AASTORE);
232231
}
233232
}

0 commit comments

Comments
 (0)