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  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      if ((id != that.id) || (email != null ? !email.equals(that.email) : that.email != null)
59          || (password != null ? !password.equals(that.password) : that.password != null)
60          || (username != null ? !username.equals(that.username) : that.username != null)) {
61        return false;
62      }
63  
64      return true;
65    }
66  
67    @Override
68    public int hashCode() {
69      int myresult = id;
70      myresult = 31 * myresult + (email != null ? email.hashCode() : 0);
71      myresult = 31 * myresult + (username != null ? username.hashCode() : 0);
72      return 31 * myresult + (password != null ? password.hashCode() : 0);
73    }
74  }