PlaceOfDischarge.java
package com.tradecloud.domain.place;
import com.tradecloud.domain.common.IntegratedStaticDataEntityBase;
import com.tradecloud.domain.model.shipment.ShippingMode;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
*/
@Entity
@Table(name = "placeofdischarge")
@XmlRootElement(name = "PlaceOfDischarge")
public class PlaceOfDischarge extends IntegratedStaticDataEntityBase {
private static final long serialVersionUID = 1L;
private boolean exportPlace;
private boolean importPlace;
@Enumerated(value = EnumType.STRING)
@XmlAttribute
@NotNull
private ShippingMode shippingMode;
@ManyToOne(fetch = FetchType.LAZY)
@NotNull
private Country country;
@ManyToOne(fetch = FetchType.LAZY)
private Region region;
@ManyToOne(fetch = FetchType.LAZY)
private City city;
public PlaceOfDischarge() {
}
public PlaceOfDischarge(String code, String name, ShippingMode shippingMode, Country country) {
super();
setCode(code);
setName(name);
setActive(true);
setShippingMode(shippingMode);
setCountry(country);
}
public PlaceOfDischarge(String code, String name) {
setCode(code);
setName(name);
setActive(true);
}
public boolean isExportPlace() {
return exportPlace;
}
public void setExportPlace(boolean exportPlace) {
this.exportPlace = exportPlace;
}
public boolean isImportPlace() {
return importPlace;
}
public void setImportPlace(boolean importPlace) {
this.importPlace = importPlace;
}
public ShippingMode getShippingMode() {
return shippingMode;
}
public void setShippingMode(ShippingMode shippingMode) {
this.shippingMode = shippingMode;
}
public Country getCountry() {
return country;
}
public void setCountry(Country country) {
this.country = country;
}
public Region getRegion() {
return region;
}
public void setRegion(Region region) {
this.region = region;
}
@Override
public int hashCode() {
return new HashCodeBuilder()
.append(getName())
.append(getActive())
.append(getCode())
//.append(getCountry().getCode())
.append(getShippingMode())
.toHashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof PlaceOfDischarge)) {
return false;
}
PlaceOfDischarge other = (PlaceOfDischarge) obj;
return new EqualsBuilder()
.append(getCode(), other.getCode())
.append(getName(), other.getName())
.append(getActive(), other.getActive())
.append(getShippingMode(), other.getShippingMode())
//.append(getCountry().getCode(), other.getCountry().getCode())
.isEquals();
}
@Override
public String toString() {
return "PlaceOfDischarge [shippingMode=" + shippingMode + /*", country=" + country.getCode() + ", getCode()=" + getCode() +*/ ", getName()="
+ getName() + ", getActive()=" + getActive() + ", getClass()=" + getClass() + "]";
}
public City getCity() {
return city;
}
public void setCity(City city) {
this.city = city;
}
}