X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FIdentityLoader.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffreenet%2Fwot%2FIdentityLoader.java;h=b446e71cabc9d20d9aff62e5009c07bf75254f01;hp=0917130f2fa279b589995334c10c54e4d3cf02ae;hb=8c46c562753c6cff5510f2d628b5adc4f315ffa2;hpb=46d3d75e26cda2484932fcc2607d6768bc99e810 diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java index 0917130..b446e71 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java @@ -17,17 +17,15 @@ package net.pterodactylus.sone.freenet.wot; -import static java.util.concurrent.TimeUnit.*; -import static net.pterodactylus.sone.freenet.wot.Context.*; - import java.util.*; import java.util.logging.*; +import javax.annotation.*; -import net.pterodactylus.sone.freenet.plugin.*; - -import com.google.common.base.Optional; import com.google.common.base.*; import com.google.inject.*; +import net.pterodactylus.sone.freenet.plugin.*; + +import static java.util.concurrent.TimeUnit.*; /** * Loads {@link OwnIdentity}s and the {@link Identity}s they trust. @@ -36,14 +34,15 @@ public class IdentityLoader { private final Logger logger = Logger.getLogger(IdentityLoader.class.getName()); private final WebOfTrustConnector webOfTrustConnector; - private final Optional context; + @Nullable + private final Context context; public IdentityLoader(WebOfTrustConnector webOfTrustConnector) { - this(webOfTrustConnector, Optional.absent()); + this(webOfTrustConnector, null); } @Inject - public IdentityLoader(WebOfTrustConnector webOfTrustConnector, Optional context) { + public IdentityLoader(WebOfTrustConnector webOfTrustConnector, @Nullable Context context) { this.webOfTrustConnector = webOfTrustConnector; this.context = context; } @@ -65,7 +64,7 @@ public class IdentityLoader { } Stopwatch stopwatch = Stopwatch.createStarted(); - Set trustedIdentities = webOfTrustConnector.loadTrustedIdentities(ownIdentity, context.transform(extractContext)); + Set trustedIdentities = webOfTrustConnector.loadTrustedIdentities(ownIdentity, (context == null) ? null : context.getContext()); logger.fine("Loaded " + trustedIdentities.size() + " identities for " + ownIdentity.getNickname() + " in " + (stopwatch.elapsed(MILLISECONDS) / 1000.0) + "s."); currentIdentities.put(ownIdentity, trustedIdentities); } @@ -74,7 +73,7 @@ public class IdentityLoader { } private boolean identityDoesNotHaveTheCorrectContext(OwnIdentity ownIdentity) { - return context.isPresent() && !ownIdentity.hasContext(context.transform(extractContext).get()); + return (context != null) && !ownIdentity.hasContext(context.getContext()); } }