All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.stargate.sgv2.api.common.config.SerialConsistencyValidator Maven / Gradle / Ivy

There is a newer version: 2.1.0-BETA-19
Show newest version
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