PropertyConfig.java

package com.tradecloud.domain.dms;

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

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

@SuppressWarnings("serial")
@Entity
@Table(name = "propertyconfig")
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "PropertyConfig")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class PropertyConfig extends PersistenceBase implements Comparable<PropertyConfig> {

    private String name;

    private String xpathExpression;

    public String getName() {
        return name;
    }

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

    @Override
    public boolean equals(final Object other) {
        if (!(other instanceof PropertyConfig))
            return false;
        PropertyConfig castOther = (PropertyConfig) other;
        return new EqualsBuilder().append(getId(), castOther.getId())
                .append(getCreated() != null ? getCreated().getTime() : -1, castOther.getCreated() != null ? castOther.getCreated().getTime() : -1)
                .append(getName(), castOther.getName()).isEquals();
    }

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

    public void setXpathExpression(String xpathExpression) {
        this.xpathExpression = xpathExpression;
    }

    public String getXpathExpression() {
        return xpathExpression;
    }

    @Override
    public int compareTo(PropertyConfig o) {
        if (o != null && o.getName() != null && this.getName() != null) {
            return this.getName().toLowerCase().compareTo(o.getName().toLowerCase());
        }
        return 0;
    }

}