1 package com.github.mygreen.supercsv.builder;
2
3 import java.util.Optional;
4
5 import org.supercsv.cellprocessor.ift.CellProcessor;
6
7 import com.github.mygreen.supercsv.cellprocessor.format.TextFormatter;
8
9
10
11
12
13
14
15
16 public class ColumnMapping implements Comparable<ColumnMapping> {
17
18 private FieldAccessor field;
19
20 private String label;
21
22 private int number;
23
24
25
26
27 private boolean partialized;
28
29
30
31
32 private Optional<FixedSizeColumnProperty> fixedSizeProperty = Optional.empty();
33
34 private CellProcessor cellProcessorForReading;
35
36 private CellProcessor cellProcessorForWriting;
37
38 private TextFormatter<?> formatter;
39
40
41
42
43
44 @Override
45 public int compareTo(final ColumnMapping o) {
46
47 if(this.number == o.number) {
48 return this.field.getName().compareTo(o.field.getName());
49
50 } else {
51 return Integer.compare(number, o.number);
52 }
53
54 }
55
56
57
58
59
60
61 public boolean isDeterminedNumber() {
62 return number >= 1;
63 }
64
65
66
67
68
69
70 public String getName() {
71 return field != null ? field.getName() : null;
72 }
73
74
75
76
77
78 public FieldAccessor getField() {
79 return field;
80 }
81
82 public void setField(FieldAccessor field) {
83 this.field = field;
84 }
85
86
87
88
89
90 public String getLabel() {
91 return label;
92 }
93
94
95
96
97
98 public void setLabel(String label) {
99 this.label = label;
100 }
101
102
103
104
105
106 public int getNumber() {
107 return number;
108 }
109
110
111
112
113
114 public void setNumber(int number) {
115 this.number = number;
116 }
117
118
119
120
121
122 public boolean isPartialized() {
123 return partialized;
124 }
125
126
127
128
129
130 public void setPartialized(boolean partialized) {
131 this.partialized = partialized;
132 }
133
134
135
136
137
138
139 public FixedSizeColumnProperty getFixedSizeProperty() {
140 return fixedSizeProperty.orElse(null);
141 }
142
143
144
145
146
147
148 public void setFixedSizeProperty(FixedSizeColumnProperty fixedSizeProperty) {
149 this.fixedSizeProperty = Optional.of(fixedSizeProperty);
150 }
151
152
153
154
155
156 public CellProcessor getCellProcessorForReading() {
157 return cellProcessorForReading;
158 }
159
160
161
162
163
164 public void setCellProcessorForReading(CellProcessor cellProcessorForReading) {
165 this.cellProcessorForReading = cellProcessorForReading;
166 }
167
168
169
170
171
172 public CellProcessor getCellProcessorForWriting() {
173 return cellProcessorForWriting;
174 }
175
176
177
178
179
180 public void setCellProcessorForWriting(CellProcessor cellProcessorForWriting) {
181 this.cellProcessorForWriting = cellProcessorForWriting;
182 }
183
184
185
186
187
188 public TextFormatter<?> getFormatter() {
189 return formatter;
190 }
191
192 public void setFormatter(TextFormatter<?> formatter) {
193 this.formatter = formatter;
194 }
195
196
197 }