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

io.envoyproxy.pgv.ValidatorIndex Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package io.envoyproxy.pgv;

/**
 * {@code ValidatorIndex} defines the entry point for finding {@link Validator} instances for a given type.
 */
@FunctionalInterface
public interface ValidatorIndex {
    /**
     * Returns the validator for {@code clazz}, or {@code ALWAYS_VALID} if not found.
     */
     Validator validatorFor(Class clazz);

    /**
     * Returns the validator for {@code }, or {@code ALWAYS_VALID} if not found.
     */
    @SuppressWarnings("unchecked")
    default  Validator validatorFor(Object instance) {
        return validatorFor(instance == null ? null : instance.getClass());
    }

    ValidatorIndex ALWAYS_VALID = new ValidatorIndex() {
        @Override
        @SuppressWarnings("unchecked")
        public  Validator validatorFor(Class clazz) {
            return Validator.ALWAYS_VALID;
        }
    };

    ValidatorIndex ALWAYS_INVALID = new ValidatorIndex() {
        @Override
        @SuppressWarnings("unchecked")
        public  Validator validatorFor(Class clazz) {
            return Validator.ALWAYS_INVALID;
        }
    };
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy