EmployeeRole.java

package com.tradecloud.domain.party;

import com.tradecloud.common.base.StaticDataEntityBase;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

@Entity
@Table(name = "employeerole")
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
//@Cacheable(value = "employeeRole")
public class EmployeeRole extends StaticDataEntityBase {

    private static final long serialVersionUID = 1L;
    /**
     * Some static strings used to represent roles known to the system.
     * <p>
     * This is not an exhaustive list as roles can be added by users through the UI
     */
    public static final String BUYER = "BUYER";
    public static final String SELLER = "SELLER";
    public static final String CONTACT = "CONTACT";
    public static final String DRIVER = "DRIVER";
    public static final String DECLARER = "DECLARER";
    public static final String SHIPPING_CONTROLLER = " SHIPPING_CONTROLLER";

    protected EmployeeRole() {
    }

    public EmployeeRole(String roleCode) {
        super(roleCode);
    }

    public EmployeeRole(String roleCode, String description) {
        super(roleCode, description);
    }

    @Override
    public int hashCode() {
        return getCode().hashCode();
    }

    @Override
    public boolean equals(Object other) {
        if (!(other instanceof EmployeeRole)) {
            return false;
        }
        EmployeeRole castOther = (EmployeeRole) other;
        return getCode().equals(castOther.getCode());
    }

    @Override
    public String toString() {
        return getCode();
    }

    public int compareTo(EmployeeRole otherRole) {
        return getCode().compareTo(otherRole.getCode());
    }
}