Class ParseEnum
java.lang.Object
org.supercsv.cellprocessor.CellProcessorAdaptor
org.supercsv.cellprocessor.ParseEnum
- All Implemented Interfaces:
CellProcessor, StringCellProcessor
Converts a String to an Enum. Patch originally supplied by Adrian Ber.
- Since:
- 2.2.0
- Author:
- James Bassett
-
Field Summary
Fields inherited from class CellProcessorAdaptor
next -
Constructor Summary
ConstructorsModifierConstructorDescription<T extends Enum<?>>Constructs a new ParseEnum processor, which converts a String to a Enum.<T extends Enum<?>>Constructs a new ParseEnum processor, which converts a String to a Enum, ignoring the case of the input (or not) depending on the supplied flag.<T extends Enum<?>>ParseEnum(Class<T> enumClass, boolean ignoreCase, CellProcessor next) Constructs a new ParseEnum processor, which converts a String to a Enum, ignoring the case of the input (or not) depending on the supplied flag, then calls the next processor in the chain.<T extends Enum<?>>ParseEnum(Class<T> enumClass, CellProcessor next) Constructs a new ParseEnum processor, which converts a String to a Enum then calls the next processor in the chain. -
Method Summary
Modifier and TypeMethodDescriptionexecute(Object value, CsvContext context) This method is invoked by the framework when the processor needs to process data or check constraints.Methods inherited from class CellProcessorAdaptor
toString, validateInputNotNull
-
Constructor Details
-
ParseEnum
Constructs a new ParseEnum processor, which converts a String to a Enum.- Type Parameters:
T- the Enum type- Parameters:
enumClass- the enum class to convert to- Throws:
NullPointerException- if enumClass is null
-
ParseEnum
Constructs a new ParseEnum processor, which converts a String to a Enum, ignoring the case of the input (or not) depending on the supplied flag.- Type Parameters:
T- the Enum type- Parameters:
enumClass- the enum class to convert toignoreCase- whether to ignore the case of the input- Throws:
NullPointerException- if enumClass is null
-
ParseEnum
Constructs a new ParseEnum processor, which converts a String to a Enum then calls the next processor in the chain.- Type Parameters:
T- the Enum type- Parameters:
enumClass- the enum class to convert tonext- the next processor in the chain- Throws:
NullPointerException- if enumClass or next is null
-
ParseEnum
Constructs a new ParseEnum processor, which converts a String to a Enum, ignoring the case of the input (or not) depending on the supplied flag, then calls the next processor in the chain.- Type Parameters:
T- the Enum type- Parameters:
enumClass- the enum class to convert toignoreCase- whether to ignore the case of the inputnext- the next processor in the chain- Throws:
NullPointerException- if enumClass or next is null
-
-
Method Details
-
execute
This method is invoked by the framework when the processor needs to process data or check constraints.- Specified by:
executein interfaceCellProcessor- Parameters:
value- the value to be processedcontext- the CSV context- Returns:
- the result of cell processor execution
- Throws:
SuperCsvCellProcessorException- if value is null or can't be parsed as an Enum
-