private final AtomicReference<String> nodeIdentifier = new AtomicReference<>();
private final AtomicReference<Boolean> enabled = new AtomicReference<>();
private final AtomicReference<Boolean> allowLocalAddresses = new AtomicReference<>();
+ private final AtomicReference<Boolean> burstOnly = new AtomicReference<>();
public ModifyPeerCommandImpl(ExecutorService threadPool, ConnectionSupplier connectionSupplier) {
this.threadPool = MoreExecutors.listeningDecorator(threadPool);
}
@Override
+ public ModifyPeerCommand disallowLocalAddresses() {
+ allowLocalAddresses.set(false);
+ return this;
+ }
+
+ @Override
+ public ModifyPeerCommand setBurstOnly() {
+ burstOnly.set(true);
+ return this;
+ }
+
+ @Override
+ public ModifyPeerCommand clearBurstOnly() {
+ burstOnly.set(false);
+ return this;
+ }
+
+ @Override
public Executable<Optional<Peer>> byName(String name) {
nodeIdentifier.set(name);
return this::execute;
ModifyPeer modifyPeer = new ModifyPeer(new RandomIdentifierGenerator().generate(), 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));
try (ModifyPeerDialog modifyPeerDialog = new ModifyPeerDialog()) {
return modifyPeerDialog.send(modifyPeer).get();
}