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: 0.6.13
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 {
    /**
     * Retuns the validator for {@code clazz}, or {@code ALWAYS_VALID} if not found.
     */
     Validator validatorFor(Class clazz);

    /**
     * Retuns 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;
        }
    };
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy