package fr.insa.clavardator.lib.users;

import fr.insa.clavardator.lib.message.SenderInfo;

import java.io.Serializable;

/**
 * Class used to serialize useful user information
 */
public class UserInformation implements Serializable, SenderInfo {
	public final String id;
	private final String username;
	private final UserState state;

	public UserInformation(String id, String username) {
		this.id = id;
		this.username = username;
		this.state = UserState.CONNECTED;
	}

	public UserInformation(String id, String username, UserState state) {
		this.id = id;
		this.username = username;
		this.state = state;
	}

	public UserInformation(User user) {
		this.id = user.getId();
		this.username = user.getUsername();
		this.state = UserState.CONNECTED;
	}

	public UserInformation(User user, UserState state) {
		this.id = user.getId();
		this.username = user.getUsername();
		this.state = state;
	}

	public String getUsername() {
		return username;
	}

	public UserState getState() {
		return state;
	}

	@Override
	public String toString() {
		return "UserInfo " + id + '(' + username + ')';
	}

	@Override
	public String getSenderId() {
		return id;
	}
}
