X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Ffcp%2Fquelaton%2FModifyPeerCommandImpl.java;h=9fff845bedf82fe1f10f0813d25451991b5e607c;hb=7a3be5ca037785f4f1acb225381578db12d15eb1;hp=a675280c6009a05124db4d83930033fcbff1289b;hpb=91de0a638af50527fc314ed97a095d1beaf36866;p=jFCPlib.git diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java index a675280..9fff845 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerCommandImpl.java @@ -6,6 +6,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; import net.pterodactylus.fcp.ModifyPeer; import net.pterodactylus.fcp.Peer; @@ -24,6 +25,7 @@ public class ModifyPeerCommandImpl implements ModifyPeerCommand { private final ListeningExecutorService threadPool; private final ConnectionSupplier connectionSupplier; + private final Supplier identifierGenerator; private final AtomicReference nodeIdentifier = new AtomicReference<>(); private final AtomicReference enabled = new AtomicReference<>(); private final AtomicReference allowLocalAddresses = new AtomicReference<>(); @@ -31,9 +33,10 @@ public class ModifyPeerCommandImpl implements ModifyPeerCommand { private final AtomicReference listenOnly = new AtomicReference<>(); private final AtomicReference ignoreSource = new AtomicReference<>(); - public ModifyPeerCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) { + public ModifyPeerCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier, Supplier identifierGenerator) { this.threadPool = MoreExecutors.listeningDecorator(threadPool); this.connectionSupplier = connectionSupplier; + this.identifierGenerator = identifierGenerator; } @Override @@ -119,7 +122,7 @@ public class ModifyPeerCommandImpl implements ModifyPeerCommand { } private Optional executeDialog() throws IOException, ExecutionException, InterruptedException { - ModifyPeer modifyPeer = new ModifyPeer(new RandomIdentifierGenerator().generate(), nodeIdentifier.get()); + ModifyPeer modifyPeer = new ModifyPeer(identifierGenerator.get(), nodeIdentifier.get()); Optional.ofNullable(enabled.get()).ifPresent(enabled -> modifyPeer.setEnabled(enabled)); Optional.ofNullable(allowLocalAddresses.get()).ifPresent(allowed -> modifyPeer.setAllowLocalAddresses(allowed)); Optional.ofNullable(burstOnly.get()).ifPresent(burstOnly -> modifyPeer.setBurstOnly(burstOnly));