59 lines
1.5 KiB
Java
59 lines
1.5 KiB
Java
package envoy.event;
|
|
|
|
import java.time.Instant;
|
|
|
|
import envoy.data.Message;
|
|
|
|
/**
|
|
* @author Kai S. K. Engelbart
|
|
* @since Envoy Common v0.2-alpha
|
|
*/
|
|
public class MessageStatusChange extends Event<Message.MessageStatus> {
|
|
|
|
private final long id;
|
|
private final Instant date;
|
|
|
|
private static final long serialVersionUID = 0L;
|
|
|
|
/**
|
|
* Initializes a {@link MessageStatusChange}.
|
|
*
|
|
* @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
|
|
* @since Envoy Common v0.2-beta
|
|
*/
|
|
public MessageStatusChange(long id, Message.MessageStatus status, Instant date) {
|
|
super(status);
|
|
this.id = id;
|
|
this.date = date;
|
|
}
|
|
|
|
/**
|
|
* Initializes a {@link MessageStatusChange} through a message.
|
|
*
|
|
* @param message the message from which to build the event
|
|
* @since Envoy Common v0.2-alpha
|
|
*/
|
|
public MessageStatusChange(Message message) {
|
|
this(message.getID(), message.getStatus(), Instant.now());
|
|
}
|
|
|
|
/**
|
|
* @return the ID of the {@link Message} this event is related to
|
|
* @since Envoy Common v0.2-alpha
|
|
*/
|
|
public long getID() { return id; }
|
|
|
|
/**
|
|
* @return the date at which the status change occurred
|
|
* @since Envoy Common v0.2-beta
|
|
*/
|
|
public Instant getDate() { return date; }
|
|
|
|
@Override
|
|
public String toString() {
|
|
return String.format("MessageStatusChange[id=%d,status=%s,date=%s]", id, value, date);
|
|
}
|
|
}
|