package cz.vavru.test.dwr.business;

import java.io.Serializable;
import java.util.Date;

/**
 * 
 * @author vlasta
 * 
 */
public class Message implements Serializable {
	static final long serialVersionUID = -7034897190745766939L;

	private int messageId;
	private String text;
	private int senderId;
	private int recipientId;
	private long time;

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public int getSenderId() {
		return senderId;
	}

	public void setSenderId(int senderId) {
		this.senderId = senderId;
	}

	public int getRecipientId() {
		return recipientId;
	}

	public void setRecipientId(int recipientId) {
		this.recipientId = recipientId;
	}

	public long getTime() {
		return time;
	}

	public void setTime(long time) {
		this.time = time;
	}

	public int getMessageId() {
		return messageId;
	}

	public void setMessageId(int messageId) {
		this.messageId = messageId;
	}

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

		Message test = (Message) obj;
		return senderId == test.getSenderId() && recipientId == test.getRecipientId()
				&& (text != null && text.equals(test.getText())) && time == test.getTime();
	}

	@Override
	public int hashCode() {
		return (int)(5 * senderId + 12 * recipientId + time + text.hashCode());
	}

	@Override
	public String toString() {
		return this.getClass().getName() + ": messageId - " + messageId + ", senderId - "
				+ senderId + ", recipientId - " + recipientId + ", time - " + time + recipientId
				+ ", text - " + text;
	}

}
