4
4
import com .fasterxml .jackson .annotation .JsonProperty ;
5
5
import com .fasterxml .jackson .annotation .JsonSubTypes ;
6
6
import com .fasterxml .jackson .annotation .JsonTypeInfo ;
7
+ import lombok .ToString ;
8
+
9
+ import java .util .List ;
7
10
8
11
@ JsonTypeInfo (
9
12
use = JsonTypeInfo .Id .NAME ,
16
19
@ JsonSubTypes .Type (value = Asm .Aconstnull .class , name = "Aconstnull" ),
17
20
@ JsonSubTypes .Type (value = Asm .Aload .class , name = "Aload" ),
18
21
@ JsonSubTypes .Type (value = Asm .Anewarray .class , name = "Anewarray" ),
22
+ @ JsonSubTypes .Type (value = Asm .Annotation .class , name = "Annotation" ),
19
23
@ JsonSubTypes .Type (value = Asm .Astore .class , name = "Astore" ),
20
24
@ JsonSubTypes .Type (value = Asm .Areturn .class , name = "Areturn" ),
21
25
@ JsonSubTypes .Type (value = Asm .Checkcast .class , name = "Checkcast" ),
@@ -107,6 +111,7 @@ public enum AsmType {
107
111
Aconstnull ,
108
112
Aload ,
109
113
Anewarray ,
114
+ Annotation ,
110
115
Astore ,
111
116
Areturn ,
112
117
Checkcast ,
@@ -301,19 +306,22 @@ public static class ClassCodeStart extends Asm {
301
306
private final String sig ;
302
307
private final String parent ;
303
308
private final String [] interfaces ;
309
+ private final List <Annotation > annotations ;
304
310
305
311
public ClassCodeStart (@ JsonProperty ("version" ) final int version ,
306
312
@ JsonProperty ("acc" ) final int acc ,
307
313
@ JsonProperty ("name" ) final String name ,
308
314
@ JsonProperty ("sig" ) final String sig ,
309
315
@ JsonProperty ("parent" ) final String parent ,
310
- @ JsonProperty ("interfaces" ) final String [] interfaces ) {
316
+ @ JsonProperty ("interfaces" ) final String [] interfaces ,
317
+ @ JsonProperty ("annotations" ) final List <Annotation > annotations ) {
311
318
this .version = version ;
312
319
this .acc = acc ;
313
320
this .name = name ;
314
321
this .sig = sig ;
315
322
this .parent = parent ;
316
323
this .interfaces = interfaces ;
324
+ this .annotations = annotations ;
317
325
}
318
326
319
327
public int getVersion () {
@@ -339,6 +347,10 @@ public String getParent() {
339
347
public String [] getInterfaces () {
340
348
return interfaces ;
341
349
}
350
+
351
+ public List <Annotation > getAnnotations () {
352
+ return annotations ;
353
+ }
342
354
}
343
355
344
356
public static class ClassCodeEnd extends Asm {
@@ -360,19 +372,25 @@ public static class CreateMethod extends Asm {
360
372
private final String desc ;
361
373
private final String sig ;
362
374
private final String [] excs ;
375
+ private final List <Annotation > anns ;
376
+ private final List <List <Annotation >> paramAnns ;
363
377
364
378
public CreateMethod (@ JsonProperty ("acc" ) final int acc ,
365
379
@ JsonProperty ("cname" ) final String cname ,
366
380
@ JsonProperty ("fname" ) final String fname ,
367
381
@ JsonProperty ("desc" ) final String desc ,
368
382
@ JsonProperty ("sig" ) final String sig ,
369
- @ JsonProperty ("excs" ) final String [] excs ) {
383
+ @ JsonProperty ("excs" ) final String [] excs ,
384
+ @ JsonProperty ("anns" ) final List <Annotation > anns ,
385
+ @ JsonProperty ("paramAnns" ) final List <List <Annotation >> paramAnns ) {
370
386
this .acc = acc ;
371
387
this .cname = cname ;
372
388
this .fname = fname ;
373
389
this .desc = desc ;
374
390
this .sig = sig ;
375
391
this .excs = excs ;
392
+ this .anns = anns ;
393
+ this .paramAnns = paramAnns ;
376
394
}
377
395
378
396
public int getAcc () {
@@ -398,6 +416,14 @@ public String getSig() {
398
416
public String [] getExcs () {
399
417
return excs ;
400
418
}
419
+
420
+ public List <Annotation > getAnns () {
421
+ return anns ;
422
+ }
423
+
424
+ public List <List <Annotation >> getParamAnns () {
425
+ return paramAnns ;
426
+ }
401
427
}
402
428
403
429
public static class CreateField extends Asm {
@@ -1057,4 +1083,113 @@ public int getN() {
1057
1083
return n ;
1058
1084
}
1059
1085
}
1086
+
1087
+ @ ToString
1088
+ public static class Annotation extends Asm {
1089
+ private final String name ;
1090
+ private final List <AnnotationProperty > properties ;
1091
+
1092
+ public Annotation (@ JsonProperty ("name" ) final String name ,
1093
+ @ JsonProperty ("props" ) final List <AnnotationProperty > properties ) {
1094
+ this .name = name ;
1095
+ this .properties = properties ;
1096
+ }
1097
+
1098
+ public String getName () {
1099
+ return name ;
1100
+ }
1101
+
1102
+ public List <AnnotationProperty > getProperties () {
1103
+ return properties ;
1104
+ }
1105
+ }
1106
+
1107
+ @ ToString
1108
+ public static class AnnotationProperty {
1109
+ private final String name ;
1110
+ private final AnnotationValue value ;
1111
+
1112
+ public AnnotationProperty (@ JsonProperty ("name" ) final String name ,
1113
+ @ JsonProperty ("value" ) final AnnotationValue value ) {
1114
+ this .name = name ;
1115
+ this .value = value ;
1116
+ }
1117
+
1118
+ public AnnotationValue getValue () {
1119
+ return value ;
1120
+ }
1121
+
1122
+ public String getName () {
1123
+ return name ;
1124
+ }
1125
+ }
1126
+
1127
+ @ JsonTypeInfo (
1128
+ use = JsonTypeInfo .Id .NAME ,
1129
+ include = JsonTypeInfo .As .PROPERTY ,
1130
+ property = "type" ,
1131
+ visible = true )
1132
+ @ JsonSubTypes ({
1133
+ @ JsonSubTypes .Type (value = AnnotationValue .AnnString .class , name = "AnnString" ),
1134
+ @ JsonSubTypes .Type (value = AnnotationValue .AnnInt .class , name = "AnnInt" ),
1135
+ @ JsonSubTypes .Type (value = AnnotationValue .AnnArray .class , name = "AnnArray" )
1136
+ })
1137
+ public static abstract class AnnotationValue {
1138
+ private AnnotationValueType type ;
1139
+
1140
+ private AnnotationValue () {}
1141
+
1142
+ public AnnotationValueType getType () {
1143
+ return type ;
1144
+ }
1145
+
1146
+ public void setType (final AnnotationValueType type ) {
1147
+ this .type = type ;
1148
+ }
1149
+
1150
+ public enum AnnotationValueType {
1151
+ AnnString ,
1152
+ AnnInt ,
1153
+ AnnArray
1154
+ }
1155
+
1156
+ @ ToString
1157
+ public static class AnnString extends AnnotationValue {
1158
+ private final String value ;
1159
+
1160
+ public AnnString (@ JsonProperty ("value" ) final String value ) {
1161
+ this .value = value ;
1162
+ }
1163
+
1164
+ public String getValue () {
1165
+ return value ;
1166
+ }
1167
+ }
1168
+
1169
+ @ ToString
1170
+ public static class AnnInt extends AnnotationValue {
1171
+ private final int value ;
1172
+
1173
+ public AnnInt (@ JsonProperty ("value" ) final int value ) {
1174
+ this .value = value ;
1175
+ }
1176
+
1177
+ public int getValue () {
1178
+ return value ;
1179
+ }
1180
+ }
1181
+
1182
+ @ ToString
1183
+ public static class AnnArray extends AnnotationValue {
1184
+ private final List <AnnotationValue > values ;
1185
+
1186
+ public AnnArray (@ JsonProperty ("values" ) final List <AnnotationValue > values ) {
1187
+ this .values = values ;
1188
+ }
1189
+
1190
+ public List <AnnotationValue > getValues () {
1191
+ return values ;
1192
+ }
1193
+ }
1194
+ }
1060
1195
}
0 commit comments