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 {
|
||||
|
||||
@JsonProperty
|
||||
private int type;
|
||||
private final int type;
|
||||
|
||||
@JsonProperty
|
||||
private final String destination;
|
||||
|
||||
@JsonProperty
|
||||
private long destinationDeviceId;
|
||||
private final long destinationDeviceId;
|
||||
|
||||
@JsonProperty
|
||||
private int destinationRegistrationId;
|
||||
private final int destinationRegistrationId;
|
||||
|
||||
@JsonProperty
|
||||
private final String body;
|
||||
|
@ -35,31 +35,20 @@ public class IncomingMessage {
|
|||
|
||||
@JsonCreator
|
||||
public IncomingMessage(
|
||||
@JsonProperty("id") final Integer type,
|
||||
@JsonProperty("id") final int type,
|
||||
@JsonProperty("destination") final String destination,
|
||||
@JsonProperty("destinationDeviceId") final Long destinationDeviceId,
|
||||
@JsonProperty("destinationRegistrationId") final Integer destinationRegistrationId,
|
||||
@JsonProperty("destinationDeviceId") final long destinationDeviceId,
|
||||
@JsonProperty("destinationRegistrationId") final int destinationRegistrationId,
|
||||
@JsonProperty("body") final String body,
|
||||
@JsonProperty("content") final String content,
|
||||
@JsonProperty("relay") final String relay,
|
||||
@JsonProperty("timestamp") final Long timestamp) {
|
||||
if (type != null) {
|
||||
this.type = type;
|
||||
}
|
||||
@JsonProperty("relay") final String relay) {
|
||||
this.type = type;
|
||||
this.destination = destination;
|
||||
|
||||
if (destinationDeviceId != null) {
|
||||
this.destinationDeviceId = destinationDeviceId;
|
||||
}
|
||||
if (destinationRegistrationId != null) {
|
||||
this.destinationRegistrationId = destinationRegistrationId;
|
||||
}
|
||||
this.destinationDeviceId = destinationDeviceId;
|
||||
this.destinationRegistrationId = destinationRegistrationId;
|
||||
this.body = body;
|
||||
this.content = content;
|
||||
this.relay = relay;
|
||||
if (timestamp != null) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
public String getDestination() {
|
||||
|
|
|
@ -18,23 +18,19 @@ public class IncomingMessageList {
|
|||
private final List<@NotNull IncomingMessage> messages;
|
||||
|
||||
@JsonProperty
|
||||
private long timestamp;
|
||||
private final long timestamp;
|
||||
|
||||
@JsonProperty
|
||||
private boolean online;
|
||||
private final boolean online;
|
||||
|
||||
@JsonCreator
|
||||
public IncomingMessageList(
|
||||
@JsonProperty("messages") final List<@NotNull IncomingMessage> messages,
|
||||
@JsonProperty("online") final Boolean online,
|
||||
@JsonProperty("timestamp") final Long timestamp) {
|
||||
@JsonProperty("online") final boolean online,
|
||||
@JsonProperty("timestamp") final long timestamp) {
|
||||
this.messages = messages;
|
||||
if (timestamp != null) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
if (online != null) {
|
||||
this.online = online;
|
||||
}
|
||||
this.timestamp = timestamp;
|
||||
this.online = online;
|
||||
}
|
||||
|
||||
public List<IncomingMessage> getMessages() {
|
||||
|
|
|
@ -646,7 +646,8 @@ class MessageControllerTest {
|
|||
try {
|
||||
return Stream.of(
|
||||
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),
|
||||
Entity.entity(messageStream.toByteArray(), MultiDeviceMessageListProvider.MEDIA_TYPE)
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue