2019-12-28 21:03:41 +01:00
|
|
|
package envoy.data;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a unique user with a unique, numeric ID, a name and a current
|
|
|
|
* {@link UserStatus}.<br>
|
|
|
|
* <br>
|
|
|
|
* Project: <strong>envoy-common</strong><br>
|
|
|
|
* File: <strong>User.java</strong><br>
|
|
|
|
* Created: <strong>28.12.2019</strong><br>
|
2019-12-30 18:49:48 +01:00
|
|
|
*
|
2019-12-28 21:03:41 +01:00
|
|
|
* @author Kai S. K. Engelbart
|
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
|
|
|
public class User implements Serializable {
|
|
|
|
|
2019-12-30 18:49:48 +01:00
|
|
|
/**
|
2019-12-31 10:16:52 +01:00
|
|
|
* This enumeration defines all possible statuses a user can have.
|
2019-12-30 18:49:48 +01:00
|
|
|
*
|
|
|
|
* @since Envoy Common v0.2-alpha
|
|
|
|
*/
|
|
|
|
public static enum UserStatus {
|
2019-12-28 21:03:41 +01:00
|
|
|
|
2019-12-30 18:49:48 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
2019-12-28 21:03:41 +01:00
|
|
|
|
2020-01-02 17:50:04 +01:00
|
|
|
private final long id;
|
|
|
|
private final String name;
|
|
|
|
|
|
|
|
private UserStatus status;
|
2019-12-30 18:49:48 +01:00
|
|
|
|
2019-12-31 10:16:52 +01:00
|
|
|
private static final long serialVersionUID = 3530947374856708236L;
|
|
|
|
|
2019-12-28 21:03:41 +01:00
|
|
|
/**
|
|
|
|
* Initializes a {@link User}. The {@link UserStatus} is set to
|
|
|
|
* {@link UserStatus#OFFLINE}.
|
2019-12-30 18:49:48 +01:00
|
|
|
*
|
2019-12-28 21:03:41 +01:00
|
|
|
* @param id unique ID
|
|
|
|
* @param name user name
|
2020-01-01 19:16:40 +01:00
|
|
|
* @since Envoy Common v0.2-alpha
|
2019-12-28 21:03:41 +01:00
|
|
|
*/
|
|
|
|
public User(long id, String name) {
|
|
|
|
this.id = id;
|
|
|
|
this.name = name;
|
2020-01-01 19:16:40 +01:00
|
|
|
status = UserStatus.ONLINE;
|
2019-12-28 21:03:41 +01:00
|
|
|
}
|
|
|
|
|
2019-12-31 10:20:35 +01:00
|
|
|
@Override
|
|
|
|
public String toString() { return String.format("User[id=%d,name=%s,status=%s]", id, name, status); }
|
|
|
|
|
2019-12-28 21:03:41 +01:00
|
|
|
/**
|
|
|
|
* @return the ID of this {@link User}
|
2020-01-01 19:16:40 +01:00
|
|
|
* @since Envoy Common v0.2-alpha
|
2019-12-28 21:03:41 +01:00
|
|
|
*/
|
|
|
|
public long getId() { return id; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the name of this {@link User}
|
2020-01-01 19:16:40 +01:00
|
|
|
* @since Envoy Common v0.2-alpha
|
2019-12-28 21:03:41 +01:00
|
|
|
*/
|
|
|
|
public String getName() { return name; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the current status of this user
|
2020-01-01 19:16:40 +01:00
|
|
|
* @since Envoy Common v0.2-alpha
|
2019-12-28 21:03:41 +01:00
|
|
|
*/
|
|
|
|
public UserStatus getStatus() { return status; }
|
|
|
|
|
|
|
|
/**
|
2020-01-02 17:50:04 +01:00
|
|
|
* @param status the next status of this user
|
2020-01-01 19:16:40 +01:00
|
|
|
* @since Envoy Common v0.2-alpha
|
2019-12-28 21:03:41 +01:00
|
|
|
*/
|
|
|
|
public void setStatus(UserStatus status) { this.status = status; }
|
|
|
|
}
|