Interface IOComparator<T>

  • Type Parameters:
    T - the type of objects that may be compared by this comparator
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface IOComparator<T>
    Like Comparator but throws IOException.
    Since:
    2.12.0
    See Also:
    Comparator
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default java.util.Comparator<T> asComparator()
      Creates a Comparator for this instance that throws UncheckedIOException instead of IOException.
      int compare​(T o1, T o2)
      Like Comparator.compare(Object, Object) but throws IOException.
    • Method Detail

      • asComparator

        default java.util.Comparator<T> asComparator()
        Creates a Comparator for this instance that throws UncheckedIOException instead of IOException.
        Returns:
        an UncheckedIOException BiFunction.
      • compare

        int compare​(T o1,
                    T o2)
             throws java.io.IOException
        Like Comparator.compare(Object, Object) but throws IOException.
        Parameters:
        o1 - the first object to be compared.
        o2 - 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.
        Throws:
        java.lang.NullPointerException - if an argument is null and this comparator does not permit null arguments
        java.lang.ClassCastException - if the arguments' types prevent them from being compared by this comparator.
        java.io.IOException - if an I/O error occurs.