1 package com.github.mygreen.supercsv.validation;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import org.supercsv.cellprocessor.ift.CellProcessor;
7
8
9
10
11
12
13
14
15 public class CsvFieldError extends CsvError {
16
17
18 private static final long serialVersionUID = -7775352881004606689L;
19
20 private final boolean processingFailure;
21
22 private final String field;
23
24 public CsvFieldError(final String objectName, final String field, final boolean processingFailure,
25 final String[] codes, final Map<String, Object> variables, final String defaultMessage) {
26 super(objectName, codes, variables, defaultMessage);
27
28 this.processingFailure = processingFailure;
29 this.field = field;
30 }
31
32
33
34
35
36
37
38
39 public boolean isProcessingFailure() {
40 return processingFailure;
41 }
42
43
44
45
46
47 public String getField() {
48 return field;
49 }
50
51 public static final class Builder {
52
53 private final String objectName;
54
55 private final String field;
56
57 private final String[] codes;
58
59 private boolean processingFailure;
60
61 private Map<String, Object> variables = new HashMap<>();
62
63 private String defaultMessage;
64
65 public Builder(final String objectName, final String field, final String[] codes) {
66 this.objectName = objectName;
67 this.field = field;
68 this.codes = codes;
69 }
70
71 public Builder processingFailure(final boolean processingFailure) {
72 this.processingFailure = processingFailure;
73 return this;
74 }
75
76 public Builder variables(final Map<String, Object> variables) {
77 this.variables.putAll(variables);
78 return this;
79 }
80
81 public Builder variables(final String key, final Object value) {
82 this.variables.put(key, value);
83 return this;
84 }
85
86 public Builder defaultMessage(final String defaultMessage) {
87 this.defaultMessage = defaultMessage;
88 return this;
89 }
90
91 public CsvFieldError build() {
92
93 return new CsvFieldError(objectName, field, processingFailure, codes, variables, defaultMessage);
94 }
95
96 }
97
98 }