org.droitateddb.validation.InvalidEntityException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api Show documentation
Show all versions of api Show documentation
droitatedDB is a lightweight framework, which frees you from the burden of dealing with Androids SQLite
database directly if you don't want to
and let's you access it directly if you have to.
The newest version!
package org.droitateddb.validation;
import java.util.List;
/**
* This exception is thrown when you try to save invalid entity
*
* @author Falk Appel
* @author Alexander Frank
*/
public class InvalidEntityException extends RuntimeException {
private List errors;
public InvalidEntityException(AccumulatedValidationResult errors) {
super(flatten(errors));
this.errors = errors.getErrors();
}
private static String flatten(AccumulatedValidationResult errors) {
if (errors == null) {
return "";
}
StringBuilder builder = new StringBuilder();
List validationResults = errors.getErrors();
for (int i = 0; i < validationResults.size(); i++) {
builder.append(validationResults.get(i));
if (i < validationResults.size() - 1) {
builder.append(" | ");
}
}
return builder.toString();
}
public List getErrors() {
return errors;
}
}