Class Unique
java.lang.Object
org.supercsv.cellprocessor.CellProcessorAdaptor
org.supercsv.cellprocessor.constraint.Unique
- All Implemented Interfaces:
CellProcessor
Ensure that upon processing a CSV file (reading or writing), that values of the column all are unique. Comparison is
based upon each elements equals() method of the objects and lookup takes O(1).
Compared to UniqueHashCode
this processor potentially uses more memory, as it stores references to each
encountered object rather than just their hashcodes. On reading huge files this can be a real memory-hazard, however,
it ensures a true uniqueness check.
- Since:
- 1.50
-
Field Summary
FieldsFields inherited from class org.supercsv.cellprocessor.CellProcessorAdaptor
next
-
Constructor Summary
ConstructorsConstructorDescriptionUnique()
Constructs a new Unique processor, which ensures that all rows in a column are unique.Unique
(CellProcessor next) Constructs a new Unique processor, which ensures that all rows in a column are unique, 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 org.supercsv.cellprocessor.CellProcessorAdaptor
toString, validateInputNotNull
-
Field Details
-
encounteredElements
-
-
Constructor Details
-
Unique
public Unique()Constructs a new Unique processor, which ensures that all rows in a column are unique. -
Unique
Constructs a new Unique processor, which ensures that all rows in a column are unique, then calls the next processor in the chain.- Parameters:
next
- the next processor in the chain- Throws:
NullPointerException
- if next is null
-
-
Method Details
-
execute
This method is invoked by the framework when the processor needs to process data or check constraints.- Parameters:
value
- the value to be processedcontext
- the CSV context- Returns:
- the result of cell processor execution
- Throws:
SuperCsvCellProcessorException
- if value is nullSuperCsvConstraintViolationException
- if a non-unique value is encountered
-