package de.towerdefence.server.session; import com.fasterxml.jackson.annotation.JsonCreator; import lombok.AllArgsConstructor; import lombok.Getter; @Getter @AllArgsConstructor public enum Channel { CONNECTION("connection"), TIME("time"); private final String jsonName; @JsonCreator public static Channel fromJsonName(String jsonName) { for (Channel channel : Channel.values()) { if (channel.getJsonName().equalsIgnoreCase(jsonName)) { return channel; } } throw new IllegalArgumentException("Unknown channel: " + jsonName); } }