2 * Sone - IdentityEvent.java - Copyright © 2013–2019 David Roden
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.
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.
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/>.
18 package net.pterodactylus.sone.freenet.wot.event;
20 import net.pterodactylus.sone.freenet.wot.Identity;
21 import net.pterodactylus.sone.freenet.wot.OwnIdentity;
24 * Base class for {@link Identity} events.
26 public abstract class IdentityEvent {
28 /** The own identity this event relates to. */
29 private final OwnIdentity ownIdentity;
31 /** The identity this event is about. */
32 private final Identity identity;
35 * Creates a new identity-based event.
38 * The own identity that relates to the identity
40 * The identity this event is about
42 protected IdentityEvent(OwnIdentity ownIdentity, Identity identity) {
43 this.ownIdentity = ownIdentity;
44 this.identity = identity;
52 * Returns the own identity this event relates to.
54 * @return The own identity this event relates to
56 public OwnIdentity ownIdentity() {
61 * Returns the identity this event is about.
63 * @return The identity this event is about
65 public Identity identity() {
70 public int hashCode() {
71 return ownIdentity().hashCode() ^ identity().hashCode();
75 public boolean equals(Object object) {
76 if ((object == null) || !object.getClass().equals(getClass())) {
79 IdentityEvent identityEvent = (IdentityEvent) object;
80 return ownIdentity().equals(identityEvent.ownIdentity()) && identity().equals(identityEvent.identity());