01: package org.drools;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import java.io.Serializable;
20:
21: public class Cheese implements Serializable {
22: /**
23: *
24: */
25: private static final long serialVersionUID = 400L;
26: private String type;
27: private int price;
28:
29: public Cheese() {
30:
31: }
32:
33: public Cheese(final String type, final int price) {
34: super ();
35: this .type = type;
36: this .price = price;
37: }
38:
39: public int getPrice() {
40: return this .price;
41: }
42:
43: public String getType() {
44: return this .type;
45: }
46:
47: public void setType(final String type) {
48: this .type = type;
49: }
50:
51: public void setPrice(final int price) {
52: this .price = price;
53: }
54:
55: public String toString() {
56: return "Cheese( type='" + this .type + "', price=" + this .price
57: + " )";
58: }
59:
60: public int hashCode() {
61: final int PRIME = 31;
62: int result = 1;
63: result = PRIME * result + price;
64: result = PRIME * result
65: + ((type == null) ? 0 : type.hashCode());
66: return result;
67: }
68:
69: public boolean equals(Object obj) {
70: if (this == obj)
71: return true;
72: if (obj == null)
73: return false;
74: if (getClass() != obj.getClass())
75: return false;
76: final Cheese other = (Cheese) obj;
77: if (price != other.price)
78: return false;
79: if (type == null) {
80: if (other.type != null)
81: return false;
82: } else if (!type.equals(other.type))
83: return false;
84: return true;
85: }
86:
87: }
|