X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FIdentityChangeEventSender.java;h=d17efaecc0b29a975d9b77a9e624fd34599bc2e7;hp=4f38f8e7658e07ce82bf790e3c729c80b7a7f44c;hb=419098bcd6215125408b29e60bd888e60979d37b;hpb=4c4b77eff97fd247c6b1c8bbb30aeb6ea3d2c172 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSender.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSender.java index 4f38f8e..d17efae 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSender.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSender.java @@ -1,5 +1,5 @@ /* - * Sone - IdentityChangeEventSender.java - Copyright © 2013 David Roden + * Sone - IdentityChangeEventSender.java - Copyright © 2013–2015 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 @@ -17,6 +17,9 @@ package net.pterodactylus.sone.freenet.wot; +import java.util.Collection; +import java.util.Map; + import net.pterodactylus.sone.freenet.wot.IdentityChangeDetector.IdentityProcessor; import net.pterodactylus.sone.freenet.wot.event.IdentityAddedEvent; import net.pterodactylus.sone.freenet.wot.event.IdentityRemovedEvent; @@ -24,7 +27,6 @@ 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 com.google.common.collect.Multimap; import com.google.common.eventbus.EventBus; /** @@ -37,14 +39,14 @@ import com.google.common.eventbus.EventBus; public class IdentityChangeEventSender { private final EventBus eventBus; - private final Multimap oldIdentities; + private final Map> oldIdentities; - public IdentityChangeEventSender(EventBus eventBus, Multimap oldIdentities) { + public IdentityChangeEventSender(EventBus eventBus, Map> oldIdentities) { this.eventBus = eventBus; this.oldIdentities = oldIdentities; } - public void detectChanges(Multimap identities) { + public void detectChanges(Map> identities) { IdentityChangeDetector identityChangeDetector = new IdentityChangeDetector(oldIdentities.keySet()); identityChangeDetector.onNewIdentity(addNewOwnIdentityAndItsTrustedIdentities(identities)); identityChangeDetector.onRemovedIdentity(removeOwnIdentityAndItsTrustedIdentities(oldIdentities)); @@ -52,7 +54,7 @@ public class IdentityChangeEventSender { identityChangeDetector.detectChanges(identities.keySet()); } - private IdentityProcessor addNewOwnIdentityAndItsTrustedIdentities(final Multimap newIdentities) { + private IdentityProcessor addNewOwnIdentityAndItsTrustedIdentities(final Map> newIdentities) { return new IdentityProcessor() { @Override public void processIdentity(Identity identity) { @@ -64,7 +66,7 @@ public class IdentityChangeEventSender { }; } - private IdentityProcessor removeOwnIdentityAndItsTrustedIdentities(final Multimap oldIdentities) { + private IdentityProcessor removeOwnIdentityAndItsTrustedIdentities(final Map> oldIdentities) { return new IdentityProcessor() { @Override public void processIdentity(Identity identity) { @@ -76,16 +78,16 @@ public class IdentityChangeEventSender { }; } - private IdentityProcessor detectChangesInTrustedIdentities(Multimap newIdentities, Multimap oldIdentities) { + private IdentityProcessor detectChangesInTrustedIdentities(Map> newIdentities, Map> oldIdentities) { return new DefaultIdentityProcessor(oldIdentities, newIdentities); } private class DefaultIdentityProcessor implements IdentityProcessor { - private final Multimap oldIdentities; - private final Multimap newIdentities; + private final Map> oldIdentities; + private final Map> newIdentities; - public DefaultIdentityProcessor(Multimap oldIdentities, Multimap newIdentities) { + public DefaultIdentityProcessor(Map> oldIdentities, Map> newIdentities) { this.oldIdentities = oldIdentities; this.newIdentities = newIdentities; }