Skip to content

Commit

Permalink
Add BinaryOperator to elidedTypesAndStaticImports
Browse files Browse the repository at this point in the history
  • Loading branch information
nadirbelarouci committed Sep 29, 2022
1 parent e3c784c commit b367315
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ T after(T value1, T value2, Comparator<T> cmp) {
}

/**
* Prefer {@link Comparators#min(Comparable, Comparable)} over {@link BinaryOperator#minBy(Comparator)}for natural ordering.
* Prefer {@link Comparators#min(Comparable, Comparable)} over {@link
* BinaryOperator#minBy(Comparator)}for natural ordering.
*/
static final class BinaryOperatorMinByNaturalOrder<T extends Comparable<? super T>> {
@BeforeTemplate
Expand All @@ -278,7 +279,8 @@ BiFunction<T, T, T> after() {
}

/**
* Prefer {@link Comparators#max(Comparable, Comparable)} over {@link BinaryOperator#maxBy(Comparator)}for natural ordering.
* Prefer {@link Comparators#max(Comparable, Comparable)} over {@link
* BinaryOperator#maxBy(Comparator)}for natural ordering.
*/
static final class BinaryOperatorMaxByNaturalOrder<T extends Comparable<? super T>> {
@BeforeTemplate
Expand All @@ -291,5 +293,4 @@ BiFunction<T, T, T> after() {
return Comparators::max;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ final class ComparatorTemplatesTest implements RefasterTemplateTestCase {
@Override
public ImmutableSet<?> elidedTypesAndStaticImports() {
return ImmutableSet.of(
Arrays.class, Collections.class, ImmutableList.class, ImmutableSet.class, identity());
Arrays.class,
BinaryOperator.class,
Collections.class,
ImmutableList.class,
ImmutableSet.class,
identity());
}

ImmutableSet<Comparator<String>> testNaturalOrder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.function.BiFunction;
import java.util.function.BinaryOperator;
import tech.picnic.errorprone.refaster.test.RefasterTemplateTestCase;

final class ComparatorTemplatesTest implements RefasterTemplateTestCase {
@Override
public ImmutableSet<?> elidedTypesAndStaticImports() {
return ImmutableSet.of(
Arrays.class, Collections.class, ImmutableList.class, ImmutableSet.class, identity());
Arrays.class,
BinaryOperator.class,
Collections.class,
ImmutableList.class,
ImmutableSet.class,
identity());
}

ImmutableSet<Comparator<String>> testNaturalOrder() {
Expand Down

0 comments on commit b367315

Please sign in to comment.