Skip to content

Commit 3fe59b9

Browse files
author
mpv1989
committed
Fix docs
1 parent 704e365 commit 3fe59b9

File tree

1 file changed

+37
-43
lines changed

1 file changed

+37
-43
lines changed

README.md

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ ArangoDB 3.x.x
3838
<artifactId>arangodb-java-driver</artifactId>
3939
<version>4.2.0</version>
4040
</dependency>
41-
....
4241
</dependencies>
4342
```
4443

@@ -57,8 +56,7 @@ If you want to test with a snapshot version (e.g. 4.2.0-SNAPSHOT), add the stagi
5756

5857
```
5958
mvn clean install -DskipTests=true -Dgpg.skip=true -Dmaven.javadoc.skip=true -B
60-
```
61-
59+
```
6260

6361
## Table of Contents
6462

@@ -269,31 +267,29 @@ ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackJodaModule())
269267

270268
## custom serializer
271269
``` Java
272-
ArangoDB arangoDB = new ArangoDB.Builder()
273-
.registerDeserializer(MyObject.class, new VPackDeserializer<MyObject>() {
274-
@Override
275-
public MyObject deserialize(
276-
final VPackSlice parent,
277-
final VPackSlice vpack,
278-
final VPackDeserializationContext context) throws VPackException {
279-
280-
final MyObject obj = new MyObject();
270+
ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackModule() {
271+
@Override
272+
public <C extends VPackSetupContext<C>> void setup(final C context) {
273+
context.registerDeserializer(MyObject.class, new VPackDeserializer<MyObject>() {
274+
@Override
275+
public MyObject deserialize(VPackSlice parent,VPackSlice vpack,
276+
VPackDeserializationContext context) throws VPackException {
277+
MyObject obj = new MyObject();
281278
obj.setName(vpack.get("name").getAsString());
282279
return obj;
283-
}
284-
}).registerSerializer(MyObject.class, new VPackSerializer<MyObject>() {
285-
@Override
286-
public void serialize(
287-
final VPackBuilder builder,
288-
final String attribute,
289-
final MyObject value,
290-
final VPackSerializationContext context) throws VPackException {
291-
280+
}
281+
});
282+
context.registerSerializer(MyObject.class, new VPackSerializer<MyObject>() {
283+
@Override
284+
public void serialize(VPackBuilder builder,String attribute,MyObject value,
285+
VPackSerializationContext context) throws VPackException {
292286
builder.add(attribute, ValueType.OBJECT);
293287
builder.add("name", value.getName());
294288
builder.close();
295-
}
296-
}).build();
289+
}
290+
});
291+
}
292+
}).build();
297293
```
298294

299295

@@ -698,31 +694,29 @@ To ignore fields at serialization/deserialization, use the annotation `Expose`
698694

699695
## custom serializer
700696
``` Java
701-
ArangoDB arangoDB = new ArangoDB.Builder()
702-
.registerDeserializer(MyObject.class, new VPackDeserializer<MyObject>() {
703-
@Override
704-
public MyObject deserialize(
705-
final VPackSlice parent,
706-
final VPackSlice vpack,
707-
final VPackDeserializationContext context) throws VPackException {
708-
709-
final MyObject obj = new MyObject();
697+
ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackModule() {
698+
@Override
699+
public <C extends VPackSetupContext<C>> void setup(final C context) {
700+
context.registerDeserializer(MyObject.class, new VPackDeserializer<MyObject>() {
701+
@Override
702+
public MyObject deserialize(VPackSlice parent,VPackSlice vpack,
703+
VPackDeserializationContext context) throws VPackException {
704+
MyObject obj = new MyObject();
710705
obj.setName(vpack.get("name").getAsString());
711706
return obj;
712-
}
713-
}).registerSerializer(MyObject.class, new VPackSerializer<MyObject>() {
714-
@Override
715-
public void serialize(
716-
final VPackBuilder builder,
717-
final String attribute,
718-
final MyObject value,
719-
final VPackSerializationContext context) throws VPackException {
720-
707+
}
708+
});
709+
context.registerSerializer(MyObject.class, new VPackSerializer<MyObject>() {
710+
@Override
711+
public void serialize(VPackBuilder builder,String attribute,MyObject value,
712+
VPackSerializationContext context) throws VPackException {
721713
builder.add(attribute, ValueType.OBJECT);
722714
builder.add("name", value.getName());
723715
builder.close();
724-
}
725-
}).build();
716+
}
717+
});
718+
}
719+
}).build();
726720
```
727721

728722
## manually serialization

0 commit comments

Comments
 (0)