From: David ‘Bombe’ Roden Date: Tue, 12 Nov 2013 05:30:20 +0000 (+0100) Subject: Convert an Identity into a Map, not a Collection of Entrys. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c6c5a9f17eaab1656455f4a1b582fc411aab5eb4;p=Sone.git Convert an Identity into a Map, not a Collection of Entrys. --- diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java b/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java index 523a42b..d0cafc5 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java @@ -20,7 +20,6 @@ package net.pterodactylus.sone.freenet.wot; import java.util.Collection; import java.util.Collections; import java.util.Map; -import java.util.Map.Entry; import java.util.Set; import com.google.common.base.Function; @@ -41,10 +40,10 @@ public interface Identity { } }; - public static final Function>> TO_PROPERTIES = new Function>>() { + public static final Function> TO_PROPERTIES = new Function>() { @Override - public Collection> apply(Identity input) { - return (input == null) ? Collections.>emptySet() : input.getProperties().entrySet(); + public Map apply(Identity input) { + return (input == null) ? Collections.emptyMap() : input.getProperties(); } }; diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetector.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetector.java index 3a0cb4b..a8cb62b 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetector.java @@ -127,15 +127,15 @@ public class IdentityChangeDetector { } private static boolean identityHasNewProperties(Identity oldIdentity, Identity newIdentity) { - return from(TO_PROPERTIES.apply(newIdentity)).anyMatch(notAPropertyOf(oldIdentity)); + return from(TO_PROPERTIES.apply(newIdentity).entrySet()).anyMatch(notAPropertyOf(oldIdentity)); } private static boolean identityHasRemovedProperties(Identity oldIdentity, Identity newIdentity) { - return from(TO_PROPERTIES.apply(oldIdentity)).anyMatch(notAPropertyOf(newIdentity)); + return from(TO_PROPERTIES.apply(oldIdentity).entrySet()).anyMatch(notAPropertyOf(newIdentity)); } private static boolean identityHasChangedProperties(Identity oldIdentity, Identity newIdentity) { - return from(TO_PROPERTIES.apply(oldIdentity)).anyMatch(hasADifferentValueThanIn(newIdentity)); + return from(TO_PROPERTIES.apply(oldIdentity).entrySet()).anyMatch(hasADifferentValueThanIn(newIdentity)); } private static Predicate containedIn(final Map identities) {