Skip to content

Commit 5c6b67c

Browse files
author
mpv1989
committed
Fix docs
1 parent 2d99c6d commit 5c6b67c

File tree

1 file changed

+37
-42
lines changed

1 file changed

+37
-42
lines changed

README.md

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ ArangoDB 3.2.X
3030
<artifactId>arangodb-java-driver-async</artifactId>
3131
<version>4.2.0</version>
3232
</dependency>
33-
....
3433
</dependencies>
3534
```
3635

@@ -49,7 +48,7 @@ If you want to test with a snapshot version (e.g. 4.2.0-SNAPSHOT), add the stagi
4948

5049
```
5150
mvn clean install -DskipTests=true -Dgpg.skip=true -Dmaven.javadoc.skip=true -B
52-
```
51+
```
5352

5453
## Table of Contents
5554

@@ -259,31 +258,29 @@ ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().registerModule(new VPackJod
259258

260259
## custom serializer
261260
``` Java
262-
ArangoDBAsync arangoDB = new ArangoDBAsync.Builder()
263-
.registerDeserializer(MyObject.class, new VPackDeserializer<MyObject>() {
264-
@Override
265-
public MyObject deserialize(
266-
final VPackSlice parent,
267-
final VPackSlice vpack,
268-
final VPackDeserializationContext context) throws VPackException {
269-
270-
final MyObject obj = new MyObject();
261+
ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().registerModule(new VPackModule() {
262+
@Override
263+
public <C extends VPackSetupContext<C>> void setup(final C context) {
264+
context.registerDeserializer(MyObject.class, new VPackDeserializer<MyObject>() {
265+
@Override
266+
public MyObject deserialize(VPackSlice parent,VPackSlice vpack,
267+
VPackDeserializationContext context) throws VPackException {
268+
MyObject obj = new MyObject();
271269
obj.setName(vpack.get("name").getAsString());
272270
return obj;
273-
}
274-
}).registerSerializer(MyObject.class, new VPackSerializer<MyObject>() {
275-
@Override
276-
public void serialize(
277-
final VPackBuilder builder,
278-
final String attribute,
279-
final MyObject value,
280-
final VPackSerializationContext context) throws VPackException {
281-
271+
}
272+
});
273+
context.registerSerializer(MyObject.class, new VPackSerializer<MyObject>() {
274+
@Override
275+
public void serialize(VPackBuilder builder,String attribute,MyObject value,
276+
VPackSerializationContext context) throws VPackException {
282277
builder.add(attribute, ValueType.OBJECT);
283278
builder.add("name", value.getName());
284279
builder.close();
285-
}
286-
}).build();
280+
}
281+
});
282+
}
283+
}).build();
287284
```
288285

289286

@@ -690,31 +687,29 @@ To ignore fields at serialization/deserialization, use the annotation `Expose`
690687

691688
## custom serializer
692689
``` Java
693-
ArangoDBAsync arangoDB = new ArangoDBAsync.Builder()
694-
.registerDeserializer(MyObject.class, new VPackDeserializer<MyObject>() {
695-
@Override
696-
public MyObject deserialize(
697-
final VPackSlice parent,
698-
final VPackSlice vpack,
699-
final VPackDeserializationContext context) throws VPackException {
700-
701-
final MyObject obj = new MyObject();
690+
ArangoDBAsync arangoDB = new ArangoDBAsync.Builder().registerModule(new VPackModule() {
691+
@Override
692+
public <C extends VPackSetupContext<C>> void setup(final C context) {
693+
context.registerDeserializer(MyObject.class, new VPackDeserializer<MyObject>() {
694+
@Override
695+
public MyObject deserialize(VPackSlice parent,VPackSlice vpack,
696+
VPackDeserializationContext context) throws VPackException {
697+
MyObject obj = new MyObject();
702698
obj.setName(vpack.get("name").getAsString());
703699
return obj;
704-
}
705-
}).registerSerializer(MyObject.class, new VPackSerializer<MyObject>() {
706-
@Override
707-
public void serialize(
708-
final VPackBuilder builder,
709-
final String attribute,
710-
final MyObject value,
711-
final VPackSerializationContext context) throws VPackException {
712-
700+
}
701+
});
702+
context.registerSerializer(MyObject.class, new VPackSerializer<MyObject>() {
703+
@Override
704+
public void serialize(VPackBuilder builder,String attribute,MyObject value,
705+
VPackSerializationContext context) throws VPackException {
713706
builder.add(attribute, ValueType.OBJECT);
714707
builder.add("name", value.getName());
715708
builder.close();
716-
}
717-
}).build();
709+
}
710+
});
711+
}
712+
}).build();
718713
```
719714

720715
## manually serialization

0 commit comments

Comments
 (0)