public class

InvertibleComparator

extends Object
implements Serializable Comparator<T>
java.lang.Object
   ↳ org.springframework.util.comparator.InvertibleComparator<T>

Class Overview

A decorator for a comparator, with an "ascending" flag denoting whether comparison results should be treated in forward (standard ascending) order or flipped for reverse (descending) order.

Summary

Public Constructors
InvertibleComparator(Comparator<T> comparator)
Create an InvertibleComparator that sorts ascending by default.
InvertibleComparator(Comparator<T> comparator, boolean ascending)
Create an InvertibleComparator that sorts based on the provided order.
Public Methods
int compare(T o1, T o2)
boolean equals(Object obj)
int hashCode()
void invertOrder()
Invert the sort order: ascending -> descending or descending -> ascending.
boolean isAscending()
Return the sort order: ascending (true) or descending (false).
void setAscending(boolean ascending)
Specify the sort order: ascending (true) or descending (false).
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.util.Comparator

Public Constructors

public InvertibleComparator (Comparator<T> comparator)

Also: SpringCore

Create an InvertibleComparator that sorts ascending by default. For the actual comparison, the specified Comparator will be used.

Parameters
comparator the comparator to decorate

public InvertibleComparator (Comparator<T> comparator, boolean ascending)

Also: SpringCore

Create an InvertibleComparator that sorts based on the provided order. For the actual comparison, the specified Comparator will be used.

Parameters
comparator the comparator to decorate
ascending the sort order: ascending (true) or descending (false)

Public Methods

public int compare (T o1, T o2)

Also: SpringCore

public boolean equals (Object obj)

public int hashCode ()

public void invertOrder ()

Also: SpringCore

Invert the sort order: ascending -> descending or descending -> ascending.

public boolean isAscending ()

Also: SpringCore

Return the sort order: ascending (true) or descending (false).

public void setAscending (boolean ascending)

Also: SpringCore

Specify the sort order: ascending (true) or descending (false).

public String toString ()