Region.java
package com.tradecloud.domain.place;
import com.tradecloud.common.base.StaticDataEntityBase;
import com.tradecloud.domain.common.IntegratedStaticDataEntityBase;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
/**
* Region representation.
*/
@Entity
@Table(name = "region", uniqueConstraints = {@UniqueConstraint(columnNames = {"code"})})
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "Region")
//@Cacheable(value = "region")
public class Region extends IntegratedStaticDataEntityBase {
/**
* UID.
*/
private static final long serialVersionUID = 1L;
private static final int REGION_CODE_LENGTH = 3;
public Region() {
}
public Region(String regionCode) {
this(regionCode, null);
}
public Region(String regionCode, String regionName) {
if (regionCode.length() != REGION_CODE_LENGTH) {
//throw new IllegalArgumentException("City code must be of length 3");
}
setCode(regionCode);
setName(regionName);
}
@Override
public int compareTo(StaticDataEntityBase o) {
if (getName() != null && o.getName() != null) {
return getName().compareToIgnoreCase(o.getName());
}
return 0;
}
}