parent
5c784bfdc6
commit
41a507057b
@ -1,7 +1,7 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -38,7 +38,8 @@ public final class GroupMessage extends Message {
|
||||
* {@link GroupMessage}
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
GroupMessage(long id, long senderID, long groupID, Date creationDate, String text, MessageAttachment<?> attachment, MessageStatus status,
|
||||
GroupMessage(long id, long senderID, long groupID, LocalDateTime creationDate, String text, MessageAttachment<?> attachment,
|
||||
MessageStatus status,
|
||||
boolean forwarded, Map<Long, MessageStatus> memberStatuses) {
|
||||
super(id, senderID, groupID, creationDate, text, attachment, status, forwarded);
|
||||
this.memberStatuses = memberStatuses;
|
||||
@ -53,10 +54,10 @@ public final class GroupMessage extends Message {
|
||||
setStatus(Collections.min(memberStatuses.values()));
|
||||
switch (getStatus()) {
|
||||
case RECEIVED:
|
||||
setReceivedDate(new Date());
|
||||
setReceivedDate(LocalDateTime.now());
|
||||
break;
|
||||
case READ:
|
||||
setReadDate(new Date());
|
||||
setReadDate(LocalDateTime.now());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* Represents a unique message with a unique, numeric ID. Further metadata
|
||||
@ -50,14 +50,14 @@ public class Message implements Serializable {
|
||||
|
||||
private final long id, senderID, recipientID;
|
||||
private final boolean forwarded;
|
||||
private final Date creationDate;
|
||||
private final LocalDateTime creationDate;
|
||||
private final String text;
|
||||
private final MessageAttachment<?> attachment;
|
||||
|
||||
private Date receivedDate, readDate;
|
||||
private LocalDateTime receivedDate, readDate;
|
||||
private MessageStatus status;
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Initializes a {@link Message} with values for all of its properties. The use
|
||||
@ -75,7 +75,8 @@ public class Message implements Serializable {
|
||||
* @param forwarded whether this message was forwarded
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
Message(long id, long senderID, long recipientID, Date creationDate, String text, MessageAttachment<?> attachment, MessageStatus status,
|
||||
Message(long id, long senderID, long recipientID, LocalDateTime creationDate, String text, MessageAttachment<?> attachment,
|
||||
MessageStatus status,
|
||||
boolean forwarded) {
|
||||
this.id = id;
|
||||
this.senderID = senderID;
|
||||
@ -111,7 +112,7 @@ public class Message implements Serializable {
|
||||
id,
|
||||
senderID,
|
||||
recipientID,
|
||||
new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(creationDate),
|
||||
DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm:ss").format(creationDate),
|
||||
status,
|
||||
text,
|
||||
forwarded,
|
||||
@ -140,32 +141,32 @@ public class Message implements Serializable {
|
||||
* @return the date at which this message was created
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public Date getCreationDate() { return creationDate; }
|
||||
public LocalDateTime getCreationDate() { return creationDate; }
|
||||
|
||||
/**
|
||||
* @return the date at which the message has been received by the sender
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public Date getReceivedDate() { return receivedDate; }
|
||||
public LocalDateTime getReceivedDate() { return receivedDate; }
|
||||
|
||||
/**
|
||||
* @param receivedDate the date at which the message has been received by the
|
||||
* sender
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public void setReceivedDate(Date receivedDate) { this.receivedDate = receivedDate; }
|
||||
public void setReceivedDate(LocalDateTime receivedDate) { this.receivedDate = receivedDate; }
|
||||
|
||||
/**
|
||||
* @return the date at which the message has been read by the sender
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public Date getReadDate() { return readDate; }
|
||||
public LocalDateTime getReadDate() { return readDate; }
|
||||
|
||||
/**
|
||||
* @param readDate at which the message has been read by the sender
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public void setReadDate(Date readDate) { this.readDate = readDate; }
|
||||
public void setReadDate(LocalDateTime readDate) { this.readDate = readDate; }
|
||||
|
||||
/**
|
||||
* @return the text content of this message
|
||||
|
@ -1,6 +1,6 @@
|
||||
package envoy.data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -23,7 +23,7 @@ public class MessageBuilder {
|
||||
|
||||
// Properties with default values
|
||||
private long id;
|
||||
private Date creationDate;
|
||||
private LocalDateTime creationDate;
|
||||
private String text;
|
||||
private MessageAttachment<?> attachment;
|
||||
private Message.MessageStatus status;
|
||||
@ -70,7 +70,7 @@ public class MessageBuilder {
|
||||
public MessageBuilder(Message msg, long recipientID, IDGenerator iDGenerator) {
|
||||
this(msg.getRecipientID(), recipientID, iDGenerator.next());
|
||||
this.attachment = msg.getAttachment();
|
||||
this.creationDate = new Date();
|
||||
this.creationDate = LocalDateTime.now();
|
||||
this.forwarded = true;
|
||||
this.text = msg.getText();
|
||||
this.status = MessageStatus.WAITING;
|
||||
@ -83,7 +83,7 @@ public class MessageBuilder {
|
||||
* <table border="1">
|
||||
* <tr>
|
||||
* <td>{@code date}</td>
|
||||
* <td>{@code new Date()}</td>
|
||||
* <td>{@code LocalDateTime.now()}</td>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td>{@code text}</td>
|
||||
@ -161,7 +161,7 @@ public class MessageBuilder {
|
||||
}
|
||||
|
||||
private void supplyDefaults() {
|
||||
if (creationDate == null) creationDate = new Date();
|
||||
if (creationDate == null) creationDate = LocalDateTime.now();
|
||||
if (text == null) text = "";
|
||||
if (status == null) status = MessageStatus.WAITING;
|
||||
}
|
||||
@ -171,7 +171,7 @@ public class MessageBuilder {
|
||||
* @return this {@link MessageBuilder}
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public MessageBuilder setDate(Date creationDate) {
|
||||
public MessageBuilder setDate(LocalDateTime creationDate) {
|
||||
this.creationDate = creationDate;
|
||||
return this;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package envoy.event;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import envoy.data.GroupMessage;
|
||||
import envoy.data.Message.MessageStatus;
|
||||
@ -29,7 +29,7 @@ public class GroupMessageStatusChangeEvent extends MessageStatusChangeEvent {
|
||||
* @param memberID the ID of the group member that caused the status change
|
||||
* @since Envoy Common v0.1-beta
|
||||
*/
|
||||
public GroupMessageStatusChangeEvent(long id, MessageStatus status, Date date, long memberID) {
|
||||
public GroupMessageStatusChangeEvent(long id, MessageStatus status, LocalDateTime date, long memberID) {
|
||||
super(id, status, date);
|
||||
this.memberID = memberID;
|
||||
}
|
||||
@ -42,5 +42,4 @@ public class GroupMessageStatusChangeEvent extends MessageStatusChangeEvent {
|
||||
|
||||
@Override
|
||||
public String toString() { return String.format("GroupMessageStatusChangeEvent[meta=%s,memberID=%d]", super.toString(), memberID); }
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package envoy.event;
|
||||
|
||||
import java.util.Date;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import envoy.data.Message;
|
||||
|
||||
@ -15,7 +15,7 @@ import envoy.data.Message;
|
||||
public class MessageStatusChangeEvent extends Event<Message.MessageStatus> {
|
||||
|
||||
private final long id;
|
||||
private final Date date;
|
||||
private final LocalDateTime date;
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
@ -28,7 +28,7 @@ public class MessageStatusChangeEvent extends Event<Message.MessageStatus> {
|
||||
* @param date the date at which the MessageStatus change occurred
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public MessageStatusChangeEvent(long id, Message.MessageStatus status, Date date) {
|
||||
public MessageStatusChangeEvent(long id, Message.MessageStatus status, LocalDateTime date) {
|
||||
super(status);
|
||||
this.id = id;
|
||||
this.date = date;
|
||||
@ -40,7 +40,7 @@ public class MessageStatusChangeEvent extends Event<Message.MessageStatus> {
|
||||
* @param message the message from which to build the event
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public MessageStatusChangeEvent(Message message) { this(message.getID(), message.getStatus(), new Date()); }
|
||||
public MessageStatusChangeEvent(Message message) { this(message.getID(), message.getStatus(), LocalDateTime.now()); }
|
||||
|
||||
/**
|
||||
* @return the ID of the {@link Message} this event is related to
|
||||
@ -52,7 +52,7 @@ public class MessageStatusChangeEvent extends Event<Message.MessageStatus> {
|
||||
* @return the date at which the status change occurred
|
||||
* @since Envoy Common v0.2-alpha
|
||||
*/
|
||||
public Date getDate() { return date; }
|
||||
public LocalDateTime getDate() { return date; }
|
||||
|
||||
@Override
|
||||
public String toString() { return String.format("MessageStatusChangeEvent[id=%d,status=%s,date=%s]", id, value, date); }
|
||||
|
Reference in New Issue
Block a user