ValidationResults.java 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package com.boman.system.common;
  2. import org.slf4j.Logger;
  3. import org.slf4j.LoggerFactory;
  4. import java.util.ArrayList;
  5. import java.util.Collection;
  6. /**
  7. * @author shiqian
  8. * @description
  9. * @date 2021年03月22日 10:50
  10. **/
  11. public class ValidationResults {
  12. private static final Logger log = LoggerFactory.getLogger(ValidationResults.class);
  13. private static ValidationResults okResult = new ValidationResults();
  14. private Collection<String> errors = new ArrayList();
  15. public ValidationResults() {
  16. }
  17. public static ValidationResults ok() {
  18. return okResult;
  19. }
  20. public boolean isOk() {
  21. return this.errors == null || this.errors.size() <= 0;
  22. }
  23. // public RowResult toRowResult(MainTableRecord row) {
  24. // return RowResult.error(String.join("\r\n", this.errors));
  25. // }
  26. // public void addError(Exception e) {
  27. // String message = getMessage(e);
  28. // this.errors.add(message);
  29. // }
  30. // private static String getMessage(Exception ex) {
  31. // String message = ex.getMessage();
  32. // if (!(ex instanceof NDSException)) {
  33. // StringWriter sw = new StringWriter();
  34. // PrintWriter pw = new PrintWriter(sw);
  35. // ex.printStackTrace(pw);
  36. // message = sw.toString().replace("\n", "<br/>").replace("\tat", "");
  37. // }
  38. //
  39. // return message;
  40. // }
  41. public Collection<String> getErrors() {
  42. return this.errors;
  43. }
  44. }