package envoy.data; import java.io.Serializable; /** * 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 { private final long id; private final String name; private UserStatus status; 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 Client v0.2-alpha */ public User(long id, String name) { this.id = id; this.name = name; status = UserStatus.OFFLINE; } @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 Client v0.2-alpha */ public long getId() { return id; } /** * @return the name of this {@link User} * @since Envoy Client v0.2-alpha */ public String getName() { return name; } /** * @return the current status of this user * @since Envoy Client v0.2-alpha */ public UserStatus getStatus() { return status; } /** * Sets the current status of this user * * @param status the status to set * @since Envoy Client v0.2-alpha */ public void setStatus(UserStatus status) { this.status = status; } public static enum UserStatus { ONLINE, AWAY, BUSY, OFFLINE; } }