<commit_before>package hu.sch.domain.user;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.validation.constraints.Size;

/**
 *
 * @author balo
 */
@Entity
@Table(name = "lostpw_tokens")
@NamedQueries({
    @NamedQuery(name = LostPasswordToken.getByToken,
            query = "SELECT t FROM LostPasswordToken t WHERE t.token = :token"
    ),
    @NamedQuery(name = LostPasswordToken.removeExpired,
            query = "DELETE FROM LostPasswordToken t "
            + "WHERE t.created < :time_in_past"
    )
})
public class LostPasswordToken implements Serializable {

    public static final String getByToken = "getByToken";
    public static final String removeExpired = "removeExpired";
    //
    @Id
    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "usr_id")
    private User subjectUser;
    //--------------------------------
    @Column(length = 64, unique = true)
    @Size(max = 64)
    private String token;
    //--------------------------------
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Date created;

    public LostPasswordToken() {
    }

    public LostPasswordToken(final User subjectUser, final String token,
            final Date created) {

        this.subjectUser = subjectUser;
        this.token = token;
        this.created = new Date(created.getTime());
    }

    public User getSubjectUser() {
        return subjectUser;
    }

    public String getToken() {
        return token;
    }

    public Date getCreated() {
        return created;
    }
}<commit_msg>Add equals and hashCode methods to LostPasswordToken (#80)<commit_after>package hu.sch.domain.user;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.validation.constraints.Size;

/**
 *
 * @author balo
 */
@Entity
@Table(name = "lostpw_tokens")
@NamedQueries({
    @NamedQuery(name = LostPasswordToken.getByToken,
            query = "SELECT t FROM LostPasswordToken t WHERE t.token = :token"
    ),
    @NamedQuery(name = LostPasswordToken.removeExpired,
            query = "DELETE FROM LostPasswordToken t "
            + "WHERE t.created < :time_in_past"
    )
})
public class LostPasswordToken implements Serializable {

    public static final String getByToken = "getByToken";
    public static final String removeExpired = "removeExpired";
    //
    @Id
    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "usr_id")
    private User subjectUser;
    //--------------------------------
    @Column(length = 64, unique = true)
    @Size(max = 64)
    private String token;
    //--------------------------------
    @Temporal(javax.persistence.TemporalType.TIMESTAMP)
    private Date created;

    public LostPasswordToken() {
    }

    public LostPasswordToken(final User subjectUser, final String token,
            final Date created) {

        this.subjectUser = subjectUser;
        this.token = token;
        this.created = new Date(created.getTime());
    }

    public User getSubjectUser() {
        return subjectUser;
    }

    public String getToken() {
        return token;
    }

    public Date getCreated() {
        return created;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + Objects.hashCode(this.subjectUser);
        hash = 59 * hash + Objects.hashCode(this.token);
        hash = 59 * hash + Objects.hashCode(this.created);
        return hash;
    }

    @Override
    public boolean equals(final Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final LostPasswordToken other = (LostPasswordToken) obj;
        if (!Objects.equals(this.subjectUser, other.subjectUser)) {
            return false;
        }
        if (!Objects.equals(this.token, other.token)) {
            return false;
        }
        if (!Objects.equals(this.created, other.created)) {
            return false;
        }
        return true;
    }

}
{'fraction_non_alphanumeric': 0.12555579081092527, 'fraction_numerical': 0.0035994071564683463, 'mean_word_length': 2.5280059746079164, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '419593', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1318, 'n_words': 322}