java.lang.Object
org.supercsv.cellprocessor.CellProcessorAdaptor
org.supercsv.cellprocessor.constraint.Unique
All Implemented Interfaces:
CellProcessor

public class Unique extends CellProcessorAdaptor
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 Details

    • encounteredElements

      private final Set<Object> encounteredElements
  • Constructor Details

    • Unique

      public Unique()
      Constructs a new Unique processor, which ensures that all rows in a column are unique.
    • Unique

      public 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.
      Parameters:
      next - the next processor in the chain
      Throws:
      NullPointerException - if next is null
  • Method Details