tech.ytsaurus.client.request.MutateNode Maven / Gradle / Ivy
The newest version!
package tech.ytsaurus.client.request;
import java.util.Optional;
import tech.ytsaurus.core.GUID;
import tech.ytsaurus.ysontree.YTreeBuilder;
public abstract class MutateNode,
TRequest extends MutateNode> extends TransactionalRequest {
protected MutatingOptions mutatingOptions;
MutateNode(Builder, ?> builder) {
super(builder);
this.mutatingOptions = new MutatingOptions(builder.mutatingOptions);
}
public Optional getMutatingOptions() {
return Optional.of(mutatingOptions);
}
@Override
protected YTreeBuilder toTree(YTreeBuilder builder) {
if (prerequisiteOptions != null) {
builder = builder.apply(prerequisiteOptions::toTree);
}
return super.toTree(builder);
}
public abstract static class Builder<
TBuilder extends Builder,
TRequest extends MutateNode, TRequest>>
extends TransactionalRequest.Builder {
protected MutatingOptions mutatingOptions = new MutatingOptions().setMutationId(GUID.create());
protected Builder() {
}
public Builder(Builder, ?> builder) {
super(builder);
this.mutatingOptions = new MutatingOptions(builder.mutatingOptions);
}
public TBuilder setMutatingOptions(MutatingOptions mutatingOptions) {
this.mutatingOptions = mutatingOptions;
return self();
}
public Optional getMutatingOptions() {
return Optional.of(mutatingOptions);
}
@Override
public YTreeBuilder toTree(YTreeBuilder builder) {
if (prerequisiteOptions != null) {
builder = builder.apply(prerequisiteOptions::toTree);
}
return super.toTree(builder);
}
}
}