Clean up null-ability of incoming message entity fields
This commit is contained in:
parent
ba5e5a780f
commit
288cbf4a80
|
@ -10,16 +10,16 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
public class IncomingMessage {
|
public class IncomingMessage {
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private int type;
|
private final int type;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private final String destination;
|
private final String destination;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private long destinationDeviceId;
|
private final long destinationDeviceId;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private int destinationRegistrationId;
|
private final int destinationRegistrationId;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private final String body;
|
private final String body;
|
||||||
|
@ -35,31 +35,20 @@ public class IncomingMessage {
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public IncomingMessage(
|
public IncomingMessage(
|
||||||
@JsonProperty("id") final Integer type,
|
@JsonProperty("id") final int type,
|
||||||
@JsonProperty("destination") final String destination,
|
@JsonProperty("destination") final String destination,
|
||||||
@JsonProperty("destinationDeviceId") final Long destinationDeviceId,
|
@JsonProperty("destinationDeviceId") final long destinationDeviceId,
|
||||||
@JsonProperty("destinationRegistrationId") final Integer destinationRegistrationId,
|
@JsonProperty("destinationRegistrationId") final int destinationRegistrationId,
|
||||||
@JsonProperty("body") final String body,
|
@JsonProperty("body") final String body,
|
||||||
@JsonProperty("content") final String content,
|
@JsonProperty("content") final String content,
|
||||||
@JsonProperty("relay") final String relay,
|
@JsonProperty("relay") final String relay) {
|
||||||
@JsonProperty("timestamp") final Long timestamp) {
|
this.type = type;
|
||||||
if (type != null) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
|
this.destinationDeviceId = destinationDeviceId;
|
||||||
if (destinationDeviceId != null) {
|
this.destinationRegistrationId = destinationRegistrationId;
|
||||||
this.destinationDeviceId = destinationDeviceId;
|
|
||||||
}
|
|
||||||
if (destinationRegistrationId != null) {
|
|
||||||
this.destinationRegistrationId = destinationRegistrationId;
|
|
||||||
}
|
|
||||||
this.body = body;
|
this.body = body;
|
||||||
this.content = content;
|
this.content = content;
|
||||||
this.relay = relay;
|
this.relay = relay;
|
||||||
if (timestamp != null) {
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDestination() {
|
public String getDestination() {
|
||||||
|
|
|
@ -18,23 +18,19 @@ public class IncomingMessageList {
|
||||||
private final List<@NotNull IncomingMessage> messages;
|
private final List<@NotNull IncomingMessage> messages;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private long timestamp;
|
private final long timestamp;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private boolean online;
|
private final boolean online;
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public IncomingMessageList(
|
public IncomingMessageList(
|
||||||
@JsonProperty("messages") final List<@NotNull IncomingMessage> messages,
|
@JsonProperty("messages") final List<@NotNull IncomingMessage> messages,
|
||||||
@JsonProperty("online") final Boolean online,
|
@JsonProperty("online") final boolean online,
|
||||||
@JsonProperty("timestamp") final Long timestamp) {
|
@JsonProperty("timestamp") final long timestamp) {
|
||||||
this.messages = messages;
|
this.messages = messages;
|
||||||
if (timestamp != null) {
|
this.timestamp = timestamp;
|
||||||
this.timestamp = timestamp;
|
this.online = online;
|
||||||
}
|
|
||||||
if (online != null) {
|
|
||||||
this.online = online;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IncomingMessage> getMessages() {
|
public List<IncomingMessage> getMessages() {
|
||||||
|
|
|
@ -646,7 +646,8 @@ class MessageControllerTest {
|
||||||
try {
|
try {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
Entity.entity(new IncomingMessageList(
|
Entity.entity(new IncomingMessageList(
|
||||||
List.of(new IncomingMessage(1, null, 1L, null, new String(contentBytes), null, null, null)), null, null),
|
List.of(new IncomingMessage(1, null, 1L, 1, new String(contentBytes), null, null)), false,
|
||||||
|
System.currentTimeMillis()),
|
||||||
MediaType.APPLICATION_JSON_TYPE),
|
MediaType.APPLICATION_JSON_TYPE),
|
||||||
Entity.entity(messageStream.toByteArray(), MultiDeviceMessageListProvider.MEDIA_TYPE)
|
Entity.entity(messageStream.toByteArray(), MultiDeviceMessageListProvider.MEDIA_TYPE)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue