From 1a4523db54e385d543ade51ee03576e3296dc385 Mon Sep 17 00:00:00 2001 From: delvh Date: Sat, 18 Jan 2020 09:37:35 +0100 Subject: [PATCH] Added a constructor for User as well as for MessageStatusChangeEvent --- src/main/java/envoy/data/Message.java | 1 - src/main/java/envoy/data/User.java | 15 ++++++++++++++- .../envoy/event/MessageStatusChangeEvent.java | 14 +++++++++++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/java/envoy/data/Message.java b/src/main/java/envoy/data/Message.java index 5d7ee33..50a2f09 100644 --- a/src/main/java/envoy/data/Message.java +++ b/src/main/java/envoy/data/Message.java @@ -81,7 +81,6 @@ public class Message implements Serializable { this.text = text; this.attachment = attachment; this.status = status; - } /** diff --git a/src/main/java/envoy/data/User.java b/src/main/java/envoy/data/User.java index dc33851..bc9cf0f 100644 --- a/src/main/java/envoy/data/User.java +++ b/src/main/java/envoy/data/User.java @@ -53,7 +53,7 @@ public class User implements Serializable { /** * Initializes a {@link User}. The {@link UserStatus} is set to - * {@link UserStatus#OFFLINE}. + * {@link UserStatus#ONLINE}. * * @param id unique ID * @param name user name @@ -65,6 +65,19 @@ public class User implements Serializable { status = UserStatus.ONLINE; } + /** + * Initializes a {@link User}. + * + * @param id unique ID + * @param name user name + * @param status the status of the user + * @since Envoy Common v0.2-alpha + */ + public User(long id, String name, UserStatus status) { + this(id, name); + this.status = status; + } + @Override public String toString() { return String.format("User[id=%d,name=%s,status=%s]", id, name, status); } diff --git a/src/main/java/envoy/event/MessageStatusChangeEvent.java b/src/main/java/envoy/event/MessageStatusChangeEvent.java index b0aea1f..ebe818b 100644 --- a/src/main/java/envoy/event/MessageStatusChangeEvent.java +++ b/src/main/java/envoy/event/MessageStatusChangeEvent.java @@ -23,16 +23,24 @@ public class MessageStatusChangeEvent implements Event { * * @param id the ID of the {@link Message} this event is related to * @param status the status of the {@link Message} this event is related - * to - * @param date the date at which the MessageStatus change occurred + * to + * @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) { this.id = id; this.status = status; - this.date = date; + this.date = date; } + /** + * Initialises a {@link MessageStatusChangeEvent} through a message. + * + * @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()); } + /** * @return the status of the {@link Message} this event is related to * @since Envoy Common v0.2-alpha