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