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.issues.issue8;
    18
    19  import java.io.Serializable;
    20
    21  /**
    22   * to test http://code.google.com/p/snakeyaml/issues/detail?id=8
    23   */
    24  public class Person implements Serializable {
    25      private static final long serialVersionUID = 1L;
    26      private String firstName;
    27      private String lastName;
    28      private int hatSize;
    29
    30      public Person() {
    31      }
    32
    33      public Person(String firstName, String lastName, int hatSize) {
    34          this.firstName = firstName;
    35          this.lastName = lastName;
    36          this.hatSize = hatSize;
    37      }
    38
    39      public String getFirstName() {
    40          return firstName;
    41      }
    42
    43      public void setFirstName(String firstName) {
    44          this.firstName = firstName;
    45      }
    46
    47      public String getLastName() {
    48          return lastName;
    49      }
    50
    51      public void setLastName(String lastName) {
    52          this.lastName = lastName;
    53      }
    54
    55      public int getHatSize() {
    56          return hatSize;
    57      }
    58
    59      public void setHatSize(int hatSize) {
    60          this.hatSize = hatSize;
    61      }
    62
    63      @Override
    64      public boolean equals(Object object) {
    65          if (object instanceof Person) {
    66              Person person = (Person) object;
    67              return firstName.equals(person.firstName) && lastName.equals(person.lastName)
    68                      && hatSize == person.hatSize;
    69          }
    70          return false;
    71      }
    72
    73      @Override
    74      public int hashCode() {
    75          return 1;
    76      }
    77  }