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 VPackDeserializerParameterizedType [List [Any ]] {
27- def deserialize (parent : VPackSlice , vpack : VPackSlice , context : VPackDeserializationContext ): List [Any ] =
28- throw new UnsupportedOperationException
29-
30- def deserialize (parent : VPackSlice , vpack : VPackSlice , context : VPackDeserializationContext , t : ParameterizedType ): List [Any ] = {
31- val clazz = t.getActualTypeArguments()(0 ).asInstanceOf [Class [Any ]]
32- vpack.arrayIterator().map { slice => context.deserialize(slice, clazz) }.toList
33- }
34- }
35-
36- val MAP = new VPackDeserializer [Map [Any , Any ]] {
37- def deserialize (parent : VPackSlice , vpack : VPackSlice , context : VPackDeserializationContext ): Map [Any , Any ] =
38- context.deserialize(vpack, classOf [java.util.Map [Any , Any ]]).toMap
39- }
40-
41- val BIG_INT = new VPackDeserializer [BigInt ] {
42- def deserialize (parent : VPackSlice , vpack : VPackSlice , context : VPackDeserializationContext ): BigInt =
43- BigInt .javaBigInteger2bigInt(context.deserialize(vpack, classOf [java.math.BigInteger ]))
44- }
45-
46- val BIG_DECIMAL = new VPackDeserializer [BigDecimal ] {
47- def deserialize (parent : VPackSlice , vpack : VPackSlice , context : VPackDeserializationContext ): BigDecimal =
48- BigDecimal .javaBigDecimal2bigDecimal(context.deserialize(vpack, classOf [java.math.BigDecimal ]))
49- }
50-
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[Any ](vpack, t.getActualTypeArguments()(0 ))
19+ value match {
20+ case null => None
21+ case _ => Some (value)
22+ }
23+ }
24+ }
25+
26+ val SEQ = new VPackDeserializerParameterizedType [Seq [Any ]] {
27+ def deserialize (parent : VPackSlice , vpack : VPackSlice , context : VPackDeserializationContext ): Seq [Any ] =
28+ throw new UnsupportedOperationException
29+
30+ def deserialize (parent : VPackSlice , vpack : VPackSlice , context : VPackDeserializationContext , t : ParameterizedType ): Seq [Any ] = {
31+ val clazz = t.getActualTypeArguments()(0 ).asInstanceOf [Class [Any ]]
32+ vpack.arrayIterator().map { slice : VPackSlice => context.deserialize[Any ](slice, clazz) }.toSeq
33+ }
34+ }
35+
36+ val LIST = new VPackDeserializerParameterizedType [List [Any ]] {
37+ def deserialize (parent : VPackSlice , vpack : VPackSlice , context : VPackDeserializationContext ): List [Any ] =
38+ throw new UnsupportedOperationException
39+
40+ def deserialize (parent : VPackSlice , vpack : VPackSlice , context : VPackDeserializationContext , t : ParameterizedType ): List [Any ] = {
41+ val clazz = t.getActualTypeArguments()(0 ).asInstanceOf [Class [Any ]]
42+ vpack.arrayIterator().map { slice : VPackSlice => context.deserialize[Any ](slice, clazz) }.toList
43+ }
44+ }
45+
46+ val MAP = new VPackDeserializer [Map [Any , Any ]] {
47+ def deserialize (parent : VPackSlice , vpack : VPackSlice , context : VPackDeserializationContext ): Map [Any , Any ] =
48+ context.deserialize[java.util.Map [Any , Any ]](vpack, classOf [java.util.Map [Any , Any ]]).toMap
49+ }
50+
51+ val BIG_INT = new VPackDeserializer [BigInt ] {
52+ def deserialize (parent : VPackSlice , vpack : VPackSlice , context : VPackDeserializationContext ): BigInt =
53+ BigInt .javaBigInteger2bigInt(context.deserialize(vpack, classOf [java.math.BigInteger ]))
54+ }
55+
56+ val BIG_DECIMAL = new VPackDeserializer [BigDecimal ] {
57+ def deserialize (parent : VPackSlice , vpack : VPackSlice , context : VPackDeserializationContext ): BigDecimal =
58+ BigDecimal .javaBigDecimal2bigDecimal(context.deserialize(vpack, classOf [java.math.BigDecimal ]))
59+ }
60+
5161}
0 commit comments