List of usage examples for java.util Comparator compare
int compare(T o1, T o2);
From source file:at.gridtec.lambda4j.operator.binary.ShortBinaryOperator.java
/** * Returns a {@link ShortBinaryOperator} which returns the lesser of two elements according to the specified {@code * Comparator}./* w ww . java2s .c om*/ * * @param comparator A {@code Comparator} for comparing the two values * @return A {@code ShortBinaryOperator} which returns the lesser of its operands, according to the supplied {@code * Comparator}. * @throws NullPointerException If given argument is {@code null} * @see BinaryOperator#minBy(Comparator) */ @Nonnull static ShortBinaryOperator minBy(@Nonnull final Comparator<Short> comparator) { Objects.requireNonNull(comparator); return (value1, value2) -> comparator.compare(value1, value2) <= 0 ? value1 : value2; }
From source file:at.gridtec.lambda4j.operator.binary.ShortBinaryOperator.java
/** * Returns a {@link ShortBinaryOperator} which returns the greater of two elements according to the specified {@code * Comparator}.//from ww w . j a va 2 s . co m * * @param comparator A {@code Comparator} for comparing the two values * @return A {@code ShortBinaryOperator} which returns the greater of its operands, according to the supplied {@code * Comparator}. * @throws NullPointerException If given argument is {@code null} * @see BinaryOperator#maxBy(Comparator) */ @Nonnull static ShortBinaryOperator maxBy(@Nonnull final Comparator<Short> comparator) { Objects.requireNonNull(comparator); return (value1, value2) -> comparator.compare(value1, value2) >= 0 ? value1 : value2; }
From source file:at.gridtec.lambda4j.operator.binary.LongBinaryOperator2.java
/** * Returns a {@link LongBinaryOperator2} which returns the lesser of two elements according to the specified {@code * Comparator}./* w w w. ja v a 2 s .c om*/ * * @param comparator A {@code Comparator} for comparing the two values * @return A {@code LongBinaryOperator2} which returns the lesser of its operands, according to the supplied {@code * Comparator}. * @throws NullPointerException If given argument is {@code null} * @see BinaryOperator#minBy(Comparator) */ @Nonnull static LongBinaryOperator2 minBy(@Nonnull final Comparator<Long> comparator) { Objects.requireNonNull(comparator); return (value1, value2) -> comparator.compare(value1, value2) <= 0 ? value1 : value2; }
From source file:at.gridtec.lambda4j.operator.binary.LongBinaryOperator2.java
/** * Returns a {@link LongBinaryOperator2} which returns the greater of two elements according to the specified {@code * Comparator}./* w w w . ja va 2s .c om*/ * * @param comparator A {@code Comparator} for comparing the two values * @return A {@code LongBinaryOperator2} which returns the greater of its operands, according to the supplied {@code * Comparator}. * @throws NullPointerException If given argument is {@code null} * @see BinaryOperator#maxBy(Comparator) */ @Nonnull static LongBinaryOperator2 maxBy(@Nonnull final Comparator<Long> comparator) { Objects.requireNonNull(comparator); return (value1, value2) -> comparator.compare(value1, value2) >= 0 ? value1 : value2; }
From source file:at.gridtec.lambda4j.operator.binary.BooleanBinaryOperator.java
/** * Returns a {@link BooleanBinaryOperator} which returns the lesser of two elements according to the specified * {@code Comparator}.//from w w w. j a v a 2 s . co m * * @param comparator A {@code Comparator} for comparing the two values * @return A {@code BooleanBinaryOperator} which returns the lesser of its operands, according to the supplied * {@code Comparator}. * @throws NullPointerException If given argument is {@code null} * @see BinaryOperator#minBy(Comparator) */ @Nonnull static BooleanBinaryOperator minBy(@Nonnull final Comparator<Boolean> comparator) { Objects.requireNonNull(comparator); return (value1, value2) -> comparator.compare(value1, value2) <= 0 ? value1 : value2; }
From source file:at.gridtec.lambda4j.operator.binary.BooleanBinaryOperator.java
/** * Returns a {@link BooleanBinaryOperator} which returns the greater of two elements according to the specified * {@code Comparator}.// w w w.jav a 2 s .com * * @param comparator A {@code Comparator} for comparing the two values * @return A {@code BooleanBinaryOperator} which returns the greater of its operands, according to the supplied * {@code Comparator}. * @throws NullPointerException If given argument is {@code null} * @see BinaryOperator#maxBy(Comparator) */ @Nonnull static BooleanBinaryOperator maxBy(@Nonnull final Comparator<Boolean> comparator) { Objects.requireNonNull(comparator); return (value1, value2) -> comparator.compare(value1, value2) >= 0 ? value1 : value2; }
From source file:at.gridtec.lambda4j.operator.binary.CharBinaryOperator.java
/** * Returns a {@link CharBinaryOperator} which returns the lesser of two elements according to the specified {@code * Comparator}./*from ww w .j a va2 s .c om*/ * * @param comparator A {@code Comparator} for comparing the two values * @return A {@code CharBinaryOperator} which returns the lesser of its operands, according to the supplied {@code * Comparator}. * @throws NullPointerException If given argument is {@code null} * @see BinaryOperator#minBy(Comparator) */ @Nonnull static CharBinaryOperator minBy(@Nonnull final Comparator<Character> comparator) { Objects.requireNonNull(comparator); return (value1, value2) -> comparator.compare(value1, value2) <= 0 ? value1 : value2; }
From source file:at.gridtec.lambda4j.operator.binary.CharBinaryOperator.java
/** * Returns a {@link CharBinaryOperator} which returns the greater of two elements according to the specified {@code * Comparator}./* ww w.ja v a 2 s.c o m*/ * * @param comparator A {@code Comparator} for comparing the two values * @return A {@code CharBinaryOperator} which returns the greater of its operands, according to the supplied {@code * Comparator}. * @throws NullPointerException If given argument is {@code null} * @see BinaryOperator#maxBy(Comparator) */ @Nonnull static CharBinaryOperator maxBy(@Nonnull final Comparator<Character> comparator) { Objects.requireNonNull(comparator); return (value1, value2) -> comparator.compare(value1, value2) >= 0 ? value1 : value2; }
From source file:at.gridtec.lambda4j.operator.binary.DoubleBinaryOperator2.java
/** * Returns a {@link DoubleBinaryOperator2} which returns the lesser of two elements according to the specified * {@code Comparator}./*from w w w .j a v a2 s. co m*/ * * @param comparator A {@code Comparator} for comparing the two values * @return A {@code DoubleBinaryOperator2} which returns the lesser of its operands, according to the supplied * {@code Comparator}. * @throws NullPointerException If given argument is {@code null} * @see BinaryOperator#minBy(Comparator) */ @Nonnull static DoubleBinaryOperator2 minBy(@Nonnull final Comparator<Double> comparator) { Objects.requireNonNull(comparator); return (value1, value2) -> comparator.compare(value1, value2) <= 0 ? value1 : value2; }
From source file:at.gridtec.lambda4j.operator.binary.DoubleBinaryOperator2.java
/** * Returns a {@link DoubleBinaryOperator2} which returns the greater of two elements according to the specified * {@code Comparator}.//from w ww . jav a 2s .co m * * @param comparator A {@code Comparator} for comparing the two values * @return A {@code DoubleBinaryOperator2} which returns the greater of its operands, according to the supplied * {@code Comparator}. * @throws NullPointerException If given argument is {@code null} * @see BinaryOperator#maxBy(Comparator) */ @Nonnull static DoubleBinaryOperator2 maxBy(@Nonnull final Comparator<Double> comparator) { Objects.requireNonNull(comparator); return (value1, value2) -> comparator.compare(value1, value2) >= 0 ? value1 : value2; }