com.redis.lettucemod.timeseries.BaseCreateOptions Maven / Gradle / Ivy
package com.redis.lettucemod.timeseries;
import java.util.Optional;
import com.redis.lettucemod.protocol.TimeSeriesCommandKeyword;
import io.lettuce.core.protocol.CommandArgs;
public class BaseCreateOptions extends BaseOptions {
private final TimeSeriesCommandKeyword duplicatePolicyKeyword;
private Optional encoding = Optional.empty();
private Optional duplicatePolicy = Optional.empty();
public BaseCreateOptions(TimeSeriesCommandKeyword duplicatePolicyKeyword) {
this.duplicatePolicyKeyword = duplicatePolicyKeyword;
}
protected BaseCreateOptions(TimeSeriesCommandKeyword duplicatePolicyKeyword, Builder builder) {
super(builder);
this.duplicatePolicyKeyword = duplicatePolicyKeyword;
this.encoding = builder.encoding;
this.duplicatePolicy = builder.policy;
}
public Optional getEncoding() {
return encoding;
}
public void setEncoding(Optional encoding) {
this.encoding = encoding;
}
@SuppressWarnings("hiding")
@Override
public void build(CommandArgs args) {
duplicatePolicy.ifPresent(p -> args.add(duplicatePolicyKeyword).add(p.getKeyword()));
encoding.ifPresent(e -> args.add(TimeSeriesCommandKeyword.ENCODING).add(e.getKeyword()));
super.build(args);
}
@SuppressWarnings("unchecked")
public static class Builder> extends BaseOptions.Builder {
private Optional encoding = Optional.empty();
private Optional policy = Optional.empty();
public B encoding(Encoding encoding) {
this.encoding = Optional.of(encoding);
return (B) this;
}
public B policy(DuplicatePolicy policy) {
this.policy = Optional.of(policy);
return (B) this;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy