com.mercadopago.exceptions.MPValidationException Maven / Gradle / Ivy
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();
}
}