X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fwotns%2Ffreenet%2Fwot%2FIdentityListenerManager.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fwotns%2Ffreenet%2Fwot%2FIdentityListenerManager.java;h=63ce4fa04c1d26a495c2c443b26d28d9e4dfbb51;hb=622c4a4d3ebed447d5708a41cf3e1e82e18fa29b;hp=0000000000000000000000000000000000000000;hpb=77869390c46e8e5eff63bf00c7ef44a37ba8f317;p=WoTNS.git diff --git a/src/main/java/net/pterodactylus/wotns/freenet/wot/IdentityListenerManager.java b/src/main/java/net/pterodactylus/wotns/freenet/wot/IdentityListenerManager.java new file mode 100644 index 0000000..63ce4fa --- /dev/null +++ b/src/main/java/net/pterodactylus/wotns/freenet/wot/IdentityListenerManager.java @@ -0,0 +1,113 @@ +/* + * Sone - IdentityListenerManager.java - Copyright © 2010 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 . + */ + +package net.pterodactylus.wotns.freenet.wot; + +import net.pterodactylus.util.event.AbstractListenerManager; + +/** + * Manager for {@link IdentityListener}s. + * + * @author David ‘Bombe’ Roden + */ +public class IdentityListenerManager extends AbstractListenerManager { + + /** + * 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); + } + } + +}