View Javadoc
1   /*
2    *    Copyright 2009-2023 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    *       https://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 static final long serialVersionUID = 1L;
22    private final ComplexImmutableAuthorId theComplexImmutableAuthorId;
23    protected final String bio;
24    protected final Section favouriteSection;
25  
26    public ComplexImmutableAuthor(ComplexImmutableAuthorId aComplexImmutableAuthorId, String bio, Section section) {
27      theComplexImmutableAuthorId = aComplexImmutableAuthorId;
28      this.bio = bio;
29      this.favouriteSection = section;
30    }
31  
32    public ComplexImmutableAuthorId getComplexImmutableAuthorId() {
33      return theComplexImmutableAuthorId;
34    }
35  
36    public String getBio() {
37      return bio;
38    }
39  
40    public Section getFavouriteSection() {
41      return favouriteSection;
42    }
43  
44    @Override
45    public boolean equals(Object o) {
46      if (this == o) {
47        return true;
48      }
49      if (o == null || getClass() != o.getClass()) {
50        return false;
51      }
52  
53      final ComplexImmutableAuthor that = (ComplexImmutableAuthor) o;
54  
55      if ((bio != null ? !bio.equals(that.bio) : that.bio != null) || (favouriteSection != that.favouriteSection)
56          || (theComplexImmutableAuthorId != null ? !theComplexImmutableAuthorId.equals(that.theComplexImmutableAuthorId)
57              : that.theComplexImmutableAuthorId != null)) {
58        return false;
59      }
60  
61      return true;
62    }
63  
64    @Override
65    public int hashCode() {
66      int myresult = theComplexImmutableAuthorId != null ? theComplexImmutableAuthorId.hashCode() : 0;
67      myresult = 31 * myresult + (bio != null ? bio.hashCode() : 0);
68      return 31 * myresult + (favouriteSection != null ? favouriteSection.hashCode() : 0);
69    }
70  }