Class UniqueHashCode
- java.lang.Object
-
- org.supercsv.cellprocessor.CellProcessorAdaptor
-
- org.supercsv.cellprocessor.constraint.UniqueHashCode
-
- All Implemented Interfaces:
CellProcessor
public class UniqueHashCode extends CellProcessorAdaptor
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.
- Author:
- Kasper B. Graversen, Dominique De Vito, James Bassett
-
-
Field Summary
-
Fields inherited from class org.supercsv.cellprocessor.CellProcessorAdaptor
next
-
-
Constructor Summary
Constructors Constructor Description UniqueHashCode()
Constructs 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
UniqueHashCode
public UniqueHashCode()
Constructs a new UniqueHashCode processor, which ensures that all rows in a column are unique.
-
UniqueHashCode
public 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.- Parameters:
next
- the next processor in the chain- Throws:
java.lang.NullPointerException
- if next is null
-
-
Method Detail
-
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.- 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
-
-