11package com .aerospike .mapper .tools .converters ;
22
3- import java .util .ArrayList ;
4- import java .util .Iterator ;
5- import java .util .List ;
6- import java .util .Map ;
7-
8- import javax .validation .constraints .NotNull ;
9-
103import com .aerospike .client .AerospikeException ;
114import com .aerospike .client .IAerospikeClient ;
125import com .aerospike .client .Key ;
2417import com .aerospike .mapper .tools .utils .MapperUtils ;
2518import com .aerospike .mapper .tools .utils .TypeUtils ;
2619
20+ import javax .validation .constraints .NotNull ;
21+ import java .util .ArrayList ;
22+ import java .util .Iterator ;
23+ import java .util .List ;
24+ import java .util .Map ;
25+
2726public class MappingConverter {
2827
2928 private final IBaseAeroMapper mapper ;
@@ -76,14 +75,9 @@ public <T> T translateFromAerospike(@NotNull Object obj, @NotNull Class<T> expec
7675 * @param clazz The class type to convert the Aerospike record to.
7776 * @param record The Aerospike record to convert.
7877 * @return A virtual list.
79- * @throws AerospikeException an AerospikeException will be thrown in case of an encountering a ReflectiveOperationException.
8078 */
8179 public <T > T convertToObject (Class <T > clazz , Key key , Record record ) {
82- try {
83- return convertToObject (clazz , key , record , null );
84- } catch (ReflectiveOperationException e ) {
85- throw new AerospikeException (e );
86- }
80+ return convertToObject (clazz , key , record , null );
8781 }
8882
8983 /**
@@ -94,16 +88,15 @@ public <T> T convertToObject(Class<T> clazz, Key key, Record record) {
9488 * @param record The Aerospike record to convert.
9589 * @param entry The entry that holds information on how to store the provided class.
9690 * @return A virtual list.
97- * @throws AerospikeException an AerospikeException will be thrown in case of an encountering a ReflectiveOperationException.
9891 */
99- public <T > T convertToObject (Class <T > clazz , Key key , Record record , ClassCacheEntry <T > entry ) throws ReflectiveOperationException {
92+ public <T > T convertToObject (Class <T > clazz , Key key , Record record , ClassCacheEntry <T > entry ) {
10093 return this .convertToObject (clazz , key , record , entry , true );
10194 }
10295
10396 /**
10497 * This method should not be used, it is public only to allow mappers to see it.
10598 */
106- public <T > T convertToObject (Class <T > clazz , Key key , Record record , ClassCacheEntry <T > entry , boolean resolveDependencies ) throws ReflectiveOperationException {
99+ public <T > T convertToObject (Class <T > clazz , Key key , Record record , ClassCacheEntry <T > entry , boolean resolveDependencies ) {
107100 if (entry == null ) {
108101 entry = ClassCache .getInstance ().loadClass (clazz , mapper );
109102 }
@@ -252,10 +245,14 @@ public void resolveDependencies(ClassCacheEntry<?> parentEntity) {
252245 DeferredObjectLoader .DeferredObjectSetter thisObjectSetter = deferredObjects .get (i );
253246 try {
254247 ThreadLocalKeySaver .save (keys [i ]);
255- Object result = records [i ] == null ? null : convertToObject ((Class ) thisObjectSetter .getObject ().getType (), keys [i ], records [i ], classCacheEntryList .get (i ), false );
248+ Object obj = convertToObject (
249+ (Class <Object >) thisObjectSetter .getObject ().getType (),
250+ keys [i ],
251+ records [i ],
252+ (ClassCacheEntry <Object >) classCacheEntryList .get (i ),
253+ false );
254+ Object result = records [i ] == null ? null : obj ;
256255 thisObjectSetter .getSetter ().setValue (result );
257- } catch (ReflectiveOperationException e ) {
258- throw new AerospikeException (e );
259256 } finally {
260257 ThreadLocalKeySaver .clear ();
261258 }
0 commit comments