Skip to content

Commit ed386f7

Browse files
committed
removed deserializa by type from ArangoSerde
1 parent 957af28 commit ed386f7

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

driver/src/main/java/com/arangodb/internal/serde/InternalSerde.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ static InternalSerde of(final ContentType contentType, ArangoSerde userSerde) {
3737
*/
3838
byte[] extract(byte[] content, String jsonPointer);
3939

40+
/**
41+
* Deserializes the content and binds it to the target data type.
42+
* For data type {@link ContentType#JSON}, the byte array is the JSON string encoded using the UTF-8 charset.
43+
*
44+
* @param content byte array to deserialize
45+
* @param type target data type
46+
* @return deserialized object
47+
*/
48+
<T> T deserialize(byte[] content, Type type);
49+
4050
/**
4151
* Deserializes the parsed json node and binds it to the target data type.
4252
*

driver/src/main/java/com/arangodb/internal/serde/InternalSerdeImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ public byte[] serialize(final Object value) {
5151
}
5252
}
5353

54+
@Override
55+
public <T> T deserialize(byte[] content, Class<T> clazz) {
56+
return deserialize(content, (Type) clazz);
57+
}
58+
5459
@Override
5560
public String toJsonString(final byte[] content) {
5661
try {
@@ -125,7 +130,7 @@ public <T> T deserializeUserData(byte[] content, Type type) {
125130
if (type instanceof Class) {
126131
return deserializeUserData(content, (Class<T>) type);
127132
} else {
128-
return userSerde.deserialize(content, type);
133+
throw new UnsupportedOperationException();
129134
}
130135
}
131136

jackson-serde/src/main/java/com/arangodb/serde/jackson/internal/JacksonSerdeImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.fasterxml.jackson.databind.ObjectMapper;
77

88
import java.io.IOException;
9-
import java.lang.reflect.Type;
109
import java.util.function.Consumer;
1110

1211
/**
@@ -31,7 +30,7 @@ public byte[] serialize(final Object value) {
3130
}
3231

3332
@Override
34-
public <T> T deserialize(final byte[] content, final Type type) {
33+
public <T> T deserialize(final byte[] content, final Class<T> type) {
3534
try {
3635
return mapper.readerFor(mapper.constructType(type)).readValue(content);
3736
} catch (IOException e) {

jsonb-serde/src/main/java/com/arangodb/serde/jsonb/JsonbSerde.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import jakarta.json.bind.JsonbBuilder;
66
import jakarta.json.bind.JsonbConfig;
77

8-
import java.lang.reflect.Type;
98
import java.nio.charset.StandardCharsets;
109

1110
/**
@@ -29,7 +28,7 @@ public byte[] serialize(Object value) {
2928
}
3029

3130
@Override
32-
public <T> T deserialize(byte[] content, Type type) {
31+
public <T> T deserialize(byte[] content, Class<T> type) {
3332
return jsonb.fromJson(new String(content, StandardCharsets.UTF_8), type);
3433
}
3534

serde-api/src/main/java/com/arangodb/serde/ArangoSerde.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import com.arangodb.ContentType;
44

5-
import java.lang.reflect.Type;
6-
75
/**
86
* Contract for serialization/deserialization of user data.
97
* Implementations of this interface could be used for customizing serialization/deserialization of user related data
@@ -32,18 +30,6 @@ public interface ArangoSerde {
3230
* @param clazz class of target data type
3331
* @return deserialized object
3432
*/
35-
default <T> T deserialize(byte[] content, Class<T> clazz) {
36-
return deserialize(content, (Type) clazz);
37-
}
38-
39-
/**
40-
* Deserializes the content and binds it to the target data type.
41-
* For data type {@link ContentType#JSON}, the byte array is the JSON string encoded using the UTF-8 charset.
42-
*
43-
* @param content byte array to deserialize
44-
* @param type target data type
45-
* @return deserialized object
46-
*/
47-
<T> T deserialize(byte[] content, Type type);
33+
<T> T deserialize(byte[] content, Class<T> clazz);
4834

4935
}

0 commit comments

Comments
 (0)