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

com.nike.backstopper.service.NoOpJsr303Validator Maven / Gradle / Ivy

There is a newer version: 2.0.1
Show newest version
package com.nike.backstopper.service;

import java.util.Set;

import javax.validation.ConstraintViolation;
import javax.validation.ValidationException;
import javax.validation.Validator;
import javax.validation.metadata.BeanDescriptor;

import static java.util.Collections.emptySet;

/**
 * Simple no-op implementation of the JSR 303 Bean Validation {@link Validator} - useful for satisfying dependency
 * injection requirements in cases where you won't actually use the JSR 303 {@link Validator} for any real work
 * and don't want your project to pull in a dependency on a real JSR 303 implementation.
 *
 * @author Nic Munroe
 */
@SuppressWarnings("WeakerAccess")
public class NoOpJsr303Validator implements Validator {

    public static final NoOpJsr303Validator SINGLETON_IMPL = new NoOpJsr303Validator();

    @Override
    public  Set> validate(T object, Class... groups) {
        return emptySet();
    }

    @Override
    public  Set> validateProperty(T object, String propertyName, Class... groups) {
        return emptySet();
    }

    @Override
    public  Set> validateValue(Class beanType, String propertyName, Object value,
                                                         Class... groups) {
        return emptySet();
    }

    @Override
    public BeanDescriptor getConstraintsForClass(Class clazz) {
        throw new ValidationException(this.getClass().getName() + " does not implement getConstraintsForClass()");
    }

    @Override
    public  T unwrap(Class type) {
        throw new ValidationException(this.getClass().getName() + " does not implement unwrap()");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy