Class ComparableComparator<T>

Type Parameters:
T - the type, must extend Comparable
All Implemented Interfaces:
Serializable, Comparator<Comparable<T>>, SchemaObject

public class ComparableComparator<T> extends LdapComparator<Comparable<T>>
Compares two objects taking into account that one might be a Comparable.
Author:
Apache Directory Project
See Also:
  • Constructor Details

    • ComparableComparator

      public ComparableComparator(String oid)
      The ComparableComparator constructor.
      Parameters:
      oid - the comparator OID
  • Method Details

    • compare

      public int compare(Comparable<T> o1, Comparable<T> o2)
      Compares two objects taking into account that one may be a Comparable. If the first is a comparable then its compareTo operation is called and the result returned as is. If the first is not a Comparable but the second is then its compareTo method is called and the result is returned after being negated. If none are comparable the hashCode of o1 minus the hashCode of o2 is returned.
      Parameters:
      o1 - the first comparable
      o2 - the second comparable
      Returns: