Lines Matching defs:Comparator

38  * as {@link Collections#sort(List,Comparator) Collections.sort} or {@link
39 * Arrays#sort(Object[],Comparator) Arrays.sort}) to allow precise control
109 public interface Comparator<T> {
184 default Comparator<T> reversed() {
190 * If this {@code Comparator} considers two elements equal, i.e.
202 * Comparator<String> cmp = Comparator.comparingInt(String::length)
213 default Comparator<T> thenComparing(Comparator<? super T> other) {
215 return (Comparator<T> & Serializable) (c1, c2) -> {
223 * extracts a key to be compared with the given {@code Comparator}.
230 * @param keyComparator the {@code Comparator} used to compare the sort key
234 * @see #comparing(Function, Comparator)
235 * @see #thenComparing(Comparator)
238 default <U> Comparator<T> thenComparing(
240 Comparator<? super U> keyComparator)
259 * @see #thenComparing(Comparator)
262 default <U extends Comparable<? super U>> Comparator<T> thenComparing(
280 * @see #thenComparing(Comparator)
283 default Comparator<T> thenComparingInt(ToIntFunction<? super T> keyExtractor) {
299 * @see #thenComparing(Comparator)
302 default Comparator<T> thenComparingLong(ToLongFunction<? super T> keyExtractor) {
318 * @see #thenComparing(Comparator)
321 default Comparator<T> thenComparingDouble(ToDoubleFunction<? super T> keyExtractor) {
338 public static <T extends Comparable<? super T>> Comparator<T> reverseOrder() {
356 public static <T extends Comparable<? super T>> Comparator<T> naturalOrder() {
357 return (Comparator<T>) Comparators.NaturalOrderComparator.INSTANCE;
363 * equal. If both are non-null, the specified {@code Comparator} is used
371 * @param comparator a {@code Comparator} for comparing non-null values
374 * {@code Comparator}.
377 public static <T> Comparator<T> nullsFirst(Comparator<? super T> comparator) {
384 * equal. If both are non-null, the specified {@code Comparator} is used
392 * @param comparator a {@code Comparator} for comparing non-null values
395 * {@code Comparator}.
398 public static <T> Comparator<T> nullsLast(Comparator<? super T> comparator) {
404 * returns a {@code Comparator<T>} that compares by that sort key using
405 * the specified {@link Comparator}.
411 * For example, to obtain a {@code Comparator} that compares {@code
415 * Comparator<Person> cmp = Comparator.comparing(
423 * @param keyComparator the {@code Comparator} used to compare the sort key
425 * specified {@code Comparator}
429 public static <T, U> Comparator<T> comparing(
431 Comparator<? super U> keyComparator)
435 return (Comparator<T> & Serializable)
443 * Comparator<T>} that compares by that sort key.
449 * For example, to obtain a {@code Comparator} that compares {@code
453 * Comparator<Person> byLastName = Comparator.comparing(Person::getLastName);
464 public static <T, U extends Comparable<? super U>> Comparator<T> comparing(
468 return (Comparator<T> & Serializable)
474 * {@code T}, and returns a {@code Comparator<T>} that compares by that
487 public static <T> Comparator<T> comparingInt(ToIntFunction<? super T> keyExtractor) {
489 return (Comparator<T> & Serializable)
495 * {@code T}, and returns a {@code Comparator<T>} that compares by that
508 public static <T> Comparator<T> comparingLong(ToLongFunction<? super T> keyExtractor) {
510 return (Comparator<T> & Serializable)
516 * {@code T}, and returns a {@code Comparator<T>} that compares by that
529 public static<T> Comparator<T> comparingDouble(ToDoubleFunction<? super T> keyExtractor) {
531 return (Comparator<T> & Serializable)