X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Ffcp%2Fquelaton%2FModifyPeerNoteCommandImpl.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Ffcp%2Fquelaton%2FModifyPeerNoteCommandImpl.java;h=a3b9aa1e6c1f8e6d6db642c40e57a933659520f1;hb=7a3be5ca037785f4f1acb225381578db12d15eb1;hp=6e6dcc2106fd53debccbac7e8fbaef6123488960;hpb=91de0a638af50527fc314ed97a095d1beaf36866;p=jFCPlib.git diff --git a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerNoteCommandImpl.java b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerNoteCommandImpl.java index 6e6dcc2..a3b9aa1 100644 --- a/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerNoteCommandImpl.java +++ b/src/main/java/net/pterodactylus/fcp/quelaton/ModifyPeerNoteCommandImpl.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.FreenetBase64; import net.pterodactylus.fcp.ModifyPeerNote; @@ -26,15 +27,16 @@ import com.google.common.util.concurrent.MoreExecutors; public class ModifyPeerNoteCommandImpl implements ModifyPeerNoteCommand { private static final FreenetBase64 BASE_64 = new FreenetBase64(); - private static final RandomIdentifierGenerator RANDOM_IDENTIFIER_GENERATOR = new RandomIdentifierGenerator(); private final ListeningExecutorService threadPool; private final ConnectionSupplier connectionSupplier; + private final Supplier identifierGenerator; private final AtomicReference nodeIdentifier = new AtomicReference<>(); private final AtomicReference darknetComment = new AtomicReference<>(); - public ModifyPeerNoteCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) { + public ModifyPeerNoteCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier, Supplier identifierGenerator) { this.threadPool = MoreExecutors.listeningDecorator(threadPool); this.connectionSupplier = connectionSupplier; + this.identifierGenerator = identifierGenerator; } @Override @@ -70,7 +72,7 @@ public class ModifyPeerNoteCommandImpl implements ModifyPeerNoteCommand { private Boolean executeDialog() throws IOException, ExecutionException, InterruptedException { ModifyPeerNote modifyPeerNote = - new ModifyPeerNote(RANDOM_IDENTIFIER_GENERATOR.generate(), nodeIdentifier.get()); + new ModifyPeerNote(identifierGenerator.get(), nodeIdentifier.get()); modifyPeerNote.setPeerNoteType(PeerNoteType.PRIVATE_DARKNET_COMMENT); modifyPeerNote.setNoteText(BASE_64.encode(darknetComment.get().getBytes(StandardCharsets.UTF_8))); try (ModifyPeerNoteDialog modifyPeerNoteDialog = new ModifyPeerNoteDialog()) {