From 0770c134a1d4310b18e78dbc4f5e9e30e70b8655 Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Thu, 3 Jun 2021 22:16:14 +0200 Subject: [PATCH] fix: fixed BasicMessage json so that it works now --- .../marvelous/gamelibrary/messages/BasicMessage.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/BasicMessage.java b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/BasicMessage.java index 696f6cc..f37fdec 100644 --- a/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/BasicMessage.java +++ b/src/main/java/uulm/teamname/marvelous/gamelibrary/messages/BasicMessage.java @@ -1,5 +1,7 @@ package uulm.teamname.marvelous.gamelibrary.messages; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonSubTypes.Type; import com.fasterxml.jackson.annotation.JsonTypeInfo; @@ -11,7 +13,7 @@ import java.util.Objects; * messageType, as fields that aren't sent are null. Note that most messages are not deserialized into the {@link * BasicMessage}, but instead into messages such as the {@link EventMessage} or {@link GameAssignmentMessage}. */ -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "messageType") +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "messageType") @JsonSubTypes({ @Type(value = HelloClientMessage.class, name = "HELLO_CLIENT"), @Type(value = HelloServerMessage.class, name = "HELLO_SERVER"), @@ -24,12 +26,13 @@ import java.util.Objects; @Type(value = ConfirmSelectionMessage.class, name = "CONFIRM_SELECTION"), @Type(value = GameStructureMessage.class, name = "GAME_STRUCTURE"), @Type(value = EventMessage.class, name = "EVENTS"), - // @Type(value = RequestMessage.class, name = "REQUESTS"), // There's a custom deserializer in EventMessage for this - @Type(value = GoodbyeClientMessage.class, name = "GOODBYE_ClIENT") + @Type(value = RequestMessage.class, name = "REQUESTS"), + @Type(value = GoodbyeClientMessage.class, name = "GOODBYE_CLIENT") }) +@JsonInclude(JsonInclude.Include.NON_NULL) public class BasicMessage { - /** The messageType describes the type of message that might be sent. Override this with the local MessageType. */ + /* The messageType describes the type of message that might be sent. Override this with the local MessageType. */ public MessageType messageType; /** I have no idea what this might be used for, even less the boolean in the answer */