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

io.rocketbase.commons.converter.ValidationConverter Maven / Gradle / Ivy

There is a newer version: 4.4.1
Show newest version
package io.rocketbase.commons.converter;

import io.rocketbase.commons.dto.validation.ValidationResponse;
import io.rocketbase.commons.exception.ValidationErrorCode;

import java.util.HashMap;
import java.util.Set;

public class ValidationConverter {

    public static > ValidationResponse convert(Set> errors) {
        ValidationResponse response = new ValidationResponse<>(errors != null && errors.isEmpty(), new HashMap<>());
        if (errors != null) {
            for (ValidationErrorCode c : errors) {
                response.getErrorCodes().put(c.getCode(), c.getMessage());
            }
        }
        return response;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy