Class HighestOf<T extends Comparable<? super T>>

  • Type Parameters:
    T - Scalar type
    All Implemented Interfaces:
    Scalar<T>

    public final class HighestOf<T extends Comparable<? super T>>
    extends ScalarEnvelope<T>
    Find the highest item.

    Here is how you can use it to find highest of Comparable items:

     final String highest = new HighestOf<String>(
             () -> "Banana", () -> "Apple", () -> "Orange"
         ).value();
     // -> highest == "Orange"
    
     final Character highestChar = new HighestOf<>('B', 'U', 'G').value();
     // -> highestChar == 'U'
     

    This class implements Scalar, which throws a checked Exception. This may not be convenient in many cases. To make it more convenient and get rid of the checked exception you can use the Unchecked decorator. Or you may use IoChecked to wrap it in an IOException.

    There is no thread-safety guarantee.

    Since:
    0.29
    See Also:
    Unchecked, IoChecked
    • Constructor Detail

      • HighestOf

        @SafeVarargs
        public HighestOf​(T... items)
        Ctor.
        Parameters:
        items - The comparable items
      • HighestOf

        @SafeVarargs
        public HighestOf​(Scalar<? extends T>... scalars)
        Ctor.
        Parameters:
        scalars - The scalars
      • HighestOf

        public HighestOf​(Iterable<? extends Scalar<? extends T>> iterable)
        Ctor.
        Parameters:
        iterable - The items