Add GetNode command implementation
[jFCPlib.git] / src / main / java / net / pterodactylus / fcp / quelaton / ListPeersCommandImpl.java
index 5638b98..c084cb5 100644 (file)
@@ -11,6 +11,7 @@ import net.pterodactylus.fcp.EndListPeers;
 import net.pterodactylus.fcp.ListPeers;
 import net.pterodactylus.fcp.Peer;
 
+import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 
@@ -23,6 +24,8 @@ public class ListPeersCommandImpl implements ListPeersCommand {
 
        private final ListeningExecutorService threadPool;
        private final ConnectionSupplier connectionSupplier;
+       private final AtomicBoolean includeMetadata = new AtomicBoolean(false);
+       private final AtomicBoolean includeVolatile = new AtomicBoolean(false);
 
        public ListPeersCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) {
                this.threadPool = MoreExecutors.listeningDecorator(threadPool);
@@ -30,9 +33,21 @@ public class ListPeersCommandImpl implements ListPeersCommand {
        }
 
        @Override
-       public Future<Collection<Peer>> execute() {
+       public ListPeersCommand includeMetadata() {
+               includeMetadata.set(true);
+               return this;
+       }
+
+       @Override
+       public ListPeersCommand includeVolatile() {
+               includeVolatile.set(true);
+               return this;
+       }
+
+       @Override
+       public ListenableFuture<Collection<Peer>> execute() {
                String identifier = new RandomIdentifierGenerator().generate();
-               ListPeers listPeers = new ListPeers(identifier);
+               ListPeers listPeers = new ListPeers(identifier, includeMetadata.get(), includeVolatile.get());
                return threadPool.submit(() -> new ListPeersReplySequence().send(listPeers).get());
        }