public class GeneralComparator extends Object implements Comparator, Serializable
| 限定符和类型 | 类和说明 |
|---|---|
class |
GeneralComparator.XMLConstants |
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
ASC
Use to indicate that a field should be sorted in ascending order.
|
int |
count |
static String |
DESC
Use to indicate that a field should be sorted in descending order.
|
| 构造器和说明 |
|---|
GeneralComparator(Class c) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addField(Getter field,
String type) |
void |
addField(String field,
String type)
Add a field that we sort on, if you readd the same field then the type is
just updated.
|
void |
addFieldAfter(String field,
String type,
String ref)
Add a new field in AFTER the named field, if we don't have the named field
then we just call
addField(String,String) which will add the field
in after all the others. |
void |
addFieldAtIndex(String field,
String type,
int index) |
void |
addFieldBefore(String field,
String type,
String ref)
Add a new field in BEFORE the named field, if we don't have the named field
then we just call
addField(String,String) which will add the field
in after all the others. |
int |
compare(Object obj1,
Object obj2) |
boolean |
equals(Object obj) |
Class |
getCompareClass() |
int |
getCount() |
protected List |
getFields()
Return a List of GeneralComparator.SortField objects, this is used in the
equals(Object) method. |
void |
removeField(String field)
Remove a field that we sort on.
|
public int count
public static final String ASC
public GeneralComparator(Class c)
public Class getCompareClass()
public void addField(Getter field, String type) throws IllegalArgumentException
public void addFieldAtIndex(String field, String type, int index) throws IllegalArgumentException
public void addFieldBefore(String field, String type, String ref) throws IllegalArgumentException
addField(String,String) which will add the field
in after all the others.field - The field to add.type - Sort either ascending or descending, should be either
GeneralComparator.ASC or GeneralComparator.DESC.ref - The reference field.IllegalArgumentException - If we can't find the field in the
class/class chain passed into the
constructor.public void addFieldAfter(String field, String type, String ref) throws IllegalArgumentException
addField(String,String) which will add the field
in after all the others.field - The field to add.type - Sort either ascending or descending, should be either
GeneralComparator.ASC or GeneralComparator.DESC.ref - The reference field.IllegalArgumentException - If we can't find the field in the
class/class chain passed into the
constructor.public void removeField(String field)
field - The field to remove.public void addField(String field, String type) throws IllegalArgumentException
field - The field to sort on.type - The type either GeneralComparator.ASC or GeneralComparator.DESC.IllegalArgumentException - If we can't find the field in the
class/class chain passed into the
constructor.public int compare(Object obj1, Object obj2)
compare 在接口中 Comparatorpublic boolean equals(Object obj)
equals 在接口中 Comparatorequals 在类中 Objectprotected List getFields()
equals(Object) method.public int getCount()
Copyright © 2021. All rights reserved.