tech.ydb.core.operation.FailedOperation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ydb-sdk-core Show documentation
Show all versions of ydb-sdk-core Show documentation
Core module of Java SDK for YDB
package tech.ydb.core.operation;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import tech.ydb.core.Result;
import tech.ydb.core.Status;
/**
*
* @author Aleksandr Gorshenin
*/
class FailedOperation implements Operation {
private final T value;
private final Status status;
FailedOperation(T value, Status status) {
this.value = value;
this.status = status;
}
@Override
public String getId() {
return null;
}
@Override
public boolean isReady() {
return true;
}
@Override
public T getValue() {
return value;
}
@Override
public CompletableFuture cancel() {
return CompletableFuture.completedFuture(status);
}
@Override
public CompletableFuture forget() {
return CompletableFuture.completedFuture(status);
}
@Override
public CompletableFuture> fetch() {
return CompletableFuture.completedFuture(Result.fail(status));
}
@Override
public Operation transform(Function func) {
return new FailedOperation<>(func.apply(value), status);
}
@Override
public String toString() {
return "FailedOperation{status=" + status + "}";
}
}