View Javadoc
1   /*
2    *    Copyright 2009-2024 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  public class ComplexImmutableAuthorId {
19    protected final int id;
20    protected final String email;
21    protected final String username;
22    protected final String password;
23  
24    public ComplexImmutableAuthorId(int aId, String aEmail, String aUsername, String aPassword) {
25      id = aId;
26      email = aEmail;
27      username = aUsername;
28      password = aPassword;
29    }
30  
31    public int getId() {
32      return id;
33    }
34  
35    public String getEmail() {
36      return email;
37    }
38  
39    public String getUsername() {
40      return username;
41    }
42  
43    public String getPassword() {
44      return password;
45    }
46  
47    @Override
48    public boolean equals(Object o) {
49      if (this == o) {
50        return true;
51      }
52      if (o == null || getClass() != o.getClass()) {
53        return false;
54      }
55  
56      final ComplexImmutableAuthorId that = (ComplexImmutableAuthorId) o;
57  
58      return id == that.id && email != null ? email.equals(that.email)
59          : that.email == null && password != null ? password.equals(that.password)
60              : that.password == null && username != null ? username.equals(that.username) : that.username == null;
61    }
62  
63    @Override
64    public int hashCode() {
65      int myresult = id;
66      myresult = 31 * myresult + (email != null ? email.hashCode() : 0);
67      myresult = 31 * myresult + (username != null ? username.hashCode() : 0);
68      return 31 * myresult + (password != null ? password.hashCode() : 0);
69    }
70  }