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

com.mercadopago.exceptions.MPValidationException Maven / Gradle / Ivy

There is a newer version: 1.8.0
Show newest version
package com.mercadopago.exceptions;

import com.mercadopago.core.ValidationViolation;

import java.util.Collection;

/**
 * Mercado Pago SDK
 * MPValidationException class
 *
 * Created by Eduardo Paoletta on 11/22/16.
 */
public class MPValidationException extends MPException {

    private Collection colViolations = null;

    public MPValidationException(Collection colViolations) {
        super("");
        this.colViolations = colViolations;
    }

    public Collection getColViolations() {
        return colViolations;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        if (colViolations != null &&
                !colViolations.isEmpty()) {
            sb.append(colViolations.toArray()[0].toString());
            if (colViolations.size() > 1) {
                sb
                        .append(" And ")
                        .append(Integer.valueOf(colViolations.size() - 1).toString())
                        .append(" more.");
            }
        }
        return sb.toString();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy