View Javadoc

1   /**
2    * Copyright (c) 2008-2011, http://www.snakeyaml.org
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.yaml.snakeyaml.recursive;
18  
19  import java.util.Date;
20  
21  public abstract class AbstractHuman {
22      private String name;
23      private Date birthday;
24      private String birthPlace;
25  
26      public String getName() {
27          return name;
28      }
29  
30      public void setName(String name) {
31          this.name = name;
32      }
33  
34      public Date getBirthday() {
35          return birthday;
36      }
37  
38      public void setBirthday(Date birthday) {
39          this.birthday = birthday;
40      }
41  
42      public String getBirthPlace() {
43          return birthPlace;
44      }
45  
46      public void setBirthPlace(String birthPlace) {
47          this.birthPlace = birthPlace;
48      }
49  
50      @Override
51      public int hashCode() {
52          final int prime = 31;
53          int result = 1;
54          result = prime * result + ((birthPlace == null) ? 0 : birthPlace.hashCode());
55          result = prime * result + ((birthday == null) ? 0 : birthday.hashCode());
56          result = prime * result + ((name == null) ? 0 : name.hashCode());
57          return result;
58      }
59  
60      @Override
61      public boolean equals(Object obj) {
62          if (this == obj)
63              return true;
64          if (obj == null)
65              return false;
66          if (getClass() != obj.getClass())
67              return false;
68          AbstractHuman other = (AbstractHuman) obj;
69          if (birthPlace == null) {
70              if (other.birthPlace != null)
71                  return false;
72          } else if (!birthPlace.equals(other.birthPlace))
73              return false;
74          if (birthday == null) {
75              if (other.birthday != null)
76                  return false;
77          } else if (!birthday.equals(other.birthday))
78              return false;
79          if (name == null) {
80              if (other.name != null)
81                  return false;
82          } else if (!name.equals(other.name))
83              return false;
84          return true;
85      }
86  
87  }