Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.

Commit 8b91fc7

Browse files
author
mpv1989
committed
initial commit
1 parent 97d5da3 commit 8b91fc7

File tree

9 files changed

+580
-17
lines changed

9 files changed

+580
-17
lines changed

.gitignore

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
*.class
2-
*.log
3-
4-
# sbt specific
5-
.cache
6-
.history
7-
.lib/
8-
dist/*
9-
target/
10-
lib_managed/
11-
src_managed/
12-
project/boot/
13-
project/plugins/project/
14-
15-
# Scala-IDE specific
16-
.scala_dependencies
17-
.worksheet
1+
*.class
2+
*.log
3+
4+
# sbt specific
5+
.cache
6+
.history
7+
.lib/
8+
dist/*
9+
target/
10+
lib_managed/
11+
src_managed/
12+
project/boot/
13+
project/plugins/project/
14+
15+
# Scala-IDE specific
16+
.scala_dependencies
17+
.worksheet
18+
19+
.cache-main
20+
.cache-tests
21+
22+
/bin
23+
/.classpath
24+
/.project
25+
/.settings
26+
/target
27+
/.idea
28+
/*.iml

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
![ArangoDB-Logo](https://docs.arangodb.com/assets/arangodb_logo_2016_inverted.png)
3+
4+
# ArangoDB VelocyPack Java Module Scala
5+
6+
Scala module for [Java VelocyPack](https://github.com/arangodb/java-velocypack).
7+
8+
Added support for:
9+
* scala.Option
10+
* scala.collection.immutable.List
11+
* scala.collection.immutable.Map
12+
13+
14+
## Maven
15+
16+
To add the dependency to your project with maven, add the following code to your pom.xml:
17+
18+
```XML
19+
<dependencies>
20+
<dependency>
21+
<groupId>com.arangodb</groupId>
22+
<artifactId>velocypack-module-scala</artifactId>
23+
<version>1.0.0</version>
24+
</dependency>
25+
</dependencies>
26+
```
27+
28+
If you want to test with a snapshot version (e.g. 1.0.0-SNAPSHOT), add the staging repository of oss.sonatype.org to your pom.xml:
29+
30+
```XML
31+
<repositories>
32+
<repository>
33+
<id>arangodb-snapshots</id>
34+
<url>https://oss.sonatype.org/content/groups/staging</url>
35+
</repository>
36+
</repositories>
37+
```
38+
39+
## Compile
40+
41+
```
42+
mvn clean install
43+
```
44+
45+
## Usage / registering module
46+
47+
``` Scala
48+
val vpack: VPack = new VPack.Builder().registerModule(new VPackScalaModule).build
49+
```

pom.xml

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.arangodb</groupId>
6+
<artifactId>java-velocypack-module-scala</artifactId>
7+
<version>1.0.0-SNAPSHOT</version>
8+
<inceptionYear>2017</inceptionYear>
9+
<packaging>jar</packaging>
10+
11+
<name>ArangoDB Velocypack Module Scala</name>
12+
<description>ArangoDB Velocypack Module for Scala</description>
13+
<url>http://maven.apache.org</url>
14+
15+
<licenses>
16+
<license>
17+
<name>Apache License 2.0</name>
18+
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
19+
<distribution>repo</distribution>
20+
</license>
21+
</licenses>
22+
23+
<properties>
24+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
25+
<arangodb.velocypack.version>1.0.3</arangodb.velocypack.version>
26+
</properties>
27+
28+
<developers>
29+
<developer>
30+
<id>mpv1989</id>
31+
<name>Mark</name>
32+
<url>https://github.com/mpv1989</url>
33+
</developer>
34+
</developers>
35+
36+
<distributionManagement>
37+
<snapshotRepository>
38+
<id>ossrh</id>
39+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
40+
</snapshotRepository>
41+
<repository>
42+
<id>ossrh</id>
43+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
44+
</repository>
45+
</distributionManagement>
46+
47+
<repositories>
48+
<repository>
49+
<id>arangodb-snapshots</id>
50+
<url>https://oss.sonatype.org/content/groups/staging</url>
51+
</repository>
52+
</repositories>
53+
54+
<build>
55+
<plugins>
56+
<plugin>
57+
<groupId>org.sonatype.plugins</groupId>
58+
<artifactId>nexus-staging-maven-plugin</artifactId>
59+
<version>1.6.5</version>
60+
<extensions>true</extensions>
61+
<configuration>
62+
<serverId>ossrh</serverId>
63+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
64+
<stagingProfileId>84aff6e87e214c</stagingProfileId>
65+
<autoReleaseAfterClose>false</autoReleaseAfterClose>
66+
</configuration>
67+
</plugin>
68+
<plugin>
69+
<groupId>org.apache.maven.plugins</groupId>
70+
<artifactId>maven-compiler-plugin</artifactId>
71+
<configuration>
72+
<source>1.8</source>
73+
<target>1.8</target>
74+
<skipMain>true</skipMain> <!-- skip compile -->
75+
<skip>true</skip> <!-- skip testCompile -->
76+
</configuration>
77+
</plugin>
78+
<plugin>
79+
<groupId>com.google.code.sbt-compiler-maven-plugin</groupId>
80+
<artifactId>sbt-compiler-maven-plugin</artifactId>
81+
<version>1.0.0-beta9</version>
82+
<configuration>
83+
<scalaVersion>2.11.8</scalaVersion>
84+
</configuration>
85+
<executions>
86+
<execution>
87+
<id>default-sbt-compile</id>
88+
<goals>
89+
<goal>addScalaSources</goal>
90+
<goal>compile</goal>
91+
<goal>testCompile</goal>
92+
</goals>
93+
</execution>
94+
</executions>
95+
</plugin>
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-resources-plugin</artifactId>
99+
<version>2.7</version>
100+
<configuration>
101+
<encoding>UTF-8</encoding>
102+
</configuration>
103+
</plugin>
104+
<plugin>
105+
<groupId>org.apache.maven.plugins</groupId>
106+
<artifactId>maven-source-plugin</artifactId>
107+
<version>2.4</version>
108+
<executions>
109+
<execution>
110+
<goals>
111+
<goal>jar</goal>
112+
</goals>
113+
</execution>
114+
</executions>
115+
</plugin>
116+
<!-- empty javadoc to publish on maven central repository -->
117+
<plugin>
118+
<groupId>org.apache.maven.plugins</groupId>
119+
<artifactId>maven-jar-plugin</artifactId>
120+
<executions>
121+
<execution>
122+
<id>empty-javadoc-jar</id>
123+
<phase>package</phase>
124+
<goals>
125+
<goal>jar</goal>
126+
</goals>
127+
<configuration>
128+
<classifier>javadoc</classifier>
129+
<classesDirectory>${basedir}/javadoc</classesDirectory>
130+
</configuration>
131+
</execution>
132+
</executions>
133+
</plugin>
134+
<plugin>
135+
<artifactId>maven-deploy-plugin</artifactId>
136+
<version>2.8.2</version>
137+
<configuration>
138+
<uniqueVersion>false</uniqueVersion>
139+
<retryFailedDeploymentCount>10</retryFailedDeploymentCount>
140+
</configuration>
141+
</plugin>
142+
<plugin>
143+
<groupId>org.apache.maven.plugins</groupId>
144+
<artifactId>maven-gpg-plugin</artifactId>
145+
<version>1.5</version>
146+
<executions>
147+
<execution>
148+
<id>sign-artifacts</id>
149+
<phase>verify</phase>
150+
<goals>
151+
<goal>sign</goal>
152+
</goals>
153+
</execution>
154+
</executions>
155+
</plugin>
156+
<plugin>
157+
<groupId>org.apache.maven.plugins</groupId>
158+
<artifactId>maven-surefire-plugin</artifactId>
159+
<version>2.19.1</version>
160+
</plugin>
161+
<plugin>
162+
<groupId>org.scalatest</groupId>
163+
<artifactId>scalatest-maven-plugin</artifactId>
164+
<version>1.0</version>
165+
<configuration>
166+
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
167+
</configuration>
168+
<executions>
169+
<execution>
170+
<goals>
171+
<goal>test</goal>
172+
</goals>
173+
</execution>
174+
</executions>
175+
</plugin>
176+
</plugins>
177+
</build>
178+
179+
<dependencies>
180+
<dependency>
181+
<groupId>com.arangodb</groupId>
182+
<artifactId>velocypack</artifactId>
183+
</dependency>
184+
<dependency>
185+
<groupId>org.scalatest</groupId>
186+
<artifactId>scalatest_2.11</artifactId>
187+
<scope>test</scope>
188+
</dependency>
189+
<dependency>
190+
<groupId>junit</groupId>
191+
<artifactId>junit</artifactId>
192+
<scope>test</scope>
193+
</dependency>
194+
<dependency>
195+
<groupId>org.hamcrest</groupId>
196+
<artifactId>hamcrest-all</artifactId>
197+
<scope>test</scope>
198+
</dependency>
199+
</dependencies>
200+
201+
<dependencyManagement>
202+
<dependencies>
203+
<dependency>
204+
<groupId>com.arangodb</groupId>
205+
<artifactId>velocypack</artifactId>
206+
<version>${arangodb.velocypack.version}</version>
207+
</dependency>
208+
<dependency>
209+
<groupId>org.scalatest</groupId>
210+
<artifactId>scalatest_2.11</artifactId>
211+
<version>3.0.0</version>
212+
</dependency>
213+
<dependency>
214+
<groupId>junit</groupId>
215+
<artifactId>junit</artifactId>
216+
<version>4.12</version>
217+
</dependency>
218+
<dependency>
219+
<groupId>org.hamcrest</groupId>
220+
<artifactId>hamcrest-all</artifactId>
221+
<version>1.3</version>
222+
</dependency>
223+
</dependencies>
224+
</dependencyManagement>
225+
226+
<scm>
227+
<url>https://github.com/arangodb/arangodb-spark-connector</url>
228+
<connection>scm:git:git://github.com/arangodb/arangodb-spark-connector.git</connection>
229+
<developerConnection>scm:git:git://github.com/arangodb/arangodb-spark-connector.git</developerConnection>
230+
</scm>
231+
232+
<organization>
233+
<name>ArangoDB GmbH</name>
234+
<url>https://www.arangodb.com</url>
235+
</organization>
236+
237+
</project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.arangodb.velocypack.module.scala
2+
3+
import com.arangodb.velocypack.VPackModule
4+
import com.arangodb.velocypack.VPackSetupContext
5+
import com.arangodb.velocypack.module.scala.internal.VPackScalaSerializers
6+
import com.arangodb.velocypack.module.scala.internal.VPackScalaDeserializers
7+
import com.arangodb.velocypack.VPackInstanceCreator
8+
9+
class VPackScalaModule extends VPackModule {
10+
11+
def setup[C <: VPackSetupContext[C]](context: C): Unit = {
12+
context.registerDeserializer(classOf[Option[Any]], VPackScalaDeserializers.OPTION)
13+
context.registerDeserializer(classOf[List[Any]], VPackScalaDeserializers.LIST)
14+
context.registerDeserializer(classOf[Map[Any, Any]], VPackScalaDeserializers.MAP)
15+
16+
context.registerSerializer(classOf[Option[Any]], VPackScalaSerializers.OPTION)
17+
context.registerSerializer(classOf[List[Any]], VPackScalaSerializers.LIST)
18+
context.registerSerializer(classOf[Map[Any, Any]], VPackScalaSerializers.MAP)
19+
context.registerEnclosingSerializer(classOf[Map[Any, Any]], VPackScalaSerializers.MAP)
20+
}
21+
22+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.arangodb.velocypack.module.scala.internal
2+
3+
import com.arangodb.velocypack.VPackDeserializer
4+
import com.arangodb.velocypack.VPackDeserializationContext
5+
import com.arangodb.velocypack.VPackSlice
6+
import com.arangodb.velocypack.VPackDeserializerParameterizedType
7+
import java.lang.reflect.ParameterizedType
8+
import scala.collection.JavaConversions._
9+
import scala.collection.JavaConverters._
10+
11+
object VPackScalaDeserializers {
12+
13+
val OPTION = new VPackDeserializerParameterizedType[Option[Any]] {
14+
def deserialize(parent: VPackSlice, vpack: VPackSlice, context: VPackDeserializationContext): Option[Any] =
15+
throw new UnsupportedOperationException
16+
17+
def deserialize(parent: VPackSlice, vpack: VPackSlice, context: VPackDeserializationContext, t: ParameterizedType): Option[Any] = {
18+
val value = context.deserialize(vpack, t.getActualTypeArguments()(0).asInstanceOf[Class[Any]])
19+
value match {
20+
case null => None
21+
case _ => Some(value)
22+
}
23+
}
24+
}
25+
26+
val LIST = new VPackDeserializer[List[Any]] {
27+
def deserialize(parent: VPackSlice, vpack: VPackSlice, context: VPackDeserializationContext): List[Any] =
28+
context.deserialize(vpack, classOf[java.util.List[Any]]).toList
29+
}
30+
31+
val MAP = new VPackDeserializer[Map[Any, Any]] {
32+
def deserialize(parent: VPackSlice, vpack: VPackSlice, context: VPackDeserializationContext): Map[Any, Any] =
33+
context.deserialize(vpack, classOf[java.util.Map[Any, Any]]).toMap
34+
}
35+
36+
}

0 commit comments

Comments
 (0)