001: /*
002: * Copyright 2006 JBoss Inc
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.drools;
018:
019: import java.util.Collection;
020: import java.util.HashMap;
021: import java.util.Map;
022:
023: /**
024: * @author etirelli
025: *
026: */
027: public class Order {
028:
029: private int number;
030:
031: private String customer;
032:
033: private Map items;
034:
035: public Order() {
036: this (0, "Bob");
037: }
038:
039: public Order(final int number, String customer) {
040: this .number = number;
041: this .items = new HashMap();
042: this .customer = customer;
043: }
044:
045: /**
046: * @return the number
047: */
048: public int getNumber() {
049: return this .number;
050: }
051:
052: /**
053: * @param number the number to set
054: */
055: public void setNumber(final int number) {
056: this .number = number;
057: }
058:
059: public Map getItems() {
060: return this .items;
061: }
062:
063: public Collection getItemsValues() {
064: return this .items.values();
065: }
066:
067: public Collection getItemsKeys() {
068: return this .items.keySet();
069: }
070:
071: public void addItem(OrderItem item) {
072: this .items.put(new Integer(item.getSeq()), item);
073: }
074:
075: /* (non-Javadoc)
076: * @see java.lang.Object#hashCode()
077: */
078: public int hashCode() {
079: final int PRIME = 31;
080: int result = 1;
081: result = PRIME * result + this .number;
082: return result;
083: }
084:
085: /* (non-Javadoc)
086: * @see java.lang.Object#equals(java.lang.Object)
087: */
088: public boolean equals(final Object obj) {
089: if (this == obj) {
090: return true;
091: }
092: if (obj == null) {
093: return false;
094: }
095: if (getClass() != obj.getClass()) {
096: return false;
097: }
098: final Order other = (Order) obj;
099: if (this .number != other.number) {
100: return false;
101: }
102: return true;
103: }
104:
105: public String getCustomer() {
106: return customer;
107: }
108:
109: public void setCustomer(String customer) {
110: this.customer = customer;
111: }
112:
113: }
|