Class ValuedComparator<V extends Comparable<V>>

Type Parameters:
V - The type of value contained in the valued objects
All Implemented Interfaces:
SortOrderComparator<Valued<V>>, Comparator<Valued<V>>

public class ValuedComparator<V extends Comparable<V>> extends AbstractSortOrderComparator<Valued<V>>
Comparator that sorts two Valued objects by their comparable values.

This comparator supports null values.

Author:
Garret Wilson
  • Constructor Details

    • ValuedComparator

      public ValuedComparator(SortOrder sortOrder)
      Sort order constructor.
      Parameters:
      sortOrder - The order in which to perform comparisons.
      Throws:
      NullPointerException - if the given sort order is null.
  • Method Details

    • compareImpl

      protected int compareImpl(Valued<V> object1, Valued<V> object2)
      Implementation to compare two objects for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. Implementations do not need to perform special checks for identity, as the AbstractSortOrderComparator.compare(Object, Object) implementation will do this.
      Specified by:
      compareImpl in class AbstractSortOrderComparator<Valued<V extends Comparable<V>>>
      Parameters:
      object1 - The first object to be compared.
      object2 - The second object to be compared.
      Returns:
      A negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
      See Also: