|
Groovy Documentation | |||||||
| FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.wordpress.tipsforjava.util.BeanComparator
public class BeanComparator extends Object
A comparator to sort on the specified field of a given class. Reflection is used to retrieve the data to be sorted, therefore you must provide the Class and the method name within the class that will be used to retrieve the data. Several sort properties can be set: a) ascending (default true) b) ignore case (default true) c) nulls last (default true)
| Field Summary | |
|---|---|
private static Class[] |
EMPTY_CLASS_ARRAY
|
private static Object[] |
EMPTY_OBJECT_ARRAY
|
private boolean |
isAscending
|
private boolean |
isIgnoreCase
|
private boolean |
isNullsLast
|
private Method |
method
|
| Constructor Summary | |
BeanComparator(Class beanClass, String methodName)
|
|
BeanComparator(Class beanClass, String methodName, boolean isAscending)
|
|
BeanComparator(Class beanClass, String methodName, boolean isAscending, boolean isIgnoreCase)
|
|
| Method Summary | |
|---|---|
int
|
compare(Object object1, Object object2)
|
void
|
setAscending(boolean isAscending)
|
void
|
setIgnoreCase(boolean isIgnoreCase)
|
void
|
setNullsLast(boolean isNullsLast)
|
| Methods inherited from class Object | |
|---|---|
| wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
| Field Detail |
|---|
private static final Class[] EMPTY_CLASS_ARRAY
private static final Object[] EMPTY_OBJECT_ARRAY
private boolean isAscending
private boolean isIgnoreCase
private boolean isNullsLast
private Method method
| Constructor Detail |
|---|
BeanComparator(Class beanClass, String methodName)
BeanComparator(Class beanClass, String methodName, boolean isAscending)
BeanComparator(Class beanClass, String methodName, boolean isAscending, boolean isIgnoreCase)
| Method Detail |
|---|
ssWarnings("unchecked")
public
public int compare(Object object1, Object object2)
public void setAscending(boolean isAscending)
public void setIgnoreCase(boolean isIgnoreCase)
public void setNullsLast(boolean isNullsLast)
Groovy Documentation