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

com.browserup.bup.rest.validation.mapper.model.ConstraintsErrors Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package com.browserup.bup.rest.validation.mapper.model;

import java.util.*;

public class ConstraintsErrors {
    private List errors = new ArrayList<>();

    public List getErrors() {
        return errors;
    }

    public void setErrors(List errors) {
        this.errors = errors;
    }

    private ArgumentConstraintsErrors getErrorsByArgumentName(String argumentName) {
        Optional argErrors = this.errors.stream()
                .filter(e -> e.getName().equals(argumentName))
                .findFirst();
        if (!argErrors.isPresent()) {
            ArgumentConstraintsErrors newArgErrors = new ArgumentConstraintsErrors();
            newArgErrors.setName(argumentName);
            errors.add(newArgErrors);
            return newArgErrors;
        } else {
            return argErrors.get();
        }
    }

    public void addError(String argumentName, String error) {
        getErrorsByArgumentName(argumentName).getErrors().add(error);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy