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

com.instaclustr.cassandra.sidecar.operations.rebuild.ValidRebuildOperationRequest Maven / Gradle / Ivy

There is a newer version: 2.0.0-alpha8
Show newest version
package com.instaclustr.cassandra.sidecar.operations.rebuild;


import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import javax.validation.Payload;

import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Target({TYPE, PARAMETER})
@Retention(RUNTIME)
@Constraint(validatedBy = {
        ValidRebuildOperationRequest.RebuildOperationRequestValidator.class,
})
public @interface ValidRebuildOperationRequest {

    String message() default "{com.instaclustr.cassandra.sidecar.operations.rebuild.ValidRebuildOperationRequest.message}";

    Class[] groups() default {};

    Class[] payload() default {};

    final class RebuildOperationRequestValidator implements ConstraintValidator {
        @Override
        public boolean isValid(RebuildOperationRequest value, ConstraintValidatorContext context) {

            context.disableDefaultConstraintViolation();

            if (value.keyspace == null && value.specificTokens != null && !value.specificTokens.isEmpty()) {
                context
                        .buildConstraintViolationWithTemplate("{com.instaclustr.cassandra.sidecar.operations.rebuild.ValidRebuildOperationRequest.keyspaceMissingForSpecificTokens}")
                        .addConstraintViolation();

                return false;
            }

            return true;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy