package cz.vavru.test.dwr.domain;

import java.io.Serializable;

/**
 * 
 * @author vlastimil@vavru.cz (http://vavru.cz)
 * 
 */
public class User implements Serializable {
	static final long serialVersionUID = -7034897190745766939L;

	private int userId;
	private String nick;
	private boolean isOnline;

	public boolean isOnline() {
		return isOnline;
	}

	public void setOnline(boolean isOnline) {
		this.isOnline = isOnline;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getNick() {
		return nick;
	}

	public void setNick(String nick) {
		this.nick = nick;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if ((obj == null) || (obj.getClass() != this.getClass()))
			return false;

		User test = (User) obj;
		return userId == test.getUserId() && (nick != null && nick.equals(test.getNick()));
	}

	@Override
	public int hashCode() {
		return 5 * userId + nick.hashCode();
	}

	@Override
	public String toString() {
		return this.getClass().getName() + ": id - " + userId + ", nick - " + nick;
	}
}
