spring-framework / org.springframework.util.comparator / NullSafeComparator / <init>

<init>

NullSafeComparator(comparator: Comparator<T>, nullsLow: Boolean)

Create a NullSafeComparator that sorts null based on the provided flag, decorating the given Comparator.

When comparing two non-null objects, the specified Comparator will be used. The given underlying Comparator must be able to handle the elements that this Comparator will be applied to.

Parameters

comparator - the comparator to use when comparing two non-null objects

nullsLow - whether to treat nulls lower or higher than non-null objects