T
- the type of objects that may be compared by this comparator@FunctionalInterface public interface SerializableComparator<T> extends Comparator<T>, Serializable
Comparator
that is also Serializable
.
You can create a serializable comparator from a regular comparator through a
method reference by appending ::compare
. For example
SerializableComparator<Employee>
comparator = Comparator.comparing(Employee::getFirstName)::compare
.
The resulting comparator will in most cases cause exceptions if it is
actually being serialized, but this construct will enable using the
shorthands in Comparator
in applications where session will not be
serialized.
compare, comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
Copyright © 2020. All rights reserved.