@@ -27,26 +27,26 @@ object BsonConverter {
2727 }
2828 case v : Any if converterPlugin.hasCustomClass(v) =>
2929 converterPlugin.toBson(v)
30- case b : Boolean => BsonBoolean (b)
31- case s : String => BsonString (s)
32- case c : Char => BsonString (c.toString)
30+ case b : Boolean => BsonBoolean (b)
31+ case s : String => BsonString (s)
32+ case c : Char => BsonString (c.toString)
3333 case bytes : Array [Byte ] => BsonBinary (bytes)
34- case r : Regex => BsonRegularExpression (r)
35- case d : Date => BsonDateTime (d)
34+ case r : Regex => BsonRegularExpression (r)
35+ case d : Date => BsonDateTime (d)
3636 case ld : LocalDate =>
3737 BsonDateTime (Date .from(ld.atStartOfDay(ZoneId .systemDefault()).toInstant))
3838 case ldt : LocalDateTime =>
3939 BsonDateTime (Date .from(ldt.atZone(ZoneId .systemDefault()).toInstant))
40- case oid : ObjectId => BsonObjectId (oid)
41- case i : Int => BsonInt32 (i)
42- case l : Long => BsonInt64 (l)
43- case bi : BigInt => BsonInt64 (bi.toLong)
44- case bi : BigInteger => BsonInt64 (bi.longValue())
45- case d : Double => BsonDouble (d)
46- case f : Float => BsonDouble (f)
47- case bd : BigDecimal => BsonDecimal128 .apply(bd)
40+ case oid : ObjectId => BsonObjectId (oid)
41+ case i : Int => BsonInt32 (i)
42+ case l : Long => BsonInt64 (l)
43+ case bi : BigInt => BsonInt64 (bi.toLong)
44+ case bi : BigInteger => BsonInt64 (bi.longValue())
45+ case d : Double => BsonDouble (d)
46+ case f : Float => BsonDouble (f)
47+ case bd : BigDecimal => BsonDecimal128 .apply(bd)
4848 case bd : java.math.BigDecimal => BsonDecimal128 .apply(bd)
49- case doc : Document => BsonDocument (doc)
49+ case doc : Document => BsonDocument (doc)
5050 case map : Map [_, _] =>
5151 var doc = Document ()
5252 map.keys.foreach(key => {
@@ -76,22 +76,22 @@ object BsonConverter {
7676 def fromBson (value : BsonValue ): Any =
7777 value match {
7878
79- case b : BsonBoolean => b.getValue
80- case s : BsonString => s.getValue
81- case bytes : BsonBinary => bytes.getData
79+ case b : BsonBoolean => b.getValue
80+ case s : BsonString => s.getValue
81+ case bytes : BsonBinary => bytes.getData
8282 case r : BsonRegularExpression => r.getPattern
83- case d : BsonDateTime => new Date (d.getValue)
84- case d : BsonTimestamp => new Date (d.getTime)
85- case oid : BsonObjectId => oid.getValue
86- case i : BsonInt32 => i.getValue
87- case l : BsonInt64 => l.getValue
88- case d : BsonDouble => d.doubleValue()
89- case d : BsonDecimal128 => d.getValue.bigDecimalValue()
90- case doc : BsonDocument => Document (doc)
83+ case d : BsonDateTime => new Date (d.getValue)
84+ case d : BsonTimestamp => new Date (d.getTime)
85+ case oid : BsonObjectId => oid.getValue
86+ case i : BsonInt32 => i.getValue
87+ case l : BsonInt64 => l.getValue
88+ case d : BsonDouble => d.doubleValue()
89+ case d : BsonDecimal128 => d.getValue.bigDecimalValue()
90+ case doc : BsonDocument => Document (doc)
9191 case array : BsonArray =>
9292 array.getValues.asScala.toList.map(v => fromBson(v))
9393 case n : BsonNull => null
94- case _ => value
94+ case _ => value
9595 }
9696
9797 def asMap (document : Document ): Map [String , Any ] = {
0 commit comments