Merge pull request #8 from informatik-ag-ngl/f/user_status_change_event

Added UserStatusChangeEvent
This commit is contained in:
delvh 2020-02-04 21:28:33 +01:00 committed by GitHub
commit df54547ae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 0 deletions

View File

@ -61,4 +61,7 @@ public class MessageStatusChangeEvent implements Event<Message.MessageStatus> {
* @since Envoy Common v0.2-alpha
*/
public Date getDate() { return date; }
@Override
public String toString() { return String.format("MessageStatusChangeEvent[id=%d,status=%s,date=%s]", id, status, date); }
}

View File

@ -0,0 +1,57 @@
package envoy.event;
import envoy.data.User;
import envoy.data.User.UserStatus;
/**
* Project: <strong>envoy-common</strong><br>
* File: <strong>UserStatusChangeEvent.java</strong><br>
* Created: <strong>1 Feb 2020</strong><br>
*
* @author Leon Hofmeister
* @since Envoy Common v0.2-alpha
*/
public class UserStatusChangeEvent implements Event<UserStatus> {
private final long id;
private final User.UserStatus status;
private static final long serialVersionUID = 4566145392192761313L;
/**
* Initializes a {@link UserStatusChangeEvent}.
*
* @param id the ID of the {@link User} this event is related to
* @param status the status of the {@link User} this event is related
* to
* @since Envoy Common v0.2-alpha
*/
public UserStatusChangeEvent(long id, User.UserStatus status) {
this.id = id;
this.status = status;
}
/**
* Initializes a {@link UserStatusChangeEvent} through a User.
*
* @param user the User from which to build the event
* @since Envoy Common v0.2-alpha
*/
public UserStatusChangeEvent(User user) { this(user.getId(), user.getStatus()); }
/**
* @return the status of the {@link User} this event is related to
* @since Envoy Common v0.2-alpha
*/
@Override
public User.UserStatus get() { return status; }
/**
* @return the ID of the {@link User} this event is related to
* @since Envoy Common v0.2-alpha
*/
public long getId() { return id; }
@Override
public String toString() { return String.format("UserStatusChangeEvent[id=%d,status=%s]", id, status); }
}