package org.kiwiproject.jaxrs.exception;
import static java.util.Objects.nonNull;
import static java.util.stream.Collectors.toList;
import static org.kiwiproject.base.KiwiPreconditions.checkArgumentNotNull;
import com.google.common.annotations.VisibleForTesting;
import javax.validation.ConstraintViolation;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Exception representing a 422 status code that extends {@link JaxrsException} to use Kiwi's {@link ErrorMessage}.
*/
public class JaxrsValidationException extends JaxrsException {
/**
* The status code for all instances of this exception.
*/
public static final int CODE = 422;
private static final String VALIDATION_FAILED_MESSAGE = "Validation failed";
/**
* New instance with given item ID and error messages.
*
* Each map contained in {@code errorMessageMaps} must have entries with at least two keys:
* {@link ErrorMessage#KEY_FIELD_NAME} and {@link ErrorMessage#KEY_MESSAGE}. In other words, the
* maps should contain an entry whose key is {@link ErrorMessage#KEY_FIELD_NAME} and another entry
* whose key is {@link ErrorMessage#KEY_MESSAGE}. Any other entries are ignored. The value of these
* two entries become the field name and message in the resulting {@link ErrorMessage} objects.
*
* @param itemId the unique ID of the item that caused this error
* @param errorMessageMaps a list containing maps containing
*/
public JaxrsValidationException(String itemId, List