package io.vertx.reactivex.ext.shell.command;
import io.vertx.reactivex.RxHelper;
import io.vertx.reactivex.ObservableHelper;
import io.vertx.reactivex.FlowableHelper;
import io.vertx.reactivex.impl.AsyncResultMaybe;
import io.vertx.reactivex.impl.AsyncResultSingle;
import io.vertx.reactivex.impl.AsyncResultCompletable;
import io.vertx.reactivex.WriteStreamObserver;
import io.vertx.reactivex.WriteStreamSubscriber;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;
@RxGen(io.vertx.ext.shell.command.CommandRegistry.class)
public class CommandRegistry extends io.vertx.reactivex.ext.shell.command.CommandResolver {
@Override
public String toString() {
return delegate.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CommandRegistry that = (CommandRegistry) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final TypeArg<CommandRegistry> __TYPE_ARG = new TypeArg<>( obj -> new CommandRegistry((io.vertx.ext.shell.command.CommandRegistry) obj),
CommandRegistry::getDelegate
);
private final io.vertx.ext.shell.command.CommandRegistry delegate;
public CommandRegistry(io.vertx.ext.shell.command.CommandRegistry delegate) {
super(delegate);
this.delegate = delegate;
}
public CommandRegistry(Object delegate) {
super((io.vertx.ext.shell.command.CommandRegistry)delegate);
this.delegate = (io.vertx.ext.shell.command.CommandRegistry)delegate;
}
public io.vertx.ext.shell.command.CommandRegistry getDelegate() {
return delegate;
}
public static io.vertx.reactivex.ext.shell.command.CommandRegistry getShared(io.vertx.reactivex.core.Vertx vertx) {
io.vertx.reactivex.ext.shell.command.CommandRegistry ret = io.vertx.reactivex.ext.shell.command.CommandRegistry.newInstance((io.vertx.ext.shell.command.CommandRegistry)io.vertx.ext.shell.command.CommandRegistry.getShared(vertx.getDelegate()));
return ret;
}
public static io.vertx.reactivex.ext.shell.command.CommandRegistry create(io.vertx.reactivex.core.Vertx vertx) {
io.vertx.reactivex.ext.shell.command.CommandRegistry ret = io.vertx.reactivex.ext.shell.command.CommandRegistry.newInstance((io.vertx.ext.shell.command.CommandRegistry)io.vertx.ext.shell.command.CommandRegistry.create(vertx.getDelegate()));
return ret;
}
public io.vertx.reactivex.ext.shell.command.CommandRegistry registerCommand(io.vertx.reactivex.ext.shell.command.Command command, Handler<AsyncResult<io.vertx.reactivex.ext.shell.command.Command>> completionHandler) {
delegate.registerCommand(command.getDelegate(), new Handler<AsyncResult<io.vertx.ext.shell.command.Command>>() {
public void handle(AsyncResult<io.vertx.ext.shell.command.Command> ar) {
if (ar.succeeded()) {
completionHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.ext.shell.command.Command.newInstance((io.vertx.ext.shell.command.Command)ar.result())));
} else {
completionHandler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
public io.vertx.reactivex.ext.shell.command.CommandRegistry registerCommand(io.vertx.reactivex.ext.shell.command.Command command) {
return
registerCommand(command, ar -> { });
}
public io.reactivex.Single<io.vertx.reactivex.ext.shell.command.Command> rxRegisterCommand(io.vertx.reactivex.ext.shell.command.Command command) {
return AsyncResultSingle.toSingle($handler -> {
registerCommand(command, $handler);
});
}
public io.vertx.reactivex.ext.shell.command.CommandRegistry registerCommands(List<io.vertx.reactivex.ext.shell.command.Command> commands, Handler<AsyncResult<List<io.vertx.reactivex.ext.shell.command.Command>>> completionHandler) {
delegate.registerCommands(commands.stream().map(elt -> elt.getDelegate()).collect(Collectors.toList()), new Handler<AsyncResult<List<io.vertx.ext.shell.command.Command>>>() {
public void handle(AsyncResult<List<io.vertx.ext.shell.command.Command>> ar) {
if (ar.succeeded()) {
completionHandler.handle(io.vertx.core.Future.succeededFuture(ar.result().stream().map(elt -> io.vertx.reactivex.ext.shell.command.Command.newInstance((io.vertx.ext.shell.command.Command)elt)).collect(Collectors.toList())));
} else {
completionHandler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
});
return this;
}
public io.vertx.reactivex.ext.shell.command.CommandRegistry registerCommands(List<io.vertx.reactivex.ext.shell.command.Command> commands) {
return
registerCommands(commands, ar -> { });
}
public io.reactivex.Single<List<io.vertx.reactivex.ext.shell.command.Command>> rxRegisterCommands(List<io.vertx.reactivex.ext.shell.command.Command> commands) {
return AsyncResultSingle.toSingle($handler -> {
registerCommands(commands, $handler);
});
}
public io.vertx.reactivex.ext.shell.command.CommandRegistry unregisterCommand(String commandName, Handler<AsyncResult<Void>> completionHandler) {
delegate.unregisterCommand(commandName, completionHandler);
return this;
}
public io.vertx.reactivex.ext.shell.command.CommandRegistry unregisterCommand(String commandName) {
return
unregisterCommand(commandName, ar -> { });
}
public io.reactivex.Completable rxUnregisterCommand(String commandName) {
return AsyncResultCompletable.toCompletable($handler -> {
unregisterCommand(commandName, $handler);
});
}
public static CommandRegistry newInstance(io.vertx.ext.shell.command.CommandRegistry arg) {
return arg != null ? new CommandRegistry(arg) : null;
}
}