1 package com.github.mygreen.supercsv.cellprocessor.conversion;
2
3 import org.supercsv.cellprocessor.CellProcessorAdaptor;
4 import org.supercsv.cellprocessor.ift.StringCellProcessor;
5 import org.supercsv.util.CsvContext;
6
7
8
9
10
11
12
13
14 public class DefaultValue extends CellProcessorAdaptor implements StringCellProcessor {
15
16 private final String returnValue;
17
18 public DefaultValue(final String returnValue) {
19 super();
20 this.returnValue = returnValue;
21 }
22
23 public DefaultValue(final String returnValue, final StringCellProcessor next) {
24 super(next);
25 this.returnValue = returnValue;
26 }
27
28 @Override
29 public <T> T execute(final Object value, final CsvContext context) {
30
31 if(value == null) {
32 return next.execute(returnValue, context);
33 }
34
35 return next.execute(value, context);
36 }
37
38
39
40
41
42 public String getReturnValue() {
43 return returnValue;
44 }
45
46 }