Property.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 org.springframework.stereotype.Component;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@SuppressWarnings("serial")
@Entity
@Component(value = "Property")
@Table(name = "property")
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Property")
public class Property extends PersistenceBase implements Comparable<Property> {
private String value;
@OneToOne
PropertyConfig propertyConfig;
public void setValue(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public PropertyConfig getPropertyConfig() {
return propertyConfig;
}
public void setPropertyConfig(PropertyConfig propertyConfig) {
this.propertyConfig = propertyConfig;
}
@Override
public boolean equals(final Object other) {
if (!(other instanceof Property))
return false;
Property castOther = (Property) other;
return new EqualsBuilder().append(getPropertyConfig(), castOther.getPropertyConfig())
.append(getCreated() != null ? getCreated().getTime() : -1, castOther.getCreated() != null ? castOther.getCreated().getTime() : -1)
.append(getId(), castOther.getId()).append(getValue(), castOther.getValue()).isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder().append(getId()).append(getValue()).append(getCreated()).append(getPropertyConfig()).toHashCode();
}
@Override
public int compareTo(Property o) {
if (o != null && o.getPropertyConfig() != null && this.getPropertyConfig() != null
&& o.getPropertyConfig().getName() != null && this.getPropertyConfig().getName() != null) {
return this.getPropertyConfig().getName().toLowerCase().compareTo(o.getPropertyConfig().getName().toLowerCase());
}
return 0;
}
}