From 636778331c5bd52882a5a2851dbced8a000036d3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 19 Sep 2019 21:15:52 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=94=A5=20Remove=20obsolete=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/freenet/wot/Identity.java | 14 -------------- .../sone/freenet/wot/IdentityChangeDetector.java | 12 +++++------- 2 files changed, 5 insertions(+), 21 deletions(-) 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 a99aac0..b4ca58c 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/Identity.java @@ -31,20 +31,6 @@ import com.google.common.base.Function; */ public interface Identity { - public static final Function> TO_CONTEXTS = new Function>() { - @Override - public Set apply(Identity identity) { - return (identity == null) ? Collections.emptySet() : identity.getContexts(); - } - }; - - public static final Function> TO_PROPERTIES = new Function>() { - @Override - public Map apply(Identity input) { - return (input == null) ? Collections.emptyMap() : input.getProperties(); - } - }; - /** * Returns the ID of the identity. * 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 8b28011..c45c012 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityChangeDetector.java @@ -21,8 +21,6 @@ import static com.google.common.base.Optional.absent; import static com.google.common.base.Optional.fromNullable; import static com.google.common.base.Predicates.not; import static com.google.common.collect.FluentIterable.from; -import static net.pterodactylus.sone.freenet.wot.Identity.TO_CONTEXTS; -import static net.pterodactylus.sone.freenet.wot.Identity.TO_PROPERTIES; import java.util.Collection; import java.util.Map; @@ -117,23 +115,23 @@ public class IdentityChangeDetector { } private static boolean identityHasNewContexts(Identity oldIdentity, Identity newIdentity) { - return from(TO_CONTEXTS.apply(newIdentity)).anyMatch(notAContextOf(oldIdentity)); + return newIdentity.getContexts().stream().anyMatch(notAContextOf(oldIdentity)::apply); } private static boolean identityHasRemovedContexts(Identity oldIdentity, Identity newIdentity) { - return from(TO_CONTEXTS.apply(oldIdentity)).anyMatch(notAContextOf(newIdentity)); + return oldIdentity.getContexts().stream().anyMatch(notAContextOf(newIdentity)::apply); } private static boolean identityHasNewProperties(Identity oldIdentity, Identity newIdentity) { - return from(TO_PROPERTIES.apply(newIdentity).entrySet()).anyMatch(notAPropertyOf(oldIdentity)); + return newIdentity.getProperties().entrySet().stream().anyMatch(notAPropertyOf(oldIdentity)::apply); } private static boolean identityHasRemovedProperties(Identity oldIdentity, Identity newIdentity) { - return from(TO_PROPERTIES.apply(oldIdentity).entrySet()).anyMatch(notAPropertyOf(newIdentity)); + return oldIdentity.getProperties().entrySet().stream().anyMatch(notAPropertyOf(newIdentity)::apply); } private static boolean identityHasChangedProperties(Identity oldIdentity, Identity newIdentity) { - return from(TO_PROPERTIES.apply(oldIdentity).entrySet()).anyMatch(hasADifferentValueThanIn(newIdentity)); + return oldIdentity.getProperties().entrySet().stream().anyMatch(hasADifferentValueThanIn(newIdentity)::apply); } private static Predicate containedIn(final Map identities) { -- 2.7.4