com.julienviet.rxjava.pgclient.PgTransaction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of reactive-pg-client Show documentation
Show all versions of reactive-pg-client Show documentation
The reactive Postgres client
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.julienviet.rxjava.pgclient;
import java.util.Map;
import rx.Observable;
import rx.Single;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
/**
* A transaction that allows to control the transaction and receive events.
*
*
* NOTE: This class has been automatically generated from the {@link com.julienviet.pgclient.PgTransaction original} non RX-ified interface using Vert.x codegen.
*/
@io.vertx.lang.rxjava.RxGen(com.julienviet.pgclient.PgTransaction.class)
public class PgTransaction {
@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;
PgTransaction that = (PgTransaction) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final io.vertx.lang.rxjava.TypeArg __TYPE_ARG = new io.vertx.lang.rxjava.TypeArg<>(
obj -> new PgTransaction((com.julienviet.pgclient.PgTransaction) obj),
PgTransaction::getDelegate
);
private final com.julienviet.pgclient.PgTransaction delegate;
public PgTransaction(com.julienviet.pgclient.PgTransaction delegate) {
this.delegate = delegate;
}
public com.julienviet.pgclient.PgTransaction getDelegate() {
return delegate;
}
/**
* Commit the current transaction.
*/
public void commit() {
delegate.commit();
}
/**
* Like {@link com.julienviet.rxjava.pgclient.PgTransaction#commit} with an handler to be notified when the transaction commit has completed
* @param handler
*/
public void commit(Handler> handler) {
delegate.commit(handler);
}
/**
* Like {@link com.julienviet.rxjava.pgclient.PgTransaction#commit} with an handler to be notified when the transaction commit has completed
* @return
*/
public Single rxCommit() {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
commit(fut);
}));
}
/**
* Rollback the current transaction.
*/
public void rollback() {
delegate.rollback();
}
/**
* Like {@link com.julienviet.rxjava.pgclient.PgTransaction#rollback} with an handler to be notified when the transaction rollback has completed
* @param handler
*/
public void rollback(Handler> handler) {
delegate.rollback(handler);
}
/**
* Like {@link com.julienviet.rxjava.pgclient.PgTransaction#rollback} with an handler to be notified when the transaction rollback has completed
* @return
*/
public Single rxRollback() {
return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> {
rollback(fut);
}));
}
/**
* Set an handler to be called when the transaction is aborted.
* @param handler the handler
* @return
*/
public PgTransaction abortHandler(Handler handler) {
delegate.abortHandler(handler);
return this;
}
public static PgTransaction newInstance(com.julienviet.pgclient.PgTransaction arg) {
return arg != null ? new PgTransaction(arg) : null;
}
}