1
1
package com .arangodb .velocypack ;
2
2
3
3
import java .lang .reflect .Array ;
4
- import java .lang .reflect .Field ;
5
4
import java .lang .reflect .InvocationTargetException ;
6
5
import java .math .BigDecimal ;
7
6
import java .math .BigInteger ;
@@ -212,9 +211,8 @@ private void deserializeField(final VPackSlice vpack, final Object entity, final
212
211
VPackException {
213
212
final VPackSlice attr = new VPackSlice (vpack .getVpack (), vpack .getStart () + vpack .getByteSize ());
214
213
if (!attr .isNone ()) {
215
- final Field field = fieldInfo .getField ();
216
- final Object value = getValue (attr , field .getType (), fieldInfo );
217
- field .set (entity , value );
214
+ final Object value = getValue (attr , fieldInfo .getType (), fieldInfo );
215
+ fieldInfo .set (entity , value );
218
216
}
219
217
}
220
218
@@ -366,14 +364,12 @@ private void serializeField(final Object entity, final VPackBuilder builder, fin
366
364
throws NoSuchMethodException , IllegalAccessException , InvocationTargetException , VPackException {
367
365
368
366
final String fieldName = fieldInfo .getFieldName ();
369
- final Field field = fieldInfo .getField ();
370
- final Class <?> type = field .getType ();
371
- final Object value = field .get (entity );
372
- addValue (field , fieldName , type , value , builder , fieldInfo );
367
+ final Class <?> type = fieldInfo .getType ();
368
+ final Object value = fieldInfo .get (entity );
369
+ addValue (fieldName , type , value , builder , fieldInfo );
373
370
}
374
371
375
372
private void addValue (
376
- final Field field ,
377
373
final String name ,
378
374
final Class <?> type ,
379
375
final Object value ,
@@ -394,7 +390,7 @@ private void addValue(
394
390
} else if (Iterable .class .isAssignableFrom (type )) {
395
391
serializeIterable (name , value , builder );
396
392
} else if (Map .class .isAssignableFrom (type )) {
397
- serializeMap (name , type , value , builder , fieldInfo );
393
+ serializeMap (name , value , builder , fieldInfo );
398
394
} else {
399
395
serializeObject (name , value , builder );
400
396
}
@@ -407,7 +403,7 @@ private void serializeArray(final String name, final Object value, final VPackBu
407
403
builder .add (name , new Value (ValueType .ARRAY ));
408
404
for (int i = 0 ; i < Array .getLength (value ); i ++) {
409
405
final Object element = Array .get (value , i );
410
- addValue (null , null , element .getClass (), element , builder , null );
406
+ addValue (null , element .getClass (), element , builder , null );
411
407
}
412
408
builder .close ();
413
409
}
@@ -417,14 +413,13 @@ private void serializeIterable(final String name, final Object value, final VPac
417
413
builder .add (name , new Value (ValueType .ARRAY ));
418
414
for (final Iterator iterator = Iterable .class .cast (value ).iterator (); iterator .hasNext ();) {
419
415
final Object element = iterator .next ();
420
- addValue (null , null , element .getClass (), element , builder , null );
416
+ addValue (null , element .getClass (), element , builder , null );
421
417
}
422
418
builder .close ();
423
419
}
424
420
425
421
private void serializeMap (
426
422
final String name ,
427
- final Class <?> type ,
428
423
final Object value ,
429
424
final VPackBuilder builder ,
430
425
final FieldInfo fieldInfo )
@@ -436,17 +431,16 @@ private void serializeMap(
436
431
builder .add (name , new Value (ValueType .OBJECT ));
437
432
final Set <Entry <?, ?>> entrySet = map .entrySet ();
438
433
for (final Entry <?, ?> entry : entrySet ) {
439
- addValue (null , keyToString (entry .getKey ()), entry .getValue ().getClass (), entry .getValue (), builder ,
440
- null );
434
+ addValue (keyToString (entry .getKey ()), entry .getValue ().getClass (), entry .getValue (), builder , null );
441
435
}
442
436
builder .close ();
443
437
} else {
444
438
builder .add (name , new Value (ValueType .ARRAY ));
445
439
final Set <Entry <?, ?>> entrySet = map .entrySet ();
446
440
for (final Entry <?, ?> entry : entrySet ) {
447
441
builder .add (null , new Value (ValueType .OBJECT ));
448
- addValue (null , ATTR_KEY , entry .getKey ().getClass (), entry .getKey (), builder , null );
449
- addValue (null , ATTR_VALUE , entry .getValue ().getClass (), entry .getValue (), builder , null );
442
+ addValue (ATTR_KEY , entry .getKey ().getClass (), entry .getKey (), builder , null );
443
+ addValue (ATTR_VALUE , entry .getValue ().getClass (), entry .getValue (), builder , null );
450
444
builder .close ();
451
445
}
452
446
builder .close ();
0 commit comments