io.stargate.sgv2.api.common.config.SerialConsistencyValidator Maven / Gradle / Ivy
package io.stargate.sgv2.api.common.config;
import io.stargate.bridge.proto.QueryOuterClass;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import java.util.Arrays;
/** Validator to check if the consistency provided is valid serial consistency */
public class SerialConsistencyValidator
implements ConstraintValidator {
private QueryOuterClass.Consistency[] validConsistencies;
@Override
public void initialize(SerialConsistencyValid constraint) {
this.validConsistencies = constraint.anyOf();
}
@Override
public boolean isValid(QueryOuterClass.Consistency value, ConstraintValidatorContext context) {
return value != null && Arrays.binarySearch(validConsistencies, value) >= 0;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy