package pizza.domain; // Generated Oct 17, 2007 1:40:55 PM by Hibernate Tools 3.2.0.beta8 import java.util.HashSet; import java.util.Set; import pizza.domain.PizzaOrder; /** * PizzaOrder generated by hbm2java */ public class PizzaOrder implements java.io.Serializable { // Fields private int id; private PizzaSize pizzaSize; private int roomNumber; private int day; private int status; private Set toppings = new HashSet(0); // ADDED: pizza order status values-- static final long serialVersionUID = 3; public static final int PREPARING = 1; public static final int BAKED = 2; public static final int FINISHED = 3; public static final int NO_SUCH_ORDER = 0; private static final String[] STATUS_NAME = { "NO_SUCH_ORDER", "PREPARING", "BAKED", "FINISHED" }; // Constructors /** default constructor */ public PizzaOrder() { } /** minimal constructor */ public PizzaOrder(int id, PizzaSize pizzaSize, int roomNumber, int day, int status) { this.id = id; this.pizzaSize = pizzaSize; this.roomNumber = roomNumber; this.day = day; this.status = status; } /** full constructor */ public PizzaOrder(int id, PizzaSize pizzaSize, int roomNumber, int day, int status, Set toppings) { this.id = id; this.pizzaSize = pizzaSize; this.roomNumber = roomNumber; this.day = day; this.status = status; this.toppings = toppings; } // Property accessors public int getId() { return this.id; } public void setId(int id) { this.id = id; } public PizzaSize getPizzaSize() { return this.pizzaSize; } public void setPizzaSize(PizzaSize pizzaSize) { this.pizzaSize = pizzaSize; } public int getRoomNumber() { return this.roomNumber; } public void setRoomNumber(int roomNumber) { this.roomNumber = roomNumber; } public int getDay() { return this.day; } public void setDay(int day) { this.day = day; } public int getStatus() { return this.status; } public void setStatus(int status) { this.status = status; } public Set getToppings() { return this.toppings; } public void setToppings(Set toppings) { this.toppings = toppings; } //ADDED: // string equivalent of status code public String getStatusString() { return STATUS_NAME[status]; } public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("ORDER ID: " + getId() + "\n"); buffer.append("ORDER DAY: " + getDay() + "\n"); buffer.append("SIZE: " + (getPizzaSize() != null?getPizzaSize().getSizeName():"not available") + "\n"); buffer.append("ROOM NUMBER: " + getRoomNumber() + "\n"); buffer.append("STATUS: " + getStatus()); return buffer.toString(); } // to allow HashSet-- public Boolean equals(PizzaOrder x) { return id == x.getId(); } public int hashCode() { return ((Integer)(id)).hashCode(); } }