Created
July 6, 2015 20:20
-
-
Save frsyuki/eda7895b4a3172222d95 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
@MessagePackDeserializer(PlanNodeDeserializer.class) | |
public abstract class PlanNode | |
{ | |
... | |
} | |
public class PlanNodeDeserializer extends Deserializer<PlanNode> | |
{ | |
public PlanNode deserialize(Unpacker unpacker) | |
{ | |
Value value = unpacker.unpackValue(); | |
if (value.asMap().map().get("error") != null) { | |
return new ObjectMapper().readValue(value, ErrorNode.class); | |
} else if (value.asMap().map().get("engine") != null) { | |
return new ObjectMapper().readValue(value, EngineNode.class); | |
} else { | |
throw new MessageTypeException("unknown type"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment