01: package org.mvel.tests.main.res;
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 Cheese implements Serializable {
22:
23: public static final String STILTON = "stilton";
24:
25: /**
26: *
27: */
28: private static final long serialVersionUID = -1187540653710115339L;
29: private String type;
30: private int price;
31:
32: public Cheese() {
33:
34: }
35:
36: public Cheese(final String type, final int price) {
37: super ();
38: this .type = type;
39: this .price = price;
40: }
41:
42: public int getPrice() {
43: return this .price;
44: }
45:
46: public String getType() {
47: return this .type;
48: }
49:
50: public void setType(final String type) {
51: this .type = type;
52: }
53:
54: public void setPrice(final int price) {
55: this .price = price;
56: }
57:
58: public String toString() {
59: return "Cheese( type='" + this .type + "', price=" + this .price
60: + " )";
61: }
62:
63: public int hashCode() {
64: final int PRIME = 31;
65: int result = 1;
66: result = PRIME * result + price;
67: result = PRIME * result
68: + ((type == null) ? 0 : type.hashCode());
69: return result;
70: }
71:
72: public boolean equals(Object obj) {
73: if (this == obj)
74: return true;
75: if (obj == null)
76: return false;
77: if (getClass() != obj.getClass())
78: return false;
79: final Cheese other = (Cheese) obj;
80: if (price != other.price)
81: return false;
82: if (type == null) {
83: if (other.type != null)
84: return false;
85: } else if (!type.equals(other.type))
86: return false;
87: return true;
88: }
89:
90: }
|