refactor: refactored JSON class for new messages

This commit is contained in:
Yannik Bretschneider 2021-06-03 22:18:48 +02:00
parent c67968896b
commit 4823803e85

View File

@ -23,14 +23,15 @@ public class JSON {
/** Deserializes an incoming network message into a {@link EventMessage}.
* @param input The JSON to deserialize
* @return The parsed message or {@code null} if the deserialization failed
* @return The parsed message (as {@link BasicMessage}, so casting is necessary)
* or {@code null} if the deserialization failed
*/
public EventMessage parse(String input) {
EventMessage result = null;
public BasicMessage parse(String input) {
BasicMessage result = null;
try {
return mapper.readValue(input, EventMessage.class);
return mapper.readValue(input, BasicMessage.class);
} catch (JsonProcessingException e) {
e.printStackTrace();
// e.printStackTrace();
return null;
}
}
@ -43,7 +44,7 @@ public class JSON {
try {
return mapper.writeValueAsString(input);
} catch (JsonProcessingException e) {
e.printStackTrace();
// e.printStackTrace();
return null;
}
}