Add method to include long description in config data
[jFCPlib.git] / src / main / java / net / pterodactylus / fcp / quelaton / GetConfigCommandImpl.java
index 2876661..cc78f96 100644 (file)
@@ -3,6 +3,7 @@ package net.pterodactylus.fcp.quelaton;
 import java.io.IOException;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
 import net.pterodactylus.fcp.ConfigData;
@@ -21,6 +22,13 @@ public class GetConfigCommandImpl implements GetConfigCommand {
 
        private final ListeningExecutorService threadPool;
        private final ConnectionSupplier connectionSupplier;
+       private final AtomicBoolean withCurrent = new AtomicBoolean();
+       private final AtomicBoolean withDefaults = new AtomicBoolean();
+       private final AtomicBoolean withSortOrder = new AtomicBoolean();
+       private final AtomicBoolean withExpertFlag = new AtomicBoolean();
+       private final AtomicBoolean withForceWriteFlag = new AtomicBoolean();
+       private final AtomicBoolean withShortDescription = new AtomicBoolean();
+       private final AtomicBoolean withLongDescription = new AtomicBoolean();
 
        public GetConfigCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) {
                this.threadPool = MoreExecutors.listeningDecorator(threadPool);
@@ -28,12 +36,61 @@ public class GetConfigCommandImpl implements GetConfigCommand {
        }
 
        @Override
+       public GetConfigCommand withCurrent() {
+               withCurrent.set(true);
+               return this;
+       }
+
+       @Override
+       public GetConfigCommand withDefaults() {
+               withDefaults.set(true);
+               return this;
+       }
+
+       @Override
+       public GetConfigCommand withSortOrder() {
+               withSortOrder.set(true);
+               return this;
+       }
+
+       @Override
+       public GetConfigCommand withExpertFlag() {
+               withExpertFlag.set(true);
+               return this;
+       }
+
+       @Override
+       public GetConfigCommand withForceWriteFlag() {
+               withForceWriteFlag.set(true);
+               return this;
+       }
+
+       @Override
+       public GetConfigCommand withShortDescription() {
+               withShortDescription.set(true);
+               return this;
+       }
+
+       @Override
+       public GetConfigCommand withLongDescription() {
+               withLongDescription.set(true);
+               return this;
+       }
+
+       @Override
        public ListenableFuture<ConfigData> execute() {
                return threadPool.submit(this::executeDialog);
        }
 
        private ConfigData executeDialog() throws IOException, ExecutionException, InterruptedException {
                GetConfig getConfig = new GetConfig(new RandomIdentifierGenerator().generate());
+               getConfig.setWithCurrent(withCurrent.get());
+               getConfig.setWithDefaults(withDefaults.get());
+               getConfig.setWithSortOrder(withSortOrder.get());
+               getConfig.setWithExpertFlag(withExpertFlag.get());
+               getConfig.setWithForceWriteFlag(withForceWriteFlag.get());
+               getConfig.setWithShortDescription(withShortDescription.get());
+               getConfig.setWithLongDescription(withLongDescription.get());
                try (GetConfigDialog getConfigDialog = new GetConfigDialog()) {
                        return getConfigDialog.send(getConfig).get();
                }