Moves type to the when clause
This commit is contained in:
+2
-3
@@ -31,15 +31,14 @@ class MessageDeserializer : StdDeserializer<Message>(Message::class.java) {
|
|||||||
override fun deserialize(
|
override fun deserialize(
|
||||||
jp: JsonParser,
|
jp: JsonParser,
|
||||||
ctxt: DeserializationContext,
|
ctxt: DeserializationContext,
|
||||||
): Message? {
|
): Message {
|
||||||
// Expect to start with a JSON array token
|
// Expect to start with a JSON array token
|
||||||
if (jp.currentToken != JsonToken.START_ARRAY) {
|
if (jp.currentToken != JsonToken.START_ARRAY) {
|
||||||
ctxt.reportWrongTokenException(this, JsonToken.START_ARRAY, "Expected START_ARRAY token")
|
ctxt.reportWrongTokenException(this, JsonToken.START_ARRAY, "Expected START_ARRAY token")
|
||||||
}
|
}
|
||||||
|
|
||||||
val type = jp.nextTextValue()
|
|
||||||
val message =
|
val message =
|
||||||
when (type) {
|
when (val type = jp.nextTextValue()) {
|
||||||
EventMessage.LABEL -> {
|
EventMessage.LABEL -> {
|
||||||
val subId = jp.nextTextValue()
|
val subId = jp.nextTextValue()
|
||||||
jp.nextToken()
|
jp.nextToken()
|
||||||
|
|||||||
+2
-3
@@ -35,15 +35,14 @@ class CommandDeserializer : StdDeserializer<Command>(Command::class.java) {
|
|||||||
override fun deserialize(
|
override fun deserialize(
|
||||||
jp: JsonParser,
|
jp: JsonParser,
|
||||||
ctxt: DeserializationContext,
|
ctxt: DeserializationContext,
|
||||||
): Command? {
|
): Command {
|
||||||
// Expect to start with a JSON array token
|
// Expect to start with a JSON array token
|
||||||
if (jp.currentToken != JsonToken.START_ARRAY) {
|
if (jp.currentToken != JsonToken.START_ARRAY) {
|
||||||
ctxt.reportWrongTokenException(this, JsonToken.START_ARRAY, "Expected START_ARRAY token")
|
ctxt.reportWrongTokenException(this, JsonToken.START_ARRAY, "Expected START_ARRAY token")
|
||||||
}
|
}
|
||||||
|
|
||||||
val type = jp.nextTextValue()
|
|
||||||
val message =
|
val message =
|
||||||
when (type) {
|
when (val type = jp.nextTextValue()) {
|
||||||
ReqCmd.LABEL -> {
|
ReqCmd.LABEL -> {
|
||||||
val subId = jp.nextTextValue()
|
val subId = jp.nextTextValue()
|
||||||
val filters = mutableListOf<Filter>()
|
val filters = mutableListOf<Filter>()
|
||||||
|
|||||||
Reference in New Issue
Block a user