io.reactiverse.pgclient.impl.CommandResponse 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
package io.reactiverse.pgclient.impl;
import io.reactiverse.pgclient.impl.codec.TxStatus;
import io.vertx.core.AsyncResult;
import io.vertx.core.impl.NoStackTraceThrowable;
public abstract class CommandResponse implements AsyncResult {
static CommandResponse failure(String msg) {
return failure(new NoStackTraceThrowable(msg), null);
}
static CommandResponse failure(String msg, TxStatus txStatus) {
return failure(new NoStackTraceThrowable(msg), txStatus);
}
static CommandResponse failure(Throwable cause) {
return failure(cause, null);
}
static CommandResponse failure(Throwable cause, TxStatus txStatus) {
return new CommandResponse(txStatus) {
@Override
public R result() {
return null;
}
@Override
public Throwable cause() {
return cause;
}
@Override
public boolean succeeded() {
return false;
}
@Override
public boolean failed() {
return true;
}
};
}
static CommandResponse success(R result) {
return success(result, null);
}
static CommandResponse success(R result, TxStatus txStatus) {
return new CommandResponse(txStatus) {
@Override
public R result() {
return result;
}
@Override
public Throwable cause() {
return null;
}
@Override
public boolean succeeded() {
return true;
}
@Override
public boolean failed() {
return false;
}
};
}
private final TxStatus txStatus;
public CommandResponse(TxStatus txStatus) {
this.txStatus = txStatus;
}
TxStatus txStatus() {
return txStatus;
}
}