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