import net.pterodactylus.sone.fcp.FcpInterface;
import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired;
import net.pterodactylus.sone.freenet.wot.Identity;
-import net.pterodactylus.sone.freenet.wot.IdentityListener;
import net.pterodactylus.sone.freenet.wot.IdentityManager;
import net.pterodactylus.sone.freenet.wot.OwnIdentity;
+import net.pterodactylus.sone.freenet.wot.event.IdentityAddedEvent;
+import net.pterodactylus.sone.freenet.wot.event.IdentityRemovedEvent;
+import net.pterodactylus.sone.freenet.wot.event.IdentityUpdatedEvent;
+import net.pterodactylus.sone.freenet.wot.event.OwnIdentityAddedEvent;
+import net.pterodactylus.sone.freenet.wot.event.OwnIdentityRemovedEvent;
import net.pterodactylus.sone.main.SonePlugin;
import net.pterodactylus.util.config.Configuration;
import net.pterodactylus.util.config.ConfigurationException;
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
-public class Core extends AbstractService implements IdentityListener, SoneProvider, PostProvider {
+public class Core extends AbstractService implements SoneProvider, PostProvider {
/** The logger. */
private static final Logger logger = Logging.getLogger(Core.class);
public void serviceStart() {
loadConfiguration();
updateChecker.start();
- identityManager.addIdentityListener(this);
identityManager.start();
webOfTrustUpdater.init();
webOfTrustUpdater.start();
webOfTrustUpdater.stop();
updateChecker.stop();
soneDownloader.stop();
- identityManager.removeIdentityListener(this);
identityManager.stop();
}
}
}
- //
- // INTERFACE IdentityListener
- //
-
/**
- * {@inheritDoc}
+ * Notifies the core that a new {@link OwnIdentity} was added.
+ *
+ * @param ownIdentityAddedEvent
+ * The event
*/
- @Override
- public void ownIdentityAdded(OwnIdentity ownIdentity) {
+ @Subscribe
+ public void ownIdentityAdded(OwnIdentityAddedEvent ownIdentityAddedEvent) {
+ OwnIdentity ownIdentity = ownIdentityAddedEvent.ownIdentity();
logger.log(Level.FINEST, String.format("Adding OwnIdentity: %s", ownIdentity));
if (ownIdentity.hasContext("Sone")) {
trustedIdentities.put(ownIdentity, Collections.synchronizedSet(new HashSet<Identity>()));
}
/**
- * {@inheritDoc}
+ * Notifies the core that an {@link OwnIdentity} was removed.
+ *
+ * @param ownIdentityRemovedEvent
+ * The event
*/
- @Override
- public void ownIdentityRemoved(OwnIdentity ownIdentity) {
+ @Subscribe
+ public void ownIdentityRemoved(OwnIdentityRemovedEvent ownIdentityRemovedEvent) {
+ OwnIdentity ownIdentity = ownIdentityRemovedEvent.ownIdentity();
logger.log(Level.FINEST, String.format("Removing OwnIdentity: %s", ownIdentity));
trustedIdentities.remove(ownIdentity);
}
/**
- * {@inheritDoc}
+ * Notifies the core that a new {@link Identity} was added.
+ *
+ * @param identityAddedEvent
+ * The event
*/
- @Override
- public void identityAdded(OwnIdentity ownIdentity, Identity identity) {
+ @Subscribe
+ public void identityAdded(IdentityAddedEvent identityAddedEvent) {
+ Identity identity = identityAddedEvent.identity();
logger.log(Level.FINEST, String.format("Adding Identity: %s", identity));
- trustedIdentities.get(ownIdentity).add(identity);
+ trustedIdentities.get(identityAddedEvent.ownIdentity()).add(identity);
addRemoteSone(identity);
}
/**
- * {@inheritDoc}
+ * Notifies the core that an {@link Identity} was updated.
+ *
+ * @param identityUpdatedEvent
+ * The event
*/
- @Override
- public void identityUpdated(OwnIdentity ownIdentity, final Identity identity) {
+ @Subscribe
+ public void identityUpdated(IdentityUpdatedEvent identityUpdatedEvent) {
+ final Identity identity = identityUpdatedEvent.identity();
soneDownloaders.execute(new Runnable() {
@Override
}
/**
- * {@inheritDoc}
+ * Notifies the core that an {@link Identity} was removed.
+ *
+ * @param identityRemovedEvent
+ * The event
*/
- @Override
- public void identityRemoved(OwnIdentity ownIdentity, Identity identity) {
+ @Subscribe
+ public void identityRemoved(IdentityRemovedEvent identityRemovedEvent) {
+ OwnIdentity ownIdentity = identityRemovedEvent.ownIdentity();
+ Identity identity = identityRemovedEvent.identity();
trustedIdentities.get(ownIdentity).remove(identity);
boolean foundIdentity = false;
for (Entry<OwnIdentity, Set<Identity>> trustedIdentity : trustedIdentities.entrySet()) {
+++ /dev/null
-/*
- * Sone - IdentityListener.java - Copyright © 2010–2012 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.freenet.wot;
-
-import java.util.EventListener;
-
-/**
- * Listener interface for {@link IdentityManager} events.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public interface IdentityListener extends EventListener {
-
- /**
- * Notifies a listener that an {@link OwnIdentity} that was not known on the
- * previous check is available.
- *
- * @param ownIdentity
- * The new own identity
- */
- public void ownIdentityAdded(OwnIdentity ownIdentity);
-
- /**
- * Notifies a listener that an {@link OwnIdentity} that was available during
- * the last check has gone away.
- *
- * @param ownIdentity
- * The disappeared own identity
- */
- public void ownIdentityRemoved(OwnIdentity ownIdentity);
-
- /**
- * Notifies a listener that a new identity was discovered.
- *
- * @param ownIdentity
- * The own identity at the root of the trust tree
- * @param identity
- * The new identity
- */
- public void identityAdded(OwnIdentity ownIdentity, Identity identity);
-
- /**
- * Notifies a listener that some properties of the identity have changed.
- *
- * @param ownIdentity
- * The own identity at the root of the trust tree
- * @param identity
- * The updated identity
- */
- public void identityUpdated(OwnIdentity ownIdentity, Identity identity);
-
- /**
- * Notifies a listener that an identity has gone away.
- *
- * @param ownIdentity
- * The own identity at the root of the trust tree
- * @param identity
- * The disappeared identity
- */
- public void identityRemoved(OwnIdentity ownIdentity, Identity identity);
-
-}
+++ /dev/null
-/*
- * Sone - IdentityListenerManager.java - Copyright © 2010–2012 David Roden
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.pterodactylus.sone.freenet.wot;
-
-import net.pterodactylus.util.event.AbstractListenerManager;
-
-/**
- * Manager for {@link IdentityListener}s.
- *
- * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
- */
-public class IdentityListenerManager extends AbstractListenerManager<IdentityManager, IdentityListener> {
-
- /**
- * Creates a new identity listener manager.
- */
- public IdentityListenerManager() {
- super(null);
- }
-
- //
- // ACTIONS
- //
-
- /**
- * Notifies all listeners that an {@link OwnIdentity} that was not known on
- * the previous check is available.
- *
- * @see IdentityListener#ownIdentityAdded(OwnIdentity)
- * @param ownIdentity
- * The new own identity
- */
- public void fireOwnIdentityAdded(OwnIdentity ownIdentity) {
- for (IdentityListener identityListener : getListeners()) {
- identityListener.ownIdentityAdded(ownIdentity);
- }
- }
-
- /**
- * Notifies all listeners that an {@link OwnIdentity} that was available
- * during the last check has gone away.
- *
- * @see IdentityListener#ownIdentityRemoved(OwnIdentity)
- * @param ownIdentity
- * The disappeared own identity
- */
- public void fireOwnIdentityRemoved(OwnIdentity ownIdentity) {
- for (IdentityListener identityListener : getListeners()) {
- identityListener.ownIdentityRemoved(ownIdentity);
- }
- }
-
- /**
- * Notifies all listeners that a new identity was discovered.
- *
- * @see IdentityListener#identityAdded(OwnIdentity, Identity)
- * @param ownIdentity
- * The own identity at the root of the trust tree
- * @param identity
- * The new identity
- */
- public void fireIdentityAdded(OwnIdentity ownIdentity, Identity identity) {
- for (IdentityListener identityListener : getListeners()) {
- identityListener.identityAdded(ownIdentity, identity);
- }
- }
-
- /**
- * Notifies all listeners that some properties of the identity have changed.
- *
- * @see IdentityListener#identityUpdated(OwnIdentity, Identity)
- * @param ownIdentity
- * The own identity at the root of the trust tree
- * @param identity
- * The updated identity
- */
- public void fireIdentityUpdated(OwnIdentity ownIdentity, Identity identity) {
- for (IdentityListener identityListener : getListeners()) {
- identityListener.identityUpdated(ownIdentity, identity);
- }
- }
-
- /**
- * Notifies all listeners that an identity has gone away.
- *
- * @see IdentityListener#identityRemoved(OwnIdentity, Identity)
- * @param ownIdentity
- * The own identity at the root of the trust tree
- * @param identity
- * The disappeared identity
- */
- public void fireIdentityRemoved(OwnIdentity ownIdentity, Identity identity) {
- for (IdentityListener identityListener : getListeners()) {
- identityListener.identityRemoved(ownIdentity, identity);
- }
- }
-
-}
import java.util.logging.Logger;
import net.pterodactylus.sone.freenet.plugin.PluginException;
+import net.pterodactylus.sone.freenet.wot.event.IdentityAddedEvent;
+import net.pterodactylus.sone.freenet.wot.event.IdentityRemovedEvent;
+import net.pterodactylus.sone.freenet.wot.event.IdentityUpdatedEvent;
+import net.pterodactylus.sone.freenet.wot.event.OwnIdentityAddedEvent;
+import net.pterodactylus.sone.freenet.wot.event.OwnIdentityRemovedEvent;
import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.service.AbstractService;
+import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import com.google.inject.name.Named;
* exceptions but it only logs them and tries to return sensible defaults.
* <p>
* It is also responsible for polling identities from the Web of Trust plugin
- * and notifying registered {@link IdentityListener}s when {@link Identity}s and
+ * and sending events to the {@link EventBus} when {@link Identity}s and
* {@link OwnIdentity}s are discovered or disappearing.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
/** The logger. */
private static final Logger logger = Logging.getLogger(IdentityManager.class);
- /** The event manager. */
- private final IdentityListenerManager identityListenerManager = new IdentityListenerManager();
+ /** The event bus. */
+ private final EventBus eventBus;
/** The Web of Trust connector. */
private final WebOfTrustConnector webOfTrustConnector;
/**
* Creates a new identity manager.
*
+ * @param eventBus
+ * The event bus
* @param webOfTrustConnector
* The Web of Trust connector
* @param context
* contexts)
*/
@Inject
- public IdentityManager(WebOfTrustConnector webOfTrustConnector, @Named("WebOfTrustContext") String context) {
+ public IdentityManager(EventBus eventBus, WebOfTrustConnector webOfTrustConnector, @Named("WebOfTrustContext") String context) {
super("Sone Identity Manager", false);
+ this.eventBus = eventBus;
this.webOfTrustConnector = webOfTrustConnector;
this.context = context;
}
//
- // LISTENER MANAGEMENT
- //
-
- /**
- * Adds a listener for identity events.
- *
- * @param identityListener
- * The listener to add
- */
- public void addIdentityListener(IdentityListener identityListener) {
- identityListenerManager.addListener(identityListener);
- }
-
- /**
- * Removes a listener for identity events.
- *
- * @param identityListener
- * The listener to remove
- */
- public void removeIdentityListener(IdentityListener identityListener) {
- identityListenerManager.removeListener(identityListener);
- }
-
- //
// ACCESSORS
//
/* find new identities. */
for (Identity currentIdentity : currentIdentities.get(ownIdentity).values()) {
if (!oldIdentities.containsKey(ownIdentity) || !oldIdentities.get(ownIdentity).containsKey(currentIdentity.getId())) {
- identityListenerManager.fireIdentityAdded(ownIdentity, currentIdentity);
+ eventBus.post(new IdentityAddedEvent(ownIdentity, currentIdentity));
}
}
if (oldIdentities.containsKey(ownIdentity)) {
for (Identity oldIdentity : oldIdentities.get(ownIdentity).values()) {
if (!currentIdentities.get(ownIdentity).containsKey(oldIdentity.getId())) {
- identityListenerManager.fireIdentityRemoved(ownIdentity, oldIdentity);
+ eventBus.post(new IdentityRemovedEvent(ownIdentity, oldIdentity));
}
}
Set<String> oldContexts = oldIdentity.getContexts();
Set<String> newContexts = newIdentity.getContexts();
if (oldContexts.size() != newContexts.size()) {
- identityListenerManager.fireIdentityUpdated(ownIdentity, newIdentity);
+ eventBus.post(new IdentityUpdatedEvent(ownIdentity, newIdentity));
continue;
}
for (String oldContext : oldContexts) {
if (!newContexts.contains(oldContext)) {
- identityListenerManager.fireIdentityUpdated(ownIdentity, newIdentity);
+ eventBus.post(new IdentityUpdatedEvent(ownIdentity, newIdentity));
break;
}
}
Map<String, String> oldProperties = oldIdentity.getProperties();
Map<String, String> newProperties = newIdentity.getProperties();
if (oldProperties.size() != newProperties.size()) {
- identityListenerManager.fireIdentityUpdated(ownIdentity, newIdentity);
+ eventBus.post(new IdentityUpdatedEvent(ownIdentity, newIdentity));
continue;
}
for (Entry<String, String> oldProperty : oldProperties.entrySet()) {
if (!newProperties.containsKey(oldProperty.getKey()) || !newProperties.get(oldProperty.getKey()).equals(oldProperty.getValue())) {
- identityListenerManager.fireIdentityUpdated(ownIdentity, newIdentity);
+ eventBus.post(new IdentityUpdatedEvent(ownIdentity, newIdentity));
break;
}
}
for (OwnIdentity oldOwnIdentity : currentOwnIdentities.values()) {
OwnIdentity newOwnIdentity = newOwnIdentities.get(oldOwnIdentity.getId());
if ((newOwnIdentity == null) || ((context != null) && oldOwnIdentity.hasContext(context) && !newOwnIdentity.hasContext(context))) {
- identityListenerManager.fireOwnIdentityRemoved(new DefaultOwnIdentity(oldOwnIdentity));
+ eventBus.post(new OwnIdentityRemovedEvent(new DefaultOwnIdentity(oldOwnIdentity)));
}
}
for (OwnIdentity currentOwnIdentity : newOwnIdentities.values()) {
OwnIdentity oldOwnIdentity = currentOwnIdentities.get(currentOwnIdentity.getId());
if (((oldOwnIdentity == null) && ((context == null) || currentOwnIdentity.hasContext(context))) || ((oldOwnIdentity != null) && (context != null) && (!oldOwnIdentity.hasContext(context) && currentOwnIdentity.hasContext(context)))) {
- identityListenerManager.fireOwnIdentityAdded(new DefaultOwnIdentity(currentOwnIdentity));
+ eventBus.post(new OwnIdentityAddedEvent(new DefaultOwnIdentity(currentOwnIdentity)));
}
}
--- /dev/null
+/*
+ * Sone - IdentityAddedEvent.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.freenet.wot.event;
+
+import net.pterodactylus.sone.freenet.wot.Identity;
+import net.pterodactylus.sone.freenet.wot.OwnIdentity;
+
+/**
+ * Event that signals that an {@link Identity} was added.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class IdentityAddedEvent extends IdentityEvent {
+
+ /**
+ * Creates a new “identity added” event.
+ *
+ * @param ownIdentity
+ * The own identity that added the identity
+ * @param identity
+ * The identity that was added
+ */
+ public IdentityAddedEvent(OwnIdentity ownIdentity, Identity identity) {
+ super(ownIdentity, identity);
+ }
+
+}
--- /dev/null
+/*
+ * Sone - IdentityEvent.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.freenet.wot.event;
+
+import net.pterodactylus.sone.freenet.wot.Identity;
+import net.pterodactylus.sone.freenet.wot.OwnIdentity;
+
+/**
+ * Base class for {@link Identity} events.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public abstract class IdentityEvent {
+
+ /** The own identity this event relates to. */
+ private final OwnIdentity ownIdentity;
+
+ /** The identity this event is about. */
+ private final Identity identity;
+
+ /**
+ * Creates a new identity-based event.
+ *
+ * @param ownIdentity
+ * The own identity that relates to the identity
+ * @param identity
+ * The identity this event is about
+ */
+ protected IdentityEvent(OwnIdentity ownIdentity, Identity identity) {
+ this.ownIdentity = ownIdentity;
+ this.identity = identity;
+ }
+
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Returns the own identity this event relates to.
+ *
+ * @return The own identity this event relates to
+ */
+ public OwnIdentity ownIdentity() {
+ return ownIdentity;
+ }
+
+ /**
+ * Returns the identity this event is about.
+ *
+ * @return The identity this event is about
+ */
+ public Identity identity() {
+ return identity;
+ }
+
+}
--- /dev/null
+/*
+ * Sone - IdentityRemovedEvent.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.freenet.wot.event;
+
+import net.pterodactylus.sone.freenet.wot.Identity;
+import net.pterodactylus.sone.freenet.wot.OwnIdentity;
+
+/**
+ * Event that signals that an {@link Identity} was removed.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class IdentityRemovedEvent extends IdentityEvent {
+
+ /**
+ * Creates a new “identity removed” event.
+ *
+ * @param ownIdentity
+ * The own identity that removed the identity
+ * @param identity
+ * The identity that was removed
+ */
+ public IdentityRemovedEvent(OwnIdentity ownIdentity, Identity identity) {
+ super(ownIdentity, identity);
+ }
+
+}
--- /dev/null
+/*
+ * Sone - IdentityUpdatedEvent.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.freenet.wot.event;
+
+import net.pterodactylus.sone.freenet.wot.Identity;
+import net.pterodactylus.sone.freenet.wot.OwnIdentity;
+
+/**
+ * Event that signals that an {@link Identity} was updated.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class IdentityUpdatedEvent extends IdentityEvent {
+
+ /**
+ * Creates a new “identity updated” event.
+ *
+ * @param ownIdentity
+ * The own identity that tracks the identity
+ * @param identity
+ * The identity that was updated
+ */
+ public IdentityUpdatedEvent(OwnIdentity ownIdentity, Identity identity) {
+ super(ownIdentity, identity);
+ }
+
+}
--- /dev/null
+/*
+ * Sone - OwnIdentityAddedEvent.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.freenet.wot.event;
+
+import net.pterodactylus.sone.freenet.wot.OwnIdentity;
+
+/**
+ * Event that signals that an {@link OwnIdentity} was added.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class OwnIdentityAddedEvent extends OwnIdentityEvent {
+
+ /**
+ * Creates new “own identity added” event.
+ *
+ * @param ownIdentity
+ * The own identity that was added
+ */
+ public OwnIdentityAddedEvent(OwnIdentity ownIdentity) {
+ super(ownIdentity);
+ }
+
+}
--- /dev/null
+/*
+ * Sone - OwnIdentityEvent.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.freenet.wot.event;
+
+import net.pterodactylus.sone.freenet.wot.OwnIdentity;
+
+/**
+ * Base class for {@link OwnIdentity} events.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public abstract class OwnIdentityEvent {
+
+ /** The own identity this event is about. */
+ private final OwnIdentity ownIdentity;
+
+ /**
+ * Creates a new own identity-based event.
+ *
+ * @param ownIdentity
+ * The own identity this event is about
+ */
+ protected OwnIdentityEvent(OwnIdentity ownIdentity) {
+ this.ownIdentity = ownIdentity;
+ }
+
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Returns the own identity this event is about.
+ *
+ * @return The own identity this event is about
+ */
+ public OwnIdentity ownIdentity() {
+ return ownIdentity;
+ }
+
+}
--- /dev/null
+/*
+ * Sone - OwnIdentityRemovedEvent.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.freenet.wot.event;
+
+import net.pterodactylus.sone.freenet.wot.OwnIdentity;
+
+/**
+ * Event that signals that an {@link OwnIdentity} was removed.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class OwnIdentityRemovedEvent extends OwnIdentityEvent {
+
+ /**
+ * Creates a new “own identity removed” event.
+ *
+ * @param ownIdentity
+ * The own identity that was removed
+ */
+ public OwnIdentityRemovedEvent(OwnIdentity ownIdentity) {
+ super(ownIdentity);
+ }
+
+}