package data;
import java.util.*;
import data.*;
public class Customer implements java.io.Serializable {
public Customer() {
purchaseOrderSet = new HashSet();
}
public Customer(Integer id) {
setId(id);
}
public Customer(Customer o) {
setId(o.getId());
setName(o.getName());
setPurchaseOrderSet(o.getPurchaseOrderSet());
}
public Customer(Integer id, String name, Set purchaseOrderSet) {
setId(id);
setName(name);
setPurchaseOrderSet(purchaseOrderSet);
}
public void setData(Customer o) {
setName(o.getName());
}
protected Integer id;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
protected String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
protected Set purchaseOrderSet;
public Set getPurchaseOrderSet() {
return purchaseOrderSet;
}
public void setPurchaseOrderSet(Set purchaseOrderSet) {
this.purchaseOrderSet = purchaseOrderSet;
}
public void addPurchaseOrder(PurchaseOrder purchaseOrder) {
purchaseOrderSet.add(purchaseOrder);
}
public String toString() {
StringBuffer sb = new StringBuffer(super.toString());
sb.append("[");
sb.append(id);
sb.append(", ");
sb.append(name);
sb.append("]");
return sb.toString();
}
public String toDisplayString() {
StringBuffer sb = new StringBuffer();
sb.append(name == null ? "" : name.toString());
return sb.toString();
}
public boolean equals(Object other) {
if (this == other) return true;
if (!(other instanceof Customer)) return false;
if(!super.equals(other)) return false;
final Customer o = (Customer) other;
if(o.getName() == null) {
if (getName() != null) return false;
}
else if (!o.getName().equals(getName()))
return false;
return true;
}
public int hashCode() {
int res = 0;
if(getName() != null)
res = 29 * res + getName().hashCode();
return res;
}
}