T
- Scalar typepublic final class HighestOf<T extends Comparable<T>> extends Object implements Scalar<T>
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 UncheckedScalar
decorator. Or you may use
IoCheckedScalar
to wrap it in an IOException.
There is no thread-safety guarantee.
UncheckedScalar
,
IoCheckedScalar
@SafeVarargs public HighestOf(T... items)
items
- The comparable items@SafeVarargs public HighestOf(Scalar<T>... scalars)
scalars
- The scalarsCopyright © 2017–2019 Cactoos. All rights reserved.