T - the type of the element to be comparedpublic abstract static class Lang.Comparator<T> extends Lang.F2<T,T,Integer> implements Comparator<T>, Serializable
Adapt JDK Comparator (since 1.2) to Functional programming. The class provides several java8 Comparator methods
| Constructor and Description |
|---|
Comparator() |
| Modifier and Type | Method and Description |
|---|---|
Integer |
apply(T p1,
T p2)
Apply the two params to the function
|
Lang.Comparator<T> |
reversed()
See Java 8 doc
|
Lang.Comparator<T> |
thenComparing(Comparator<? super T> other)
See Java 8 doc
|
<U extends Comparable<? super U>> |
thenComparing(Lang.Function<? super T,? extends U> keyExtractor)
See Java 8 doc
|
<U extends Comparable<? super U>> |
thenComparing(Lang.Function<? super T,? extends U> keyExtractor,
Comparator<? super U> keyComparator)
See Java 8 doc
|
andThen, andThen, applyOrElse, curry, curry, lift, orElsebreakOutclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompare, comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reverseOrder, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic Integer apply(T p1, T p2) throws NotAppliedException, Lang.Break
Lang.Func2Apply the two params to the function
In case implementing a partial function, it can throw out an NotAppliedException if the function is not defined for the given parameter(s)
apply in interface Lang.Func2<T,T,Integer>p1 - the first argument of type P1p2 - the second argument of type P2NotAppliedException - if the function doesn’t apply to the parameter(s)Lang.Break - to short cut collecting operations (fold/reduce) on an containerpublic Lang.Comparator<T> reversed()
See Java 8 doc
reversed in interface Comparator<T>public Lang.Comparator<T> thenComparing(Comparator<? super T> other)
See Java 8 doc
thenComparing in interface Comparator<T>public <U extends Comparable<? super U>> Lang.Comparator<T> thenComparing(Lang.Function<? super T,? extends U> keyExtractor, Comparator<? super U> keyComparator)
See Java 8 doc
U - the generic type of the keykeyExtractor - The function to extract the key for comparisonkeyComparator - The function to compare the extracted keyU from element of type T and run keyComparator to compare the two keyspublic <U extends Comparable<? super U>> Lang.Comparator<T> thenComparing(Lang.Function<? super T,? extends U> keyExtractor)
See Java 8 doc
U - the key typekeyExtractor - the function that extract key of type U from instance of type TCopyright © 2014–2021 OSGL (Open Source General Library). All rights reserved.