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.domain.blog;
17  
18  import java.io.Serializable;
19  
20  public class ComplexImmutableAuthor implements Serializable {
21    private final ComplexImmutableAuthorId theComplexImmutableAuthorId;
22    protected final String bio;
23    protected final Section favouriteSection;
24  
25    public ComplexImmutableAuthor(ComplexImmutableAuthorId aComplexImmutableAuthorId, String bio, Section section) {
26      theComplexImmutableAuthorId = aComplexImmutableAuthorId;
27      this.bio = bio;
28      this.favouriteSection = section;
29    }
30  
31    public ComplexImmutableAuthorId getComplexImmutableAuthorId() {
32      return theComplexImmutableAuthorId;
33    }
34  
35    public String getBio() {
36      return bio;
37    }
38  
39    public Section getFavouriteSection() {
40      return favouriteSection;
41    }
42  
43    @Override
44    public boolean equals(Object o) {
45      if (this == o) {
46        return true;
47      }
48      if (o == null || getClass() != o.getClass()) {
49        return false;
50      }
51  
52      final ComplexImmutableAuthor that = (ComplexImmutableAuthor) o;
53  
54      if (bio != null ? !bio.equals(that.bio) : that.bio != null) {
55        return false;
56      }
57      if (favouriteSection != that.favouriteSection) {
58        return false;
59      }
60      if (theComplexImmutableAuthorId != null ? !theComplexImmutableAuthorId.equals(that.theComplexImmutableAuthorId) : that.theComplexImmutableAuthorId != null) {
61        return false;
62      }
63  
64      return true;
65    }
66  
67    @Override
68    public int hashCode() {
69      int myresult = theComplexImmutableAuthorId != null ? theComplexImmutableAuthorId.hashCode() : 0;
70      myresult = 31 * myresult + (bio != null ? bio.hashCode() : 0);
71      myresult = 31 * myresult + (favouriteSection != null ? favouriteSection.hashCode() : 0);
72      return myresult;
73    }
74  }