16 package org.openkilda.messaging;
21 import com.fasterxml.jackson.annotation.JsonCreator;
22 import com.fasterxml.jackson.annotation.JsonInclude;
23 import com.fasterxml.jackson.annotation.JsonProperty;
24 import com.fasterxml.jackson.annotation.JsonTypeInfo;
26 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
28 import java.io.Serializable;
42 @JsonInclude(JsonInclude.Include.NON_NULL)
43 @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property=
"clazz")
48 static final long serialVersionUID = 1L;
53 @JsonProperty(TIMESTAMP)
54 protected
long timestamp = 0L;
63 public
BaseMessage(@JsonProperty(TIMESTAMP) final
long timestamp) {
64 this.timestamp = timestamp;
71 this(System.currentTimeMillis());
90 this.timestamp = timestamp;
101 public static final <T extends BaseMessage> T
getMessage(String json, Class<T>
type)
102 throws java.io.IOException {
103 return type.cast(MAPPER.readValue(json,
type));
120 return getMessage(json,
type);
121 }
catch (Exception e) {
void setTimestamp(long timestamp)
static final ObjectMapper MAPPER
static final< T extends BaseMessage > T getMessage(String json, Class< T > type)
static final< T extends BaseMessage > T tryGetMessage(String json, Class< T > type)
static final String TIMESTAMP