fix: fixed BasicMessage json so that it works now

This commit is contained in:
Yannik Bretschneider 2021-06-03 22:16:14 +02:00
parent 670a27d3ef
commit 0770c134a1

View File

@ -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 */