Skip to content

Commit a2bce59

Browse files
#20 Add support for query plugins
Make scala 2.11
1 parent 642e886 commit a2bce59

File tree

1 file changed

+14
-12
lines changed
  • src/main/scala/io/waylay/kairosdb/driver/models/json

1 file changed

+14
-12
lines changed

src/main/scala/io/waylay/kairosdb/driver/models/json/Formats.scala

+14-12
Original file line numberDiff line numberDiff line change
@@ -330,18 +330,20 @@ object Formats {
330330

331331
implicit val queryTagFormat = Json.format[QueryTag]
332332

333-
implicit val queryPluginWrites: Writes[QueryPlugin] = (plugin: QueryPlugin) => {
334-
JsObject(Seq("name" -> JsString(plugin.name)) ++ plugin.properties.map(
335-
prop => {
336-
val propValue: JsValue = prop._2 match {
337-
case s: String => Json.toJson(s)
338-
case l: Long => Json.toJson(l)
339-
case i: Integer => Json.toJson(i.longValue())
340-
case d: Double => Json.toJson(d)
341-
case stringSeq: Seq[String] => Json.toJson(stringSeq)
342-
}
343-
prop._1 -> propValue
344-
}))
333+
implicit val queryPluginWrites: Writes[QueryPlugin] = new Writes[QueryPlugin] {
334+
override def writes(plugin: QueryPlugin): JsValue = {
335+
JsObject(Seq("name" -> JsString(plugin.name)) ++ plugin.properties.map(
336+
prop => {
337+
val propValue: JsValue = prop._2 match {
338+
case s: String => Json.toJson(s)
339+
case l: Long => Json.toJson(l)
340+
case i: Integer => Json.toJson(i.longValue())
341+
case d: Double => Json.toJson(d)
342+
case stringSeq: Seq[String] => Json.toJson(stringSeq)
343+
}
344+
prop._1 -> propValue
345+
}))
346+
}
345347
}
346348

347349
implicit val queryWrites: Writes[Query] = new Writes[Query] {

0 commit comments

Comments
 (0)