package envoy.data; import java.io.Serializable; import java.util.Date; /** * Represents a unique user with a unique, numeric ID, a name and a current * {@link UserStatus}.
*
* Project: envoy-common
* File: User.java
* Created: 28.12.2019
* * @author Kai S. K. Engelbart * @since Envoy Common v0.2-alpha */ public class User implements Serializable { /** * This enumeration defines all possible statuses a user can have. * * @since Envoy Common v0.2-alpha */ public static enum UserStatus { /** * select this, if a user is online and can be interacted with */ ONLINE, /** * select this, if a user is online but unavailable at the moment (sudden * interruption) */ AWAY, /** * select this, if a user is online but unavailable at the moment (polite way) */ BUSY, /** * select this, if a user is offline */ OFFLINE; } private long id; private String name; private UserStatus status; private Date lastOnline; private static final long serialVersionUID = 3530947374856708236L; /** * Initializes a {@link User}. The {@link UserStatus} is set to * {@link UserStatus#OFFLINE}. * * @param id unique ID * @param name user name * @since Envoy Common v0.2-alpha */ public User(long id, String name) { this.id = id; this.name = name; status = UserStatus.ONLINE; setLastOnline(new Date()); } /** * Used to let Hibernate modify the values of an {@link User} * * @since Envoy Common v0.2-alpha */ public User() {} @Override public String toString() { return String.format("User[id=%d,name=%s,status=%s]", id, name, status); } /** * @return the ID of this {@link User} * @since Envoy Common v0.2-alpha */ public long getId() { return id; } /** * @return the name of this {@link User} * @since Envoy Common v0.2-alpha */ public String getName() { return name; } /** * @return the current status of this user * @since Envoy Common v0.2-alpha */ public UserStatus getStatus() { return status; } /** * @param status the status to set * @since Envoy Common v0.2-alpha */ public void setStatus(UserStatus status) { this.status = status; } /** * @param id the id to set * @since Envoy Common v0.2-alpha */ public void setId(long id) { this.id = id; } /** * @param name the name to set * @since Envoy Common v0.2-alpha */ public void setName(String name) { this.name = name; } /** * @return the lastOnline * @since Envoy Common v0.2-alpha */ public Date getLastOnline() { return lastOnline; } /** * @param lastOnline the lastOnline to set * @since Envoy Common v0.2-alpha */ public void setLastOnline(Date lastOnline) { this.lastOnline = lastOnline; } }