Class IsElementOf
java.lang.Object
org.supercsv.cellprocessor.CellProcessorAdaptor
org.supercsv.cellprocessor.constraint.IsElementOf
- All Implemented Interfaces:
BoolCellProcessor, CellProcessor, DateCellProcessor, DoubleCellProcessor, LongCellProcessor, StringCellProcessor
public class IsElementOf
extends CellProcessorAdaptor
implements BoolCellProcessor, DateCellProcessor, DoubleCellProcessor, LongCellProcessor, StringCellProcessor
This processor ensures that the input value is an element of a Collection. It differs from
IsIncludedIn as
the Collection is modifiable, so it can be used with other processors such as
Collector to enforce referential integrity.- Since:
- 2.1.0
- Author:
- James Bassett
-
Field Summary
Fields inherited from class CellProcessorAdaptor
next -
Constructor Summary
ConstructorsConstructorDescriptionIsElementOf(Collection<Object> collection) Constructs a new IsElementOf, which ensures that the input value is an element of a Collection.IsElementOf(Collection<Object> collection, CellProcessor next) Constructs a new IsElementOf, which ensures that the input value is an element of a Collection, 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
-
IsElementOf
Constructs a new IsElementOf, which ensures that the input value is an element of a Collection.- Parameters:
collection- the collection to check- Throws:
NullPointerException- if collection is null
-
IsElementOf
Constructs a new IsElementOf, which ensures that the input value is an element of a Collection, then calls the next processor in the chain.- Parameters:
collection- the collection to checknext- the next processor in the chain- Throws:
NullPointerException- if collection 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:
SuperCsvConstraintViolationException- if value isn't in the Collection
-