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
-
Field Summary
FieldsFields inherited from class org.supercsv.cellprocessor.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 TypeMethodDescriptionprivate static void
checkPreconditions
(Collection<Object> collection) Checks the preconditions for creating a new IsElementOf processor.execute
(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 org.supercsv.cellprocessor.CellProcessorAdaptor
toString, validateInputNotNull
-
Field Details
-
collection
-
-
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
-
checkPreconditions
Checks the preconditions for creating a new IsElementOf processor.- Parameters:
collection
- the collection to check- Throws:
NullPointerException
- if collection is null
-
execute
This method is invoked by the framework when the processor needs to process data or check constraints.- Specified by:
execute
in 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
-