Class RecordComparator

java.lang.Object
com.northconcepts.datapipeline.core.RecordComparator
All Implemented Interfaces:
Cloneable, Comparator<Record>

public class RecordComparator extends Object implements Comparator<Record>, Cloneable
Orders records by a list of fields, each ascending or descending with an optional Collator; when no fields are added, records are compared on all their fields by name.
  • Field Details

    • cacheFieldIndexes

      protected boolean cacheFieldIndexes
  • Constructor Details

    • RecordComparator

      public RecordComparator()
    • RecordComparator

      public RecordComparator(RecordComparator o)
      Creates a copy of the given comparator with its own copies of the field comparators.
  • Method Details

    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • add

      public RecordComparator add(String fieldName)
      Adds an ascending comparison on the given field name or FieldPath expression.
    • add

      public RecordComparator add(String fieldName, boolean ascending)
      Adds an ascending or descending comparison on the given field name or FieldPath expression.
    • add

      public RecordComparator add(String fieldName, boolean ascending, Collator collator)
      Adds a comparison on the given field name or FieldPath expression that uses the collator for string values.
    • getCount

      public int getCount()
      Returns the number of fields added for comparison.
    • get

      public FieldComparator get(int index)
      Returns the comparator for the field added at the given 0-based index.
    • remove

      public RecordComparator remove(int index)
    • removeAll

      public RecordComparator removeAll()
      Clears the field comparisons so records are compared on all their fields.
    • compare

      public int compare(Record record1, Record record2)
      Specified by:
      compare in interface Comparator<Record>