Add method to set listen only on a peer
[jFCPlib.git] / src / main / java / net / pterodactylus / fcp / quelaton / ModifyPeerCommandImpl.java
index e709e5b..58d750d 100644 (file)
@@ -28,6 +28,7 @@ public class ModifyPeerCommandImpl implements ModifyPeerCommand {
        private final AtomicReference<Boolean> enabled = new AtomicReference<>();
        private final AtomicReference<Boolean> allowLocalAddresses = new AtomicReference<>();
        private final AtomicReference<Boolean> burstOnly = new AtomicReference<>();
+       private final AtomicReference<Boolean> listenOnly = new AtomicReference<>();
 
        public ModifyPeerCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) {
                this.threadPool = MoreExecutors.listeningDecorator(threadPool);
@@ -71,6 +72,12 @@ public class ModifyPeerCommandImpl implements ModifyPeerCommand {
        }
 
        @Override
+       public ModifyPeerCommand setListenOnly() {
+               listenOnly.set(true);
+               return this;
+       }
+
+       @Override
        public Executable<Optional<Peer>> byName(String name) {
                nodeIdentifier.set(name);
                return this::execute;
@@ -97,6 +104,7 @@ public class ModifyPeerCommandImpl implements ModifyPeerCommand {
                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));
+               Optional.ofNullable(listenOnly.get()).ifPresent(listenOnly -> modifyPeer.setListenOnly(listenOnly));
                try (ModifyPeerDialog modifyPeerDialog = new ModifyPeerDialog()) {
                        return modifyPeerDialog.send(modifyPeer).get();
                }