1
1
package com .aerospike .mapper .tools .converters ;
2
2
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
-
10
3
import com .aerospike .client .AerospikeException ;
11
4
import com .aerospike .client .IAerospikeClient ;
12
5
import com .aerospike .client .Key ;
24
17
import com .aerospike .mapper .tools .utils .MapperUtils ;
25
18
import com .aerospike .mapper .tools .utils .TypeUtils ;
26
19
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
+
27
26
public class MappingConverter {
28
27
29
28
private final IBaseAeroMapper mapper ;
@@ -76,14 +75,9 @@ public <T> T translateFromAerospike(@NotNull Object obj, @NotNull Class<T> expec
76
75
* @param clazz The class type to convert the Aerospike record to.
77
76
* @param record The Aerospike record to convert.
78
77
* @return A virtual list.
79
- * @throws AerospikeException an AerospikeException will be thrown in case of an encountering a ReflectiveOperationException.
80
78
*/
81
79
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 );
87
81
}
88
82
89
83
/**
@@ -94,16 +88,15 @@ public <T> T convertToObject(Class<T> clazz, Key key, Record record) {
94
88
* @param record The Aerospike record to convert.
95
89
* @param entry The entry that holds information on how to store the provided class.
96
90
* @return A virtual list.
97
- * @throws AerospikeException an AerospikeException will be thrown in case of an encountering a ReflectiveOperationException.
98
91
*/
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 ) {
100
93
return this .convertToObject (clazz , key , record , entry , true );
101
94
}
102
95
103
96
/**
104
97
* This method should not be used, it is public only to allow mappers to see it.
105
98
*/
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 ) {
107
100
if (entry == null ) {
108
101
entry = ClassCache .getInstance ().loadClass (clazz , mapper );
109
102
}
@@ -252,10 +245,14 @@ public void resolveDependencies(ClassCacheEntry<?> parentEntity) {
252
245
DeferredObjectLoader .DeferredObjectSetter thisObjectSetter = deferredObjects .get (i );
253
246
try {
254
247
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 ;
256
255
thisObjectSetter .getSetter ().setValue (result );
257
- } catch (ReflectiveOperationException e ) {
258
- throw new AerospikeException (e );
259
256
} finally {
260
257
ThreadLocalKeySaver .clear ();
261
258
}
0 commit comments