From 860029508a9860de1c7a0c0b2fdcbe5b642a5f16 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 1 May 2020 16:01:40 +0200 Subject: [PATCH] =?utf8?q?=E2=99=BB=EF=B8=8F=20Refactor=20parts=20of=20ide?= =?utf8?q?ntity=20removal?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/core/Core.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index da1b2f8..9354063 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1581,13 +1581,8 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, OwnIdentity ownIdentity = identityRemovedEvent.getOwnIdentity(); Identity identity = identityRemovedEvent.getIdentity(); trustedIdentities.remove(ownIdentity, identity); - for (Entry> trustedIdentity : trustedIdentities.asMap().entrySet()) { - if (trustedIdentity.getKey().equals(ownIdentity)) { - continue; - } - if (trustedIdentity.getValue().contains(identity)) { - return; - } + if (otherOwnIdentityStillKnowsIdentity(ownIdentity, identity)) { + return; } Sone sone = getSone(identity.getId()); if (sone == null) { @@ -1604,6 +1599,10 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, database.removeSone(sone); } + private boolean otherOwnIdentityStillKnowsIdentity(OwnIdentity ownIdentity, Identity identity) { + return trustedIdentities.entries().stream().anyMatch(e -> !e.getKey().equals(ownIdentity) && e.getValue().equals(identity)); + } + /** * Deletes the temporary image. * -- 2.7.4