01: /**
02: * Copyright 2007 Jens Dietrich Licensed under the Apache License, Version 2.0 (the "License");
03: * you may not use this file except in compliance with the License.
04: * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
05: * Unless required by applicable law or agreed to in writing, software distributed under the
06: * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
07: * either express or implied. See the License for the specific language governing permissions
08: * and limitations under the License.
09: */package test.nz.org.take.compiler.misc1;
10:
11: /**
12: * Bean class referenced in tests.
13: * @author <a href="http://www-ist.massey.ac.nz/JBDietrich/">Jens Dietrich</a>
14: */
15: public class Person {
16:
17: private String name = null;
18: private String firstName = null;
19:
20: public Person(String firstName, String name) {
21: super ();
22: this .name = name;
23: this .firstName = firstName;
24: }
25:
26: public String getName() {
27: return name;
28: }
29:
30: public void setName(String name) {
31: this .name = name;
32: }
33:
34: public String getFirstName() {
35: return firstName;
36: }
37:
38: public void setFirstName(String firstName) {
39: this .firstName = firstName;
40: }
41:
42: @Override
43: public int hashCode() {
44: final int PRIME = 31;
45: int result = 1;
46: result = PRIME * result
47: + ((firstName == null) ? 0 : firstName.hashCode());
48: result = PRIME * result
49: + ((name == null) ? 0 : name.hashCode());
50: return result;
51: }
52:
53: @Override
54: public boolean equals(Object obj) {
55: if (this == obj)
56: return true;
57: if (obj == null)
58: return false;
59: if (getClass() != obj.getClass())
60: return false;
61: final Person other = (Person) obj;
62: if (firstName == null) {
63: if (other.firstName != null)
64: return false;
65: } else if (!firstName.equals(other.firstName))
66: return false;
67: if (name == null) {
68: if (other.name != null)
69: return false;
70: } else if (!name.equals(other.name))
71: return false;
72: return true;
73: }
74: }
|