2020-01-06 18:00:43 +01:00
|
|
|
package envoy.event;
|
|
|
|
|
2020-07-16 17:04:35 +02:00
|
|
|
import java.time.Instant;
|
2020-10-22 23:58:55 +02:00
|
|
|
import java.util.Objects;
|
2020-01-11 11:36:38 +01:00
|
|
|
|
2020-01-06 18:00:43 +01:00
|
|
|
import envoy.data.Message;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Kai S. K. Engelbart
|
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
2020-06-20 09:19:39 +02:00
|
|
|
public class MessageStatusChange extends Event<Message.MessageStatus> {
|
2020-01-06 18:00:43 +01:00
|
|
|
|
2020-07-16 17:04:35 +02:00
|
|
|
private final long id;
|
|
|
|
private final Instant date;
|
2020-01-06 18:00:43 +01:00
|
|
|
|
2020-03-24 19:06:56 +01:00
|
|
|
private static final long serialVersionUID = 0L;
|
2020-01-28 17:50:09 +01:00
|
|
|
|
2020-01-06 18:00:43 +01:00
|
|
|
/**
|
2020-06-20 09:19:39 +02:00
|
|
|
* Initializes a {@link MessageStatusChange}.
|
2020-01-06 18:00:43 +01:00
|
|
|
*
|
2020-01-11 14:17:51 +01:00
|
|
|
* @param id the ID of the {@link Message} this event is related to
|
2020-10-19 18:17:51 +02:00
|
|
|
* @param status the status of the {@link Message} this event is related to
|
2020-01-18 09:37:35 +01:00
|
|
|
* @param date the date at which the MessageStatus change occurred
|
2020-07-16 17:04:35 +02:00
|
|
|
* @since Envoy Common v0.2-beta
|
2020-01-06 18:00:43 +01:00
|
|
|
*/
|
2020-07-16 17:04:35 +02:00
|
|
|
public MessageStatusChange(long id, Message.MessageStatus status, Instant date) {
|
2020-02-11 16:53:41 +01:00
|
|
|
super(status);
|
2020-01-11 14:17:51 +01:00
|
|
|
this.id = id;
|
2020-10-22 23:58:55 +02:00
|
|
|
this.date = Objects.requireNonNull(date);
|
2020-01-06 18:00:43 +01:00
|
|
|
}
|
|
|
|
|
2020-01-18 09:37:35 +01:00
|
|
|
/**
|
2020-06-20 09:19:39 +02:00
|
|
|
* Initializes a {@link MessageStatusChange} through a message.
|
2020-01-18 09:37:35 +01:00
|
|
|
*
|
|
|
|
* @param message the message from which to build the event
|
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
2020-10-19 18:17:51 +02:00
|
|
|
public MessageStatusChange(Message message) {
|
|
|
|
this(message.getID(), message.getStatus(), Instant.now());
|
|
|
|
}
|
2020-01-18 09:37:35 +01:00
|
|
|
|
2020-01-06 18:00:43 +01:00
|
|
|
/**
|
|
|
|
* @return the ID of the {@link Message} this event is related to
|
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
2020-03-25 17:43:55 +01:00
|
|
|
public long getID() { return id; }
|
2020-01-11 11:36:38 +01:00
|
|
|
|
|
|
|
/**
|
2020-01-11 14:17:51 +01:00
|
|
|
* @return the date at which the status change occurred
|
2020-07-16 17:04:35 +02:00
|
|
|
* @since Envoy Common v0.2-beta
|
2020-01-11 11:36:38 +01:00
|
|
|
*/
|
2020-07-16 17:04:35 +02:00
|
|
|
public Instant getDate() { return date; }
|
2020-02-02 14:20:11 +01:00
|
|
|
|
|
|
|
@Override
|
2020-10-19 18:17:51 +02:00
|
|
|
public String toString() {
|
|
|
|
return String.format("MessageStatusChange[id=%d,status=%s,date=%s]", id, value, date);
|
|
|
|
}
|
2020-01-06 18:00:43 +01:00
|
|
|
}
|