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 fromIsIncludedIn
as the Collection is modifiable, so it can be used with other processors such asCollector
to enforce referential integrity.- Since:
- 2.1.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Collection<java.lang.Object>
collection
-
Fields inherited from class org.supercsv.cellprocessor.CellProcessorAdaptor
next
-
-
Constructor Summary
Constructors Constructor Description IsElementOf(java.util.Collection<java.lang.Object> collection)
Constructs a new IsElementOf, which ensures that the input value is an element of a Collection.IsElementOf(java.util.Collection<java.lang.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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
checkPreconditions(java.util.Collection<java.lang.Object> collection)
Checks the preconditions for creating a new IsElementOf processor.java.lang.Object
execute(java.lang.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
-
-
-
-
Constructor Detail
-
IsElementOf
public IsElementOf(java.util.Collection<java.lang.Object> collection)
Constructs a new IsElementOf, which ensures that the input value is an element of a Collection.- Parameters:
collection
- the collection to check- Throws:
java.lang.NullPointerException
- if collection is null
-
IsElementOf
public IsElementOf(java.util.Collection<java.lang.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.- Parameters:
collection
- the collection to checknext
- the next processor in the chain- Throws:
java.lang.NullPointerException
- if collection or next is null
-
-
Method Detail
-
checkPreconditions
private static void checkPreconditions(java.util.Collection<java.lang.Object> collection)
Checks the preconditions for creating a new IsElementOf processor.- Parameters:
collection
- the collection to check- Throws:
java.lang.NullPointerException
- if collection is null
-
execute
public java.lang.Object execute(java.lang.Object value, CsvContext context)
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
-
-