Interface SerializableComparator<T>

Type Parameters:
T - the type of objects that may be compared by this comparator
All Superinterfaces:
Comparator<T>, Serializable
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface SerializableComparator<T> extends Comparator<T>, Serializable
A 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.

Since:
1.0
Author:
Vaadin Ltd