1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.supercsv.benchmark.cellprocessor;
17
18 import org.supercsv.benchmark.model.StopType;
19 import org.supercsv.cellprocessor.CellProcessorAdaptor;
20 import org.supercsv.cellprocessor.ift.CellProcessor;
21 import org.supercsv.exception.SuperCsvCellProcessorException;
22 import org.supercsv.util.CsvContext;
23
24
25
26
27
28
29 public class ParseStopType extends CellProcessorAdaptor {
30
31
32
33
34 public ParseStopType() {
35 super();
36 }
37
38
39
40
41 public ParseStopType(CellProcessor next) {
42 super(next);
43 }
44
45
46
47
48 public Object execute(Object value, CsvContext context) {
49
50 validateInputNotNull(value, context);
51
52 for( StopType stopType : StopType.values() ) {
53 if( stopType.name().equals(value.toString()) ) {
54 return next.execute(stopType, context);
55 }
56 }
57
58 throw new SuperCsvCellProcessorException(String.format("Unknown StopType: %s", value), context, this);
59 }
60
61 }