9
9
10
10
class ReflectionObjectDecoder {
11
11
12
- private static Object NOT_SET = new Object () {
12
+ protected static Object NOT_SET = new Object () {
13
13
@ Override
14
14
public String toString () {
15
15
return "NOT_SET" ;
16
16
}
17
17
};
18
- private Map <Slice , Binding > allBindings = new HashMap <Slice , Binding >();
19
- private String tempCacheKey ;
20
- private String ctorArgsCacheKey ;
21
- private int tempCount ;
22
- private long expectedTracker ;
23
- private int requiredIdx ;
24
- private int tempIdx ;
25
- private ClassDescriptor desc ;
18
+ protected Map <Slice , Binding > allBindings = new HashMap <Slice , Binding >();
19
+ protected String tempCacheKey ;
20
+ protected String ctorArgsCacheKey ;
21
+ protected int tempCount ;
22
+ protected long expectedTracker ;
23
+ protected int requiredIdx ;
24
+ protected int tempIdx ;
25
+ protected ClassDescriptor desc ;
26
26
27
27
public ReflectionObjectDecoder (ClassInfo classInfo ) {
28
28
try {
@@ -34,7 +34,9 @@ public ReflectionObjectDecoder(ClassInfo classInfo) {
34
34
}
35
35
}
36
36
37
- private final void init (ClassInfo classInfo ) throws Exception {
37
+ protected final void init (ClassInfo classInfo ) throws Exception {
38
+
39
+ System .out .println ("INIT" );
38
40
Class clazz = classInfo .clazz ;
39
41
ClassDescriptor desc = ClassDescriptor .getDecodingClassDescriptor (classInfo , true );
40
42
for (Binding param : desc .ctor .parameters ) {
@@ -116,6 +118,7 @@ public class OnlyField implements Decoder {
116
118
117
119
public Object decode (JsonIterator iter ) throws IOException {
118
120
try {
121
+ System .out .println ("ONLY FIELD" );
119
122
return decode_ (iter );
120
123
} catch (RuntimeException e ) {
121
124
throw e ;
@@ -181,6 +184,7 @@ public class WithCtor implements Decoder {
181
184
@ Override
182
185
public Object decode (JsonIterator iter ) throws IOException {
183
186
try {
187
+ System .out .println ("WITH CTOR" );
184
188
return decode_ (iter );
185
189
} catch (RuntimeException e ) {
186
190
throw e ;
@@ -260,6 +264,7 @@ public class WithWrapper implements Decoder {
260
264
@ Override
261
265
public Object decode (JsonIterator iter ) throws IOException {
262
266
try {
267
+ System .out .println ("WITH WRAPPER" );
263
268
return decode_ (iter );
264
269
} catch (RuntimeException e ) {
265
270
throw e ;
@@ -346,7 +351,7 @@ private void setToBinding(Object obj, Binding binding, Object value) throws Exce
346
351
}
347
352
}
348
353
349
- private void setExtra (Object obj , Map <String , Object > extra ) throws Exception {
354
+ protected void setExtra (Object obj , Map <String , Object > extra ) throws Exception {
350
355
if (extra == null ) {
351
356
return ;
352
357
}
@@ -367,24 +372,24 @@ private void setExtra(Object obj, Map<String, Object> extra) throws Exception {
367
372
}
368
373
}
369
374
370
- private boolean canNotSetDirectly (Binding binding ) {
375
+ protected boolean canNotSetDirectly (Binding binding ) {
371
376
return binding .field == null && binding .method == null ;
372
377
}
373
378
374
- private Object decodeBinding (JsonIterator iter , Binding binding ) throws Exception {
379
+ protected Object decodeBinding (JsonIterator iter , Binding binding ) throws Exception {
375
380
Object value ;
376
381
value = binding .decoder .decode (iter );
377
382
return value ;
378
383
}
379
384
380
- private Object decodeBinding (JsonIterator iter , Object obj , Binding binding ) throws Exception {
385
+ protected Object decodeBinding (JsonIterator iter , Object obj , Binding binding ) throws Exception {
381
386
if (binding .valueCanReuse ) {
382
387
CodegenAccess .setExistingObject (iter , binding .field .get (obj ));
383
388
}
384
389
return decodeBinding (iter , binding );
385
390
}
386
391
387
- private Map <String , Object > onUnknownProperty (JsonIterator iter , Slice fieldName , Map <String , Object > extra ) throws IOException {
392
+ protected Map <String , Object > onUnknownProperty (JsonIterator iter , Slice fieldName , Map <String , Object > extra ) throws IOException {
388
393
boolean shouldReadValue = desc .asExtraForUnknownProperties || !desc .keyValueTypeWrappers .isEmpty ();
389
394
if (shouldReadValue ) {
390
395
Any value = iter .readAny ();
@@ -398,7 +403,7 @@ private Map<String, Object> onUnknownProperty(JsonIterator iter, Slice fieldName
398
403
return extra ;
399
404
}
400
405
401
- private List <String > collectMissingFields (long tracker ) {
406
+ protected List <String > collectMissingFields (long tracker ) {
402
407
List <String > missingFields = new ArrayList <String >();
403
408
for (Binding binding : allBindings .values ()) {
404
409
if (binding .asMissingWhenNotPresent ) {
@@ -409,7 +414,7 @@ private List<String> collectMissingFields(long tracker) {
409
414
return missingFields ;
410
415
}
411
416
412
- private void applyWrappers (Object [] temp , Object obj ) throws Exception {
417
+ protected void applyWrappers (Object [] temp , Object obj ) throws Exception {
413
418
for (WrapperDescriptor wrapper : desc .bindingTypeWrappers ) {
414
419
Object [] args = new Object [wrapper .parameters .size ()];
415
420
for (int i = 0 ; i < wrapper .parameters .size (); i ++) {
@@ -422,7 +427,7 @@ private void applyWrappers(Object[] temp, Object obj) throws Exception {
422
427
}
423
428
}
424
429
425
- private Object createNewObject (JsonIterator iter , Object [] temp ) throws Exception {
430
+ protected Object createNewObject (JsonIterator iter , Object [] temp ) throws Exception {
426
431
if (iter .tempObjects == null ) {
427
432
iter .tempObjects = new HashMap <String , Object >();
428
433
}
0 commit comments