package io.vertx.reactivex.core.eventbus;
import java.util.Map;
import io.reactivex.Observable;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.Completable;
import io.reactivex.Maybe;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
@io.vertx.lang.rx.RxGen(io.vertx.core.eventbus.MessageProducer.class)
public class MessageProducer<T> implements io.vertx.reactivex.core.streams.WriteStream<T> {
@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;
MessageProducer that = (MessageProducer) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final io.vertx.lang.rx.TypeArg<MessageProducer> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new MessageProducer((io.vertx.core.eventbus.MessageProducer) obj),
MessageProducer::getDelegate
);
private final io.vertx.core.eventbus.MessageProducer<T> delegate;
public final io.vertx.lang.rx.TypeArg<T> __typeArg_0;
public MessageProducer(io.vertx.core.eventbus.MessageProducer delegate) {
this.delegate = delegate;
this.__typeArg_0 = io.vertx.lang.rx.TypeArg.unknown(); }
public MessageProducer(io.vertx.core.eventbus.MessageProducer delegate, io.vertx.lang.rx.TypeArg<T> typeArg_0) {
this.delegate = delegate;
this.__typeArg_0 = typeArg_0;
}
public io.vertx.core.eventbus.MessageProducer getDelegate() {
return delegate;
}
private io.vertx.reactivex.WriteStreamObserver<T> observer;
private io.vertx.reactivex.WriteStreamSubscriber<T> subscriber;
public synchronized io.vertx.reactivex.WriteStreamObserver<T> toObserver() {
if (observer == null) {
java.util.function.Function<T, T> conv = (java.util.function.Function<T, T>) __typeArg_0.unwrap;
observer = io.vertx.reactivex.RxHelper.toObserver(getDelegate(), conv);
}
return observer;
}
public synchronized io.vertx.reactivex.WriteStreamSubscriber<T> toSubscriber() {
if (subscriber == null) {
java.util.function.Function<T, T> conv = (java.util.function.Function<T, T>) __typeArg_0.unwrap;
subscriber = io.vertx.reactivex.RxHelper.toSubscriber(getDelegate(), conv);
}
return subscriber;
}
public void end(T data) {
delegate.end(__typeArg_0.<T>unwrap(data));
}
public void end(T data, Handler<AsyncResult<Void>> handler) {
delegate.end(__typeArg_0.<T>unwrap(data), handler);
}
public Completable rxEnd(T data) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
end(data, handler);
});
}
public boolean writeQueueFull() {
boolean ret = delegate.writeQueueFull();
return ret;
}
@Deprecated()
public io.vertx.reactivex.core.eventbus.MessageProducer<T> send(T message) {
io.vertx.reactivex.core.eventbus.MessageProducer<T> ret = io.vertx.reactivex.core.eventbus.MessageProducer.newInstance(delegate.send(__typeArg_0.<T>unwrap(message)), __typeArg_0);
return ret;
}
@Deprecated()
public <R> io.vertx.reactivex.core.eventbus.MessageProducer<T> send(T message, Handler<AsyncResult<io.vertx.reactivex.core.eventbus.Message<R>>> replyHandler) {
io.vertx.reactivex.core.eventbus.MessageProducer<T> ret = io.vertx.reactivex.core.eventbus.MessageProducer.newInstance(delegate.send(__typeArg_0.<T>unwrap(message), new Handler<AsyncResult<io.vertx.core.eventbus.Message<R>>>() {
public void handle(AsyncResult<io.vertx.core.eventbus.Message<R>> ar) {
if (ar.succeeded()) {
replyHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.reactivex.core.eventbus.Message.newInstance(ar.result(), io.vertx.lang.rx.TypeArg.unknown())));
} else {
replyHandler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
}
}
}), __typeArg_0);
return ret;
}
public io.vertx.reactivex.core.eventbus.MessageProducer<T> exceptionHandler(Handler<Throwable> handler) {
delegate.exceptionHandler(handler);
return this;
}
public io.vertx.reactivex.core.eventbus.MessageProducer<T> write(T data) {
delegate.write(__typeArg_0.<T>unwrap(data));
return this;
}
public io.vertx.reactivex.core.eventbus.MessageProducer<T> write(T data, Handler<AsyncResult<Void>> handler) {
delegate.write(__typeArg_0.<T>unwrap(data), handler);
return this;
}
public Completable rxWrite(T data) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
write(data, handler);
});
}
public io.vertx.reactivex.core.eventbus.MessageProducer<T> setWriteQueueMaxSize(int maxSize) {
delegate.setWriteQueueMaxSize(maxSize);
return this;
}
public io.vertx.reactivex.core.eventbus.MessageProducer<T> drainHandler(Handler<Void> handler) {
delegate.drainHandler(handler);
return this;
}
public io.vertx.reactivex.core.eventbus.MessageProducer<T> deliveryOptions(DeliveryOptions options) {
delegate.deliveryOptions(options);
return this;
}
public String address() {
String ret = delegate.address();
return ret;
}
public void end() {
delegate.end();
}
public void end(Handler<AsyncResult<Void>> handler) {
delegate.end(handler);
}
public Completable rxEnd() {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
end(handler);
});
}
public void close() {
delegate.close();
}
public void close(Handler<AsyncResult<Void>> handler) {
delegate.close(handler);
}
public Completable rxClose() {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
close(handler);
});
}
public static final int DEFAULT_WRITE_QUEUE_MAX_SIZE = io.vertx.core.eventbus.MessageProducer.DEFAULT_WRITE_QUEUE_MAX_SIZE;
public static <T>MessageProducer<T> newInstance(io.vertx.core.eventbus.MessageProducer arg) {
return arg != null ? new MessageProducer<T>(arg) : null;
}
public static <T>MessageProducer<T> newInstance(io.vertx.core.eventbus.MessageProducer arg, io.vertx.lang.rx.TypeArg<T> __typeArg_T) {
return arg != null ? new MessageProducer<T>(arg, __typeArg_T) : null;
}
}