Remove @author tags
[Sone.git] / src / main / java / net / pterodactylus / sone / freenet / wot / event / IdentityEvent.java
1 /*
2  * Sone - IdentityEvent.java - Copyright © 2013–2016 David Roden
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 package net.pterodactylus.sone.freenet.wot.event;
19
20 import net.pterodactylus.sone.freenet.wot.Identity;
21 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
22
23 /**
24  * Base class for {@link Identity} events.
25  */
26 public abstract class IdentityEvent {
27
28         /** The own identity this event relates to. */
29         private final OwnIdentity ownIdentity;
30
31         /** The identity this event is about. */
32         private final Identity identity;
33
34         /**
35          * Creates a new identity-based event.
36          *
37          * @param ownIdentity
38          *            The own identity that relates to the identity
39          * @param identity
40          *            The identity this event is about
41          */
42         protected IdentityEvent(OwnIdentity ownIdentity, Identity identity) {
43                 this.ownIdentity = ownIdentity;
44                 this.identity = identity;
45         }
46
47         //
48         // ACCESSORS
49         //
50
51         /**
52          * Returns the own identity this event relates to.
53          *
54          * @return The own identity this event relates to
55          */
56         public OwnIdentity ownIdentity() {
57                 return ownIdentity;
58         }
59
60         /**
61          * Returns the identity this event is about.
62          *
63          * @return The identity this event is about
64          */
65         public Identity identity() {
66                 return identity;
67         }
68
69         @Override
70         public int hashCode() {
71                 return ownIdentity().hashCode() ^ identity().hashCode();
72         }
73
74         @Override
75         public boolean equals(Object object) {
76                 if ((object == null) || !object.getClass().equals(getClass())) {
77                         return false;
78                 }
79                 IdentityEvent identityEvent = (IdentityEvent) object;
80                 return ownIdentity().equals(identityEvent.ownIdentity()) && identity().equals(identityEvent.identity());
81         }
82
83 }