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-
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+
4151}
0 commit comments