Sha256: b8bdeb49c1ba034086ab5c488d1f9dda11bf762134a7ad51442d7dfe041aa691

Contents?: true

Size: 1.06 KB

Versions: 101

Compression:

Stored size: 1.06 KB

Contents

package org.embulk.config;

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

public class TaskValidationException
        extends RuntimeException
{
    @SuppressWarnings("unchecked")
    private final Set violations;

    public <T> TaskValidationException(Set<ConstraintViolation<T>> violations)
    {
        super(formatMessage(violations));
        this.violations = violations;
    }

    @SuppressWarnings("unchecked")
    public Set<ConstraintViolation<?>> getViolations()
    {
        return violations;
    }

    private static <T> String formatMessage(Set<ConstraintViolation<T>> violations)
    {
        StringBuilder sb = new StringBuilder();
        sb.append("Configuration task validation failed.");
        for(ConstraintViolation<T> violation : violations) {
            sb.append(" ");
            sb.append(violation.getPropertyPath());
            sb.append(" ");
            sb.append(violation.getMessage());
            sb.append(" but got ");
            sb.append(violation.getInvalidValue());
        }
        return sb.toString();
    }
}

Version data entries

101 entries across 101 versions & 1 rubygems

Version Path
embulk-0.4.0 embulk-core/src/main/java/org/embulk/config/TaskValidationException.java