Convert an Identity into a Map, not a Collection of Entrys.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 12 Nov 2013 05:30:20 +0000 (06:30 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:25:59 +0000 (22:25 +0100)
src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java
src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetector.java

index 523a42b..d0cafc5 100644 (file)
@@ -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<Identity, Collection<Map.Entry<String, String>>> TO_PROPERTIES = new Function<Identity, Collection<Entry<String, String>>>() {
+       public static final Function<Identity, Map<String, String>> TO_PROPERTIES = new Function<Identity, Map<String, String>>() {
                @Override
-               public Collection<Entry<String, String>> apply(Identity input) {
-                       return (input == null) ? Collections.<Map.Entry<String, String>>emptySet() : input.getProperties().entrySet();
+               public Map<String, String> apply(Identity input) {
+                       return (input == null) ? Collections.<String, String>emptyMap() : input.getProperties();
                }
        };
 
index 3a0cb4b..a8cb62b 100644 (file)
@@ -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<Identity> containedIn(final Map<String, Identity> identities) {