xref: /aosp_15_r20/external/snakeyaml/src/test/java/org/yaml/snakeyaml/constructor/TestBean.java (revision ac2a7c1bf4e14d82f3bd566dcc2d76d5b42faf34)
1 /**
2  * Copyright (c) 2008, SnakeYAML
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  */
14 package org.yaml.snakeyaml.constructor;
15 
16 import java.util.Date;
17 
18 public class TestBean {
19 
20   private String name;
21   private int age;
22   private Date born;
23 
TestBean()24   public TestBean() {}
25 
TestBean(final String name, final int age, final Date born)26   public TestBean(final String name, final int age, final Date born) {
27     this.name = name;
28     this.age = age;
29     this.born = born;
30   }
31 
getName()32   public String getName() {
33     return this.name;
34   }
35 
getAge()36   public int getAge() {
37     return age;
38   }
39 
getBorn()40   public Date getBorn() {
41     return born;
42   }
43 
setName(final String name)44   public void setName(final String name) {
45     this.name = name;
46   }
47 
setAge(final int age)48   public void setAge(final int age) {
49     this.age = age;
50   }
51 
setBorn(final Date born)52   public void setBorn(final Date born) {
53     this.born = born;
54   }
55 
equals(final Object other)56   public boolean equals(final Object other) {
57     boolean ret = this == other;
58     if (!ret && other instanceof TestBean) {
59       TestBean o = (TestBean) other;
60       ret = this.name == null ? o.name == null
61           : this.name.equals(o.name) && this.age == o.age && this.born == null ? o.born == null
62               : this.born.equals(o.born);
63     }
64     return ret;
65   }
66 
hashCode()67   public int hashCode() {
68     int val = 3;
69     val += 3 * (name == null ? 0 : name.hashCode());
70     val += 3 * age;
71     val += 3 * (born == null ? 0 : born.hashCode());
72     return val;
73   }
74 
toString()75   public String toString() {
76     return "#<org.jvyaml.TestBean name=\"" + name + "\" age=" + age + " born=\"" + born + "\">";
77   }
78 }
79