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.constructor;
    18
    19  import java.util.Date;
    20
    21  /**
    22   * @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
    23   */
    24  public class TestBean {
    25      private String name;
    26      private int age;
    27      private Date born;
    28
    29      public TestBean() {
    30      }
    31
    32      public TestBean(final String name, final int age, final Date born) {
    33          this.name = name;
    34          this.age = age;
    35          this.born = born;
    36      }
    37
    38      public String getName() {
    39          return this.name;
    40      }
    41
    42      public int getAge() {
    43          return age;
    44      }
    45
    46      public Date getBorn() {
    47          return born;
    48      }
    49
    50      public void setName(final String name) {
    51          this.name = name;
    52      }
    53
    54      public void setAge(final int age) {
    55          this.age = age;
    56      }
    57
    58      public void setBorn(final Date born) {
    59          this.born = born;
    60      }
    61
    62      public boolean equals(final Object other) {
    63          boolean ret = this == other;
    64          if (!ret && other instanceof TestBean) {
    65              TestBean o = (TestBean) other;
    66              ret = this.name == null ? o.name == null : this.name.equals(o.name)
    67                      && this.age == o.age && this.born == null ? o.born == null : this.born
    68                      .equals(o.born);
    69          }
    70          return ret;
    71      }
    72
    73      public int hashCode() {
    74          int val = 3;
    75          val += 3 * (name == null ? 0 : name.hashCode());
    76          val += 3 * age;
    77          val += 3 * (born == null ? 0 : born.hashCode());
    78          return val;
    79      }
    80
    81      public String toString() {
    82          return "#<org.jvyaml.TestBean name=\"" + name + "\" age=" + age + " born=\"" + born + "\">";
    83      }
    84  }