Skip to content

Commit b692dca

Browse files
authored
Bugifx/custom serde (#308)
* CustomSerdeTest * bugfix custom serialization in aql query * bugfix custom deserialization in document APIs * bugfix custom serialization in aql query * CustomSerdeTest refactoring * bugfix custom serialization in explainQuery * test upd
1 parent ef7720a commit b692dca

File tree

6 files changed

+716
-522
lines changed

6 files changed

+716
-522
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@
219219
<artifactId>hamcrest-all</artifactId>
220220
<scope>test</scope>
221221
</dependency>
222+
<dependency>
223+
<groupId>com.arangodb</groupId>
224+
<artifactId>jackson-dataformat-velocypack</artifactId>
225+
<version>0.1.4</version>
226+
<scope>test</scope>
227+
</dependency>
222228
</dependencies>
223229

224230
<dependencyManagement>

src/main/java/com/arangodb/internal/ArangoExecutor.java

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,45 @@
2222

2323
import java.lang.reflect.Type;
2424

25+
import com.arangodb.entity.Entity;
2526
import com.arangodb.internal.util.ArangoSerializationFactory;
2627
import com.arangodb.internal.util.ArangoSerializationFactory.Serializer;
27-
import com.arangodb.util.ArangoSerialization;
2828
import com.arangodb.velocypack.exception.VPackException;
2929
import com.arangodb.velocystream.Response;
3030

3131
/**
3232
* @author Mark Vollmary
33-
*
3433
*/
3534
public abstract class ArangoExecutor {
3635

37-
public static interface ResponseDeserializer<T> {
38-
T deserialize(Response response) throws VPackException;
39-
}
36+
public static interface ResponseDeserializer<T> {
37+
T deserialize(Response response) throws VPackException;
38+
}
4039

41-
private final DocumentCache documentCache;
42-
private final ArangoSerialization util;
40+
private final DocumentCache documentCache;
41+
private final ArangoSerializationFactory util;
4342

44-
protected ArangoExecutor(final ArangoSerializationFactory util, final DocumentCache documentCache) {
45-
super();
46-
this.documentCache = documentCache;
47-
this.util = util.get(Serializer.INTERNAL);
48-
}
43+
protected ArangoExecutor(final ArangoSerializationFactory util, final DocumentCache documentCache) {
44+
super();
45+
this.documentCache = documentCache;
46+
this.util = util;
47+
}
4948

50-
public DocumentCache documentCache() {
51-
return documentCache;
52-
}
49+
public DocumentCache documentCache() {
50+
return documentCache;
51+
}
5352

54-
@SuppressWarnings("unchecked")
55-
protected <T> T createResult(final Type type, final Response response) {
56-
return (T) ((type != Void.class && response.getBody() != null) ? util.deserialize(response.getBody(), type)
57-
: null);
58-
}
53+
@SuppressWarnings("unchecked")
54+
protected <T> T createResult(final Type type, final Response response) {
55+
if (type != Void.class && response.getBody() != null) {
56+
if (type instanceof Class && Entity.class.isAssignableFrom((Class) type) ) {
57+
return (T) util.get(Serializer.INTERNAL).deserialize(response.getBody(), type);
58+
} else {
59+
return (T) util.get(Serializer.CUSTOM).deserialize(response.getBody(), type);
60+
}
61+
} else {
62+
return (T) null;
63+
}
64+
}
5965

6066
}

0 commit comments

Comments
 (0)