View Javadoc
1   /*
2    *    Copyright 2009-2021 the original author or authors.
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.apache.ibatis.submitted.cglib_lazy_error;
17  
18  public class Person {
19  
20    private Long id;
21    private String firstName;
22    private String lastName;
23    private Person parent;
24  
25    public Person getAncestor() {
26      if (getParent() == null) {
27        return this;
28      } else {
29        return getParent().getAncestor();
30      }
31    }
32  
33    @Override
34    public boolean equals(Object o) {
35      if (this == o) return true;
36      if (!(o instanceof Person)) return false;
37  
38      Person person = (Person) o;
39  
40      if (id != null ? !id.equals(person.id) : person.id != null) return false;
41  
42      return true;
43    }
44  
45    @Override
46    public int hashCode() {
47      return id != null ? id.hashCode() : 0;
48    }
49  
50    @Override
51    public String toString() {
52      return id + ": " + firstName + " " + lastName + " ("+parent+")";
53    }
54  
55    public String getFirstName() {
56      return firstName;
57    }
58  
59    public void setFirstName(String firstName) {
60      this.firstName = firstName;
61    }
62  
63    public String getLastName() {
64      return lastName;
65    }
66  
67    public void setLastName(String lastName) {
68      this.lastName = lastName;
69    }
70  
71    public Long getId() {
72      return id;
73    }
74  
75    public void setId(Long id) {
76      this.id = id;
77    }
78  
79    public Person getParent() {
80      return parent;
81    }
82  
83    public void setParent(Person parent) {
84      this.parent = parent;
85    }
86  }