EffectiveDateConfig.java

package com.tradecloud.domain.rate;

import com.tradecloud.common.base.PersistenceBase;
import com.tradecloud.domain.costing.CostGroup;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

@Entity
@Table(name = "effectivedateconfig")
public class EffectiveDateConfig extends PersistenceBase implements Comparable<EffectiveDateConfig> {

    private static final long serialVersionUID = 1L;

    @NotNull
    @Enumerated(EnumType.STRING)
    private CostGroup costGroup;

    @NotNull
    @Enumerated(EnumType.STRING)
    private EffectiveDateCLC effectiveDateCLC;

    @NotNull
    @Enumerated(EnumType.STRING)
    private EffectiveDateALC effectiveDateALC;

    public CostGroup getCostGroup() {
        return costGroup;
    }

    public void setCostGroup(CostGroup costGroup) {
        this.costGroup = costGroup;
    }

    public EffectiveDateALC getEffectiveDateALC() {
        return effectiveDateALC;
    }

    public void setEffectiveDateALC(EffectiveDateALC effectiveDateALC) {
        this.effectiveDateALC = effectiveDateALC;
    }

    public EffectiveDateCLC getEffectiveDateCLC() {
        return effectiveDateCLC;
    }

    public void setEffectiveDateCLC(EffectiveDateCLC effectiveDateCLC) {
        this.effectiveDateCLC = effectiveDateCLC;
    }

    @Override
    public int compareTo(EffectiveDateConfig o) {
        return getCostGroup().value().compareTo(o.getCostGroup().value());
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null)
            return false;
        if (!(obj instanceof EffectiveDateConfig)) {
            return false;
        }

        EffectiveDateConfig other = (EffectiveDateConfig) obj;

        if (other.getCostGroup() == costGroup && other.getEffectiveDateALC() == effectiveDateALC &&
                other.effectiveDateCLC == effectiveDateCLC)
            return true;

        return false;
    }
}