Skip to content

Commit 545a679

Browse files
author
mpv1989
committed
added extension point for VelocyPack serialization
1 parent a5c2260 commit 545a679

File tree

4 files changed

+84
-1
lines changed

4 files changed

+84
-1
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ v4.1.11 (2017-03-xx)
55
* fixed exception handling in Connection (issue #110)
66
* added connection pooling (issue #103)
77
* extracted VelocyPack implementation to https://github.com/arangodb/java-velocypack
8+
* added extension point for VelocyPack serialization (ArangoDB.registerModule())
89
* fixed NPE in ArangoCursor (issue #112)
910
* added support for replacing build-in VelocyPack serializer/deserializer
1011
* added ArangoDatabase.getVersion(), ArangoDatabase.getAccessibleDatabases()

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,57 @@ If you want to test with a snapshot version (e.g. 4.0.0-SNAPSHOT), add the stagi
5454
mvn clean install -DskipTests=true -Dgpg.skip=true -Dmaven.javadoc.skip=true -B
5555
```
5656

57+
## configure VelocyPack serialization
58+
59+
Since version `4.1.11` you can extend the VelocyPack serialization by registering additional `VPackModule`s on `ArangoDB.Builder`.
60+
61+
### Java 8 types
62+
63+
Added support for:
64+
* java.time.Instant
65+
* java.time.LocalDate
66+
* java.time.LocalDateTime
67+
* java.util.Optional;
68+
* java.util.OptionalDouble;
69+
* java.util.OptionalInt;
70+
* java.util.OptionalLong;
71+
72+
```XML
73+
<dependencies>
74+
<dependency>
75+
<groupId>com.arangodb</groupId>
76+
<artifactId>velocypack-module-jdk8</artifactId>
77+
<version>1.0.1</version>
78+
</dependency>
79+
</dependencies>
80+
```
81+
82+
``` Java
83+
ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackJdk8Module()).build();
84+
```
85+
86+
### Joda-Time
87+
88+
Added support for:
89+
* org.joda.time.DateTime;
90+
* org.joda.time.Instant;
91+
* org.joda.time.LocalDate;
92+
* org.joda.time.LocalDateTime;
93+
94+
```XML
95+
<dependencies>
96+
<dependency>
97+
<groupId>com.arangodb</groupId>
98+
<artifactId>velocypack-module-joda</artifactId>
99+
<version>1.0.0</version>
100+
</dependency>
101+
</dependencies>
102+
```
103+
104+
``` Java
105+
ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackJodaModule()).build();
106+
```
107+
57108
# Learn more
58109
* [ArangoDB](https://www.arangodb.com/)
59110
* [ChangeLog](ChangeLog)

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<logback-classic.version>1.1.3</logback-classic.version>
2828
<hamcrest-all.version>1.3</hamcrest-all.version>
2929
<junit.version>4.12</junit.version>
30-
<arangodb.velocypack.version>1.0.1</arangodb.velocypack.version>
30+
<arangodb.velocypack.version>1.0.2</arangodb.velocypack.version>
3131
</properties>
3232

3333
<developers>

src/main/java/com/arangodb/ArangoDB.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import com.arangodb.velocypack.VPackJsonSerializer;
6666
import com.arangodb.velocypack.VPackModule;
6767
import com.arangodb.velocypack.VPackParser;
68+
import com.arangodb.velocypack.VPackParserModule;
6869
import com.arangodb.velocypack.VPackSerializer;
6970
import com.arangodb.velocypack.ValueType;
7071
import com.arangodb.velocypack.exception.VPackException;
@@ -280,11 +281,41 @@ public Builder registerModules(final VPackModule... modules) {
280281
return this;
281282
}
282283

284+
public Builder registerJsonModule(final VPackParserModule module) {
285+
vpackParserBuilder.registerModule(module);
286+
return this;
287+
}
288+
289+
public Builder registerJsonModules(final VPackParserModule... module) {
290+
vpackParserBuilder.registerModules(module);
291+
return this;
292+
}
293+
294+
/**
295+
* Replace the built-in serializer with the given serializer.
296+
*
297+
* <br />
298+
* <b>ATTENTION!:</b> Use at your own risk
299+
*
300+
* @param serializer
301+
* custom serializer
302+
* @return builder
303+
*/
283304
public Builder setSerializer(final ArangoSerializer serializer) {
284305
this.serializer = serializer;
285306
return this;
286307
}
287308

309+
/**
310+
* Replace the built-in deserializer with the given deserializer.
311+
*
312+
* <br />
313+
* <b>ATTENTION!:</b> Use at your own risk
314+
*
315+
* @param deserializer
316+
* custom deserializer
317+
* @return builder
318+
*/
288319
public Builder setDeserializer(final ArangoDeserializer deserializer) {
289320
this.deserializer = deserializer;
290321
return this;

0 commit comments

Comments
 (0)