package io.vertx.reactivex.kafka.client.producer;
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.kafka.client.producer.RecordMetadata;
import io.vertx.kafka.client.common.PartitionInfo;
import java.util.List;
import java.util.Map;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
@io.vertx.lang.rx.RxGen(io.vertx.kafka.client.producer.KafkaProducer.class)
public class KafkaProducer<K,V> implements io.vertx.reactivex.core.streams.WriteStream<io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V>> {
@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;
KafkaProducer that = (KafkaProducer) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final io.vertx.lang.rx.TypeArg<KafkaProducer> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new KafkaProducer((io.vertx.kafka.client.producer.KafkaProducer) obj),
KafkaProducer::getDelegate
);
private final io.vertx.kafka.client.producer.KafkaProducer<K,V> delegate;
public final io.vertx.lang.rx.TypeArg<K> __typeArg_0;
public final io.vertx.lang.rx.TypeArg<V> __typeArg_1;
public KafkaProducer(io.vertx.kafka.client.producer.KafkaProducer delegate) {
this.delegate = delegate;
this.__typeArg_0 = io.vertx.lang.rx.TypeArg.unknown(); this.__typeArg_1 = io.vertx.lang.rx.TypeArg.unknown(); }
public KafkaProducer(io.vertx.kafka.client.producer.KafkaProducer delegate, io.vertx.lang.rx.TypeArg<K> typeArg_0, io.vertx.lang.rx.TypeArg<V> typeArg_1) {
this.delegate = delegate;
this.__typeArg_0 = typeArg_0;
this.__typeArg_1 = typeArg_1;
}
public io.vertx.kafka.client.producer.KafkaProducer getDelegate() {
return delegate;
}
private io.vertx.reactivex.WriteStreamObserver<io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V>> observer;
private io.vertx.reactivex.WriteStreamSubscriber<io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V>> subscriber;
public synchronized io.vertx.reactivex.WriteStreamObserver<io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V>> toObserver() {
if (observer == null) {
java.util.function.Function<io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord, io.vertx.kafka.client.producer.KafkaProducerRecord<K,V>> conv = io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V>::getDelegate;
observer = io.vertx.reactivex.RxHelper.toObserver(getDelegate(), conv);
}
return observer;
}
public synchronized io.vertx.reactivex.WriteStreamSubscriber<io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V>> toSubscriber() {
if (subscriber == null) {
java.util.function.Function<io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord, io.vertx.kafka.client.producer.KafkaProducerRecord<K,V>> conv = io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V>::getDelegate;
subscriber = io.vertx.reactivex.RxHelper.toSubscriber(getDelegate(), conv);
}
return subscriber;
}
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 end(io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V> data) {
delegate.end(data.getDelegate());
}
public void end(io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V> data, Handler<AsyncResult<Void>> handler) {
delegate.end(data.getDelegate(), handler);
}
public Completable rxEnd(io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V> data) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
end(data, handler);
});
}
public static <K, V> io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> createShared(io.vertx.reactivex.core.Vertx vertx, String name, Map<String, String> config) {
io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> ret = io.vertx.reactivex.kafka.client.producer.KafkaProducer.newInstance(io.vertx.kafka.client.producer.KafkaProducer.createShared(vertx.getDelegate(), name, config), io.vertx.lang.rx.TypeArg.unknown(), io.vertx.lang.rx.TypeArg.unknown());
return ret;
}
public static <K, V> io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> createShared(io.vertx.reactivex.core.Vertx vertx, String name, Map<String, String> config, Class<K> keyType, Class<V> valueType) {
io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> ret = io.vertx.reactivex.kafka.client.producer.KafkaProducer.newInstance(io.vertx.kafka.client.producer.KafkaProducer.createShared(vertx.getDelegate(), name, config, io.vertx.lang.reactivex.Helper.unwrap(keyType), io.vertx.lang.reactivex.Helper.unwrap(valueType)), io.vertx.lang.rx.TypeArg.of(keyType), io.vertx.lang.rx.TypeArg.of(valueType));
return ret;
}
public static <K, V> io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> create(io.vertx.reactivex.core.Vertx vertx, Map<String, String> config) {
io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> ret = io.vertx.reactivex.kafka.client.producer.KafkaProducer.newInstance(io.vertx.kafka.client.producer.KafkaProducer.create(vertx.getDelegate(), config), io.vertx.lang.rx.TypeArg.unknown(), io.vertx.lang.rx.TypeArg.unknown());
return ret;
}
public static <K, V> io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> create(io.vertx.reactivex.core.Vertx vertx, Map<String, String> config, Class<K> keyType, Class<V> valueType) {
io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> ret = io.vertx.reactivex.kafka.client.producer.KafkaProducer.newInstance(io.vertx.kafka.client.producer.KafkaProducer.create(vertx.getDelegate(), config, io.vertx.lang.reactivex.Helper.unwrap(keyType), io.vertx.lang.reactivex.Helper.unwrap(valueType)), io.vertx.lang.rx.TypeArg.of(keyType), io.vertx.lang.rx.TypeArg.of(valueType));
return ret;
}
public io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> exceptionHandler(Handler<Throwable> handler) {
delegate.exceptionHandler(handler);
return this;
}
public io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> write(io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V> kafkaProducerRecord) {
delegate.write(kafkaProducerRecord.getDelegate());
return this;
}
public io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> setWriteQueueMaxSize(int i) {
delegate.setWriteQueueMaxSize(i);
return this;
}
public boolean writeQueueFull() {
boolean ret = delegate.writeQueueFull();
return ret;
}
public io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> drainHandler(Handler<Void> handler) {
delegate.drainHandler(handler);
return this;
}
public io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> write(io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V> data, Handler<AsyncResult<Void>> handler) {
delegate.write(data.getDelegate(), handler);
return this;
}
public Completable rxWrite(io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V> data) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
write(data, handler);
});
}
public io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> send(io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V> record) {
delegate.send(record.getDelegate());
return this;
}
public io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> send(io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V> record, Handler<AsyncResult<RecordMetadata>> handler) {
delegate.send(record.getDelegate(), handler);
return this;
}
public Single<RecordMetadata> rxSend(io.vertx.reactivex.kafka.client.producer.KafkaProducerRecord<K, V> record) {
return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> {
send(record, handler);
});
}
public io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> partitionsFor(String topic, Handler<AsyncResult<List<PartitionInfo>>> handler) {
delegate.partitionsFor(topic, handler);
return this;
}
public Single<List<PartitionInfo>> rxPartitionsFor(String topic) {
return io.vertx.reactivex.impl.AsyncResultSingle.toSingle(handler -> {
partitionsFor(topic, handler);
});
}
public io.vertx.reactivex.kafka.client.producer.KafkaProducer<K, V> flush(Handler<Void> completionHandler) {
delegate.flush(completionHandler);
return this;
}
public void close() {
delegate.close();
}
public void close(Handler<AsyncResult<Void>> completionHandler) {
delegate.close(completionHandler);
}
public Completable rxClose() {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
close(handler);
});
}
public void close(long timeout, Handler<AsyncResult<Void>> completionHandler) {
delegate.close(timeout, completionHandler);
}
public Completable rxClose(long timeout) {
return io.vertx.reactivex.impl.AsyncResultCompletable.toCompletable(handler -> {
close(timeout, handler);
});
}
public static <K,V>KafkaProducer<K,V> newInstance(io.vertx.kafka.client.producer.KafkaProducer arg) {
return arg != null ? new KafkaProducer<K,V>(arg) : null;
}
public static <K,V>KafkaProducer<K,V> newInstance(io.vertx.kafka.client.producer.KafkaProducer arg, io.vertx.lang.rx.TypeArg<K> __typeArg_K, io.vertx.lang.rx.TypeArg<V> __typeArg_V) {
return arg != null ? new KafkaProducer<K,V>(arg, __typeArg_K, __typeArg_V) : null;
}
}