br.com.m4rc310.gql.dto.messages.MMessage Maven / Gradle / Ivy
The newest version!
package br.com.m4rc310.gql.dto.messages;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import br.com.m4rc310.gql.dto.messages.MMessage.MErrorMessage;
import br.com.m4rc310.gql.dto.messages.MMessage.MInitMessage;
import br.com.m4rc310.gql.dto.messages.MMessage.MStartMessage;
import br.com.m4rc310.gql.dto.messages.MMessage.MStopMessage;
import br.com.m4rc310.gql.dto.messages.MMessage.MTerminateMessage;
import graphql.ExecutionResult;
import io.leangen.graphql.spqr.spring.web.dto.GraphQLRequest;
import lombok.Data;
import lombok.Getter;
/**
* MMessage class.
*
* @author marcelo
* @version $Id: $Id
*/
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, include = JsonTypeInfo.As.EXISTING_PROPERTY)
@JsonSubTypes({
@JsonSubTypes.Type(value = MInitMessage.class, name = MMessage.GQL_CONNECTION_INIT),
@JsonSubTypes.Type(value = MTerminateMessage.class, name = MMessage.GQL_CONNECTION_TERMINATE),
@JsonSubTypes.Type(value = MStopMessage.class, name = MMessage.GQL_STOP),
@JsonSubTypes.Type(value = MStartMessage.class, name = MMessage.GQL_START),
@JsonSubTypes.Type(value = MErrorMessage.class, name = MMessage.GQL_CONNECTION_ERROR),
@JsonSubTypes.Type(value = MErrorMessage.class, name = MMessage.GQL_ERROR),
})
public class MMessage {
/** Constant GQL_CONNECTION_INIT="connection_init"
*/
public static final String GQL_CONNECTION_INIT = "connection_init";
/** Constant GQL_CONNECTION_TERMINATE="connection_terminate"
*/
public static final String GQL_CONNECTION_TERMINATE = "connection_terminate";
/** Constant GQL_START="start"
*/
public static final String GQL_START = "start";
/** Constant GQL_STOP="stop"
*/
public static final String GQL_STOP = "stop";
/** Constant GQL_CONNECTION_ACK="connection_ack"
*/
public static final String GQL_CONNECTION_ACK = "connection_ack";
/** Constant GQL_CONNECTION_ERROR="connection_error"
*/
public static final String GQL_CONNECTION_ERROR = "connection_error";
/** Constant GQL_CONNECTION_KEEP_ALIVE="ka"
*/
public static final String GQL_CONNECTION_KEEP_ALIVE = "ka";
/** Constant GQL_DATA="data"
*/
public static final String GQL_DATA = "data";
/** Constant GQL_ERROR="error"
*/
public static final String GQL_ERROR = "error";
/** Constant GQL_COMPLETE="complete"
*/
public static final String GQL_COMPLETE = "complete";
private final String id;
private final String type;
/**
* Constructor for MMessage.
*
* @param id a {@link java.lang.String} object
* @param type a {@link java.lang.String} object
*/
public MMessage(String id, String type) {
this.id = id;
this.type = type;
}
@Getter
public static abstract class MPayloadMessage extends MMessage {
private final T payload;
public MPayloadMessage(String id, String type, T payload) {
super(id, type);
this.payload = payload;
}
}
public static class MDataMessage extends MPayloadMessage