com.google.sitebricks.conversion.ValidationConverter Maven / Gradle / Ivy
The newest version!
package com.google.sitebricks.conversion;
import java.util.List;
import java.util.Set;
import javax.inject.Singleton;
import javax.validation.ConstraintViolation;
import com.google.common.collect.Lists;
@Singleton
public class ValidationConverter extends ConverterAdaptor>, List> {
@Override
public List to(Set extends ConstraintViolation>> source) {
List errors = Lists.newArrayList();
if (source != null) {
for (ConstraintViolation> cv: source) {
errors.add(cv.getMessage());
}
}
return errors;
}
}