Class OptionalComparator<V>

  • All Implemented Interfaces:
    java.util.Comparator<Optional<? extends V>>

    public final class OptionalComparator<V>
    extends java.lang.Object
    implements java.util.Comparator<Optional<? extends V>>
    A Comparator for Optional values.

    Absent values are always "smaller" than present values. Decorate this with GreaterAbsent to reverse this behavior.

    • Constructor Summary

      Constructors 
      Constructor Description
      OptionalComparator​(java.util.Comparator<? super V> delegate)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(Optional<? extends V> o1, Optional<? extends V> o2)  
      • 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
    • Constructor Detail

      • OptionalComparator

        public OptionalComparator​(java.util.Comparator<? super V> delegate)
    • Method Detail

      • compare

        public int compare​(Optional<? extends V> o1,
                           Optional<? extends V> o2)
        Specified by:
        compare in interface java.util.Comparator<V>