LCTemplateMDO.java

package com.tradecloud.dto.letterofcredit.integration;

import java.io.Serializable;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.commons.lang.StringUtils;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "lcTemplate")
public class LCTemplateMDO implements Serializable {

    private String clientKey;
    private String description;
    private String key;
    private String name;
    private String templateExternalStatus;

    public String getClientKey() {
        return clientKey;
    }

    public void setClientKey(String clientKey) {
        this.clientKey = clientKey;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTemplateExternalStatus() {
        return templateExternalStatus;
    }

    public void setTemplateExternalStatus(String templateExternalStatus) {
        this.templateExternalStatus = templateExternalStatus;
    }

    public int hashCode() {
        return StringUtils.isNotBlank(key) ? key.hashCode() : super.hashCode();
    }

    public boolean equals(Object obj) {
        LCTemplateMDO otherMDO = (LCTemplateMDO) obj;

        if (otherMDO != null) {
            String otherKey = otherMDO.getKey();
            String otherClientKey = otherMDO.getClientKey();

            if (StringUtils.isNotBlank(otherClientKey) && StringUtils.isNotBlank(otherKey)
                    && StringUtils.isNotBlank(key) && StringUtils.isNotBlank(clientKey)) {
                return clientKey.equals(otherClientKey) && key.equals(otherKey);
            }

        }

        return false;
    }
}