2020-01-06 18:00:43 +01:00
|
|
|
package envoy.event;
|
|
|
|
|
2020-01-11 11:36:38 +01:00
|
|
|
import java.util.Date;
|
|
|
|
|
2020-01-06 18:00:43 +01:00
|
|
|
import envoy.data.Message;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Project: <strong>envoy-common</strong><br>
|
|
|
|
* File: <strong>MessageStatusChangeEvent.java</strong><br>
|
|
|
|
* Created: <strong>6 Jan 2020</strong><br>
|
|
|
|
*
|
|
|
|
* @author Kai S. K. Engelbart
|
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
2020-02-11 16:53:41 +01:00
|
|
|
public class MessageStatusChangeEvent extends Event<Message.MessageStatus> {
|
2020-01-06 18:00:43 +01:00
|
|
|
|
2020-03-24 19:06:56 +01:00
|
|
|
private final long id;
|
|
|
|
private final Date 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
|
|
|
/**
|
|
|
|
* Initializes a {@link MessageStatusChangeEvent}.
|
|
|
|
*
|
2020-01-11 14:17:51 +01:00
|
|
|
* @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
|
2020-01-18 09:37:35 +01:00
|
|
|
* to
|
|
|
|
* @param date the date at which the MessageStatus change occurred
|
2020-01-06 18:00:43 +01:00
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
2020-01-11 14:17:51 +01:00
|
|
|
public MessageStatusChangeEvent(long id, Message.MessageStatus status, Date date) {
|
2020-02-11 16:53:41 +01:00
|
|
|
super(status);
|
2020-01-11 14:17:51 +01:00
|
|
|
this.id = id;
|
2020-01-18 09:37:35 +01:00
|
|
|
this.date = date;
|
2020-01-06 18:00:43 +01:00
|
|
|
}
|
|
|
|
|
2020-01-18 09:37:35 +01:00
|
|
|
/**
|
2020-01-28 18:58:44 +01:00
|
|
|
* Initializes a {@link MessageStatusChangeEvent} 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
|
|
|
|
*/
|
|
|
|
public MessageStatusChangeEvent(Message message) { this(message.getId(), message.getStatus(), new Date()); }
|
|
|
|
|
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-01-11 14:17:51 +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-01-11 11:36:38 +01:00
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
|
|
|
public Date getDate() { return date; }
|
2020-02-02 14:20:11 +01:00
|
|
|
|
|
|
|
@Override
|
2020-02-11 16:53:41 +01:00
|
|
|
public String toString() { return String.format("MessageStatusChangeEvent[id=%d,status=%s,date=%s]", id, value, date); }
|
2020-01-06 18:00:43 +01:00
|
|
|
}
|