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

org.s1.web.formats.BeanValidationException Maven / Gradle / Ivy

There is a newer version: 0.1.3
Show newest version
package org.s1.web.formats;

import javax.validation.ConstraintViolation;
import java.util.Set;

/**
 * @author Grigory Pykhov
 */
public class BeanValidationException extends Exception {

    private Set> violations;

    /**
     *
     * @param violations ConstraintViolations
     */
    public BeanValidationException(Set> violations) {
        super(getMessage(violations));
        this.violations = violations;
    }

    /**
     *
     * @return ConstraintViolations
     */
    public Set> getViolations() {
        return violations;
    }

    private static String getMessage(Set> violations){
        String message = "";
        message+="Got "+violations.size()+" violations:\n";
        int i=1;
        for(ConstraintViolation violation:violations){
            message+=(i++)+") "+violation.getPropertyPath()+" ["+violation.getInvalidValue()+"]: "+violation.getMessage()+"\n";
        }
        return message;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy