ValueLookupBase.java

package com.tradecloud.domain;

import com.tradecloud.common.base.PersistenceBase;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Temporal;
import java.util.Date;

/**
 * This is intended as a base class for all data lookup style classes. There is not much that can really be put in here, though possibly a
 * 'X getValue()' method would be a possible addition.
 */
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class ValueLookupBase extends PersistenceBase {

    // Removing for now because I am refactoring this into Rate. Should be put in when that is checked.
    //@NotNull
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date effectiveDate;

    public Date getEffectiveDate() {
        return effectiveDate;
    }

    public void setEffectiveDate(Date effectiveDate) {
        this.effectiveDate = effectiveDate;
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(effectiveDate).toHashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (!(obj instanceof ValueLookupBase)) {
            return false;
        }
        ValueLookupBase other = (ValueLookupBase) obj;
        return new EqualsBuilder().append(effectiveDate, other.effectiveDate).isEquals();
    }
}