Class UniqueHashCode
java.lang.Object
org.supercsv.cellprocessor.CellProcessorAdaptor
org.supercsv.cellprocessor.constraint.UniqueHashCode
- All Implemented Interfaces:
CellProcessor
Ensure that upon processing a CSV file (reading or writing), that values of the column are all unique. Comparison is
based upon each elements hashCode() method and lookup takes O(1).
Compared to Unique
this processor is much more memory efficient as it only stores the set of encountered
hashcodes rather than storing references to all encountered objects. The tradeoff being possible false positives.
Prior to v1.50 this class was named Unique but has been renamed to clarify its inner workings.
-
Field Summary
FieldsFields inherited from class org.supercsv.cellprocessor.CellProcessorAdaptor
next
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new UniqueHashCode processor, which ensures that all rows in a column are unique.UniqueHashCode
(CellProcessor next) Constructs a new UniqueHashCode 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
-
uniqueSet
-
-
Constructor Details
-
UniqueHashCode
public UniqueHashCode()Constructs a new UniqueHashCode processor, which ensures that all rows in a column are unique. -
UniqueHashCode
Constructs a new UniqueHashCode 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
-