Class Frequency.NaturalComparator<T extends java.lang.Comparable<T>>

  • Type Parameters:
    T - the type of the objects compared
    All Implemented Interfaces:
    java.io.Serializable, java.util.Comparator<java.lang.Comparable<T>>
    Enclosing class:
    Frequency

    private static class Frequency.NaturalComparator<T extends java.lang.Comparable<T>>
    extends java.lang.Object
    implements java.util.Comparator<java.lang.Comparable<T>>, java.io.Serializable
    A Comparator that compares comparable objects using the natural order. Copied from Commons Collections ComparableComparator.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static long serialVersionUID
      Serializable version identifier
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private NaturalComparator()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(java.lang.Comparable<T> o1, java.lang.Comparable<T> o2)
      Compare the two Comparable arguments.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Serializable version identifier
        See Also:
        Constant Field Values
    • Constructor Detail

      • NaturalComparator

        private NaturalComparator()
    • Method Detail

      • compare

        public int compare​(java.lang.Comparable<T> o1,
                           java.lang.Comparable<T> o2)
        Compare the two Comparable arguments. This method is equivalent to:
        ((Comparable)o1).compareTo(o2)
        Specified by:
        compare in interface java.util.Comparator<T extends java.lang.Comparable<T>>
        Parameters:
        o1 - the first object
        o2 - the second object
        Returns:
        result of comparison
        Throws:
        java.lang.NullPointerException - when o1 is null, or when ((Comparable)o1).compareTo(o2) does
        java.lang.ClassCastException - when o1 is not a Comparable, or when ((Comparable)o1).compareTo(o2) does