Improved Message.java and User.java to remain compatible with database
This commit is contained in:
		@@ -48,11 +48,11 @@ public class Message implements Serializable {
 | 
				
			|||||||
		READ
 | 
							READ
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private final long					id, senderId, recipientId;
 | 
						private long					id, senderId, recipientId;
 | 
				
			||||||
	private final transient User		sender, recipient;
 | 
						private transient User			sender, recipient;
 | 
				
			||||||
	private final Date					date;
 | 
						private Date					date;
 | 
				
			||||||
	private final String				text;
 | 
						private String					text;
 | 
				
			||||||
	private final MessageAttachment<?>	attachment;
 | 
						private MessageAttachment<?>	attachment;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private MessageStatus status;
 | 
						private MessageStatus status;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -168,4 +168,74 @@ public class Message implements Serializable {
 | 
				
			|||||||
	 * @since Envoy Common v0.2-alpha
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public MessageStatus getStatus() { return status; }
 | 
						public MessageStatus getStatus() { return status; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Only used for Hibernate. Please do not use.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param id the id to set
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setId(long id) { this.id = id; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Only used for Hibernate. Please do not use.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param senderId the senderId to set
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setSenderId(long senderId) { this.senderId = senderId; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Only used for Hibernate. Please do not use.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param recipientId the recipientId to set
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setRecipientId(long recipientId) { this.recipientId = recipientId; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Only used for Hibernate. Please do not use.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param sender the sender to set
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setSender(User sender) { this.sender = sender; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Only used for Hibernate. Please do not use.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param recipient the recipient to set
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setRecipient(User recipient) { this.recipient = recipient; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Only used for Hibernate. Please do not use.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param date the date to set
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setDate(Date date) { this.date = date; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Only used for Hibernate. Please do not use.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param text the text to set
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setText(String text) { this.text = text; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Only used for Hibernate. Please do not use.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param attachment the attachment to set
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setAttachment(MessageAttachment<?> attachment) { this.attachment = attachment; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * @param status the status to set
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setStatus(MessageStatus status) { this.status = status; }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1,8 +1,7 @@
 | 
				
			|||||||
package envoy.data;
 | 
					package envoy.data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.Serializable;
 | 
					import java.io.Serializable;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.Date;
 | 
				
			||||||
import java.util.List;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Represents a unique user with a unique, numeric ID, a name and a current
 | 
					 * Represents a unique user with a unique, numeric ID, a name and a current
 | 
				
			||||||
@@ -46,11 +45,10 @@ public class User implements Serializable {
 | 
				
			|||||||
		OFFLINE;
 | 
							OFFLINE;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private final long			id;
 | 
						private long		id;
 | 
				
			||||||
	private final String		name;
 | 
						private String		name;
 | 
				
			||||||
	private final List<User>	contacts	= new ArrayList<>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private UserStatus	status;
 | 
						private UserStatus	status;
 | 
				
			||||||
 | 
						private Date		lastOnline;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private static final long serialVersionUID = 3530947374856708236L;
 | 
						private static final long serialVersionUID = 3530947374856708236L;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -60,46 +58,70 @@ public class User implements Serializable {
 | 
				
			|||||||
	 *
 | 
						 *
 | 
				
			||||||
	 * @param id   unique ID
 | 
						 * @param id   unique ID
 | 
				
			||||||
	 * @param name user name
 | 
						 * @param name user name
 | 
				
			||||||
	 * @since Envoy Client v0.2-alpha
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public User(long id, String name) {
 | 
						public User(long id, String name) {
 | 
				
			||||||
		this.id		= id;
 | 
							this.id		= id;
 | 
				
			||||||
		this.name	= name;
 | 
							this.name	= name;
 | 
				
			||||||
		status		= UserStatus.OFFLINE;
 | 
							status		= UserStatus.ONLINE;
 | 
				
			||||||
 | 
							setLastOnline(new Date());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Used to let Hibernate modify the values of an {@link User}
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public User() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String toString() { return String.format("User[id=%d,name=%s,status=%s]", id, name, status); }
 | 
						public String toString() { return String.format("User[id=%d,name=%s,status=%s]", id, name, status); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * @return the ID of this {@link User}
 | 
						 * @return the ID of this {@link User}
 | 
				
			||||||
	 * @since Envoy Client v0.2-alpha
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public long getId() { return id; }
 | 
						public long getId() { return id; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * @return the name of this {@link User}
 | 
						 * @return the name of this {@link User}
 | 
				
			||||||
	 * @since Envoy Client v0.2-alpha
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public String getName() { return name; }
 | 
						public String getName() { return name; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * @return a list of all users this user can send messages to
 | 
					 | 
				
			||||||
	 * @since Envoy Client v0.2-alpha
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public List<User> getContacts() { return contacts; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * @return the current status of this user
 | 
						 * @return the current status of this user
 | 
				
			||||||
	 * @since Envoy Client v0.2-alpha
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public UserStatus getStatus() { return status; }
 | 
						public UserStatus getStatus() { return status; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Sets the current status of this user
 | 
					 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @param status the status to set
 | 
						 * @param status the status to set
 | 
				
			||||||
	 * @since Envoy Client v0.2-alpha
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public void setStatus(UserStatus status) { this.status = status; }
 | 
						public void setStatus(UserStatus status) { this.status = status; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * @param id the id to set
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setId(long id) { this.id = id; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * @param name the name to set
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setName(String name) { this.name = name; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * @return the lastOnline
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public Date getLastOnline() { return lastOnline; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * @param lastOnline the lastOnline to set
 | 
				
			||||||
 | 
						 * @since Envoy Common v0.2-alpha
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setLastOnline(Date lastOnline) { this.lastOnline = lastOnline; }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user