Skip to content

Instantly share code, notes, and snippets.

@attribyte
Last active January 2, 2016 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save attribyte/259d80d325d3cdd8e6ca to your computer and use it in GitHub Desktop.
Save attribyte/259d80d325d3cdd8e6ca to your computer and use it in GitHub Desktop.
case class QueryResponse(query: Protos.Query,
matchCount: Int,
posts: Seq[Protos.Post])
extends NameValueMessage {
def toNameValuePairs =
List(
("query", query),
("matchCount", matchCount),
("posts", posts)
)
}
object QueryResponseMaterializer
extends MultiValueMapMaterializer {
def fromMap(nameValueMap: Map[String, Any]): =
QueryResponse(
nameValueMap.getOrElse("query",
Protos.Query.getDefaultInstance
).asInstanceOf[Protos.Query],
nameValueMap.getOrElse("matchCount", 0
).asInstanceOf[Int],
nameValueMap.getOrElse("posts",
List.empty
).asInstanceOf[Seq[Protos.Post]]
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment