1 /** 2 * Copyright (c) 2008, 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 package org.yaml.snakeyaml.recursive; 17 18 import java.util.Date; 19 20 public abstract class AbstractHuman { 21 private String name; 22 private Date birthday; 23 private String birthPlace; 24 getName()25 public String getName() { 26 return name; 27 } 28 setName(String name)29 public void setName(String name) { 30 this.name = name; 31 } 32 getBirthday()33 public Date getBirthday() { 34 return birthday; 35 } 36 setBirthday(Date birthday)37 public void setBirthday(Date birthday) { 38 this.birthday = birthday; 39 } 40 getBirthPlace()41 public String getBirthPlace() { 42 return birthPlace; 43 } 44 setBirthPlace(String birthPlace)45 public void setBirthPlace(String birthPlace) { 46 this.birthPlace = birthPlace; 47 } 48 49 @Override hashCode()50 public int hashCode() { 51 final int prime = 31; 52 int result = 1; 53 result = prime * result + ((birthPlace == null) ? 0 : birthPlace.hashCode()); 54 result = prime * result + ((birthday == null) ? 0 : birthday.hashCode()); 55 result = prime * result + ((name == null) ? 0 : name.hashCode()); 56 return result; 57 } 58 59 @Override equals(Object obj)60 public boolean equals(Object obj) { 61 if (this == obj) 62 return true; 63 if (obj == null) 64 return false; 65 if (getClass() != obj.getClass()) 66 return false; 67 AbstractHuman other = (AbstractHuman) obj; 68 if (birthPlace == null) { 69 if (other.birthPlace != null) 70 return false; 71 } else if (!birthPlace.equals(other.birthPlace)) 72 return false; 73 if (birthday == null) { 74 if (other.birthday != null) 75 return false; 76 } else if (!birthday.equals(other.birthday)) 77 return false; 78 if (name == null) { 79 if (other.name != null) 80 return false; 81 } else if (!name.equals(other.name)) 82 return false; 83 return true; 84 } 85 86 } 87