package ca.corefacility.bioinformatics.irida.model;

import java.util.Date;
import java.util.UUID;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * A password reset object.
 * 
 * @author Josh Adam <josh.adam@phac-aspc.gc.ca>
 */
@Entity
@Table(name = "password_reset")
public class PasswordReset implements Comparable<PasswordReset> {

	@NotNull
	@Temporal(TemporalType.TIMESTAMP)
	private Date createdDate;

	@OneToOne
	@NotNull
	private User user;

	@Id
	@NotNull
	private String id;

	protected PasswordReset() {}

	public PasswordReset(User user) {
		this.createdDate = new Date();
		this.user = user;
		this.id = UUID.randomUUID().toString();
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public User getUser() {
		return user;
	}

	public String getId() {
		return this.id;
	}

	@Override
	public int compareTo(PasswordReset passwordReset) {
		return createdDate.compareTo(passwordReset.createdDate);
	}
}

@@ -69,16 +69,42 @@
 l.Date;%0A
+import java.util.Objects;%0A
 import j
@@ -118,16 +118,16 @@
 l.UUID;%0A
-
 %0Aimport 
@@ -568,16 +568,18 @@
 eset() %7B
+%0A%09
 %7D%0A%0A%09publ
@@ -916,24 +916,24 @@
 ordReset) %7B%0A
-
 %09%09return cre
@@ -981,11 +981,373 @@
 ate);%0A%09%7D
+%0A%0A%09@Override%0A%09public int hashCode() %7B%0A%09%09return Objects.hash(createdDate, user, id);%0A%09%7D%0A%0A%09@Override%0A%09public boolean equals(Object other) %7B%0A%09%09if (other instanceof Project) %7B%0A%09%09%09PasswordReset p = (PasswordReset) other;%0A%09%09%09return Objects.equals(createdDate, p.createdDate) && Objects.equals(user, p.user)%0A%09%09%09%09%09&&%09%09%09%09%09Objects.equals(id, p.id);%0A%09%09%7D%0A%0A%09%09return false;%0A%09%7D
 %0A%7D%0A

Add hashCode and equals methods.