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.

  • Field Details

    • uniqueSet

      private final Set<Integer> uniqueSet
  • Constructor Details

    • 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:
      NullPointerException - if next is null
  • Method Details