-
-
Save attribyte/259d80d325d3cdd8e6ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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