|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.deltava.comparators.AbstractComparator<T>
public abstract class AbstractComparator<T>
Implements common comparator functions. NOTE: Most comparators in this package impose orderings that are inconsistent with equals.
| Field Summary | |
|---|---|
protected int |
_comparisonType
The criteria by which to compare objects. |
protected boolean |
_reverseSort
Are we doing a reverse sort? |
protected String[] |
_typeNames
Text descriptions of the different comparison types. |
| Constructor Summary | |
|---|---|
protected |
AbstractComparator(String[] typeNames)
Create a new comparator with a given set of type names. |
| Method Summary | |
|---|---|
int |
compare(T o1,
T o2)
Return the result by interrogating the implementation and applying a reverse sort if requred. |
protected abstract int |
compareImpl(T o1,
T o2)
This method does the actual comparison. |
int |
getComparisonType()
Return the comparison type. |
String[] |
getTypeNames()
Return the list of comparison type names. |
boolean |
isReverseSort()
Return if we are performing a reverse sort. |
void |
setComparisonType(int type)
Sets the comparison type. |
void |
setComparisonType(String type)
Sets the comparison type. |
void |
setReverseSort(boolean rSort)
Updates the reverse sort parameter to sort in descending order. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
|---|
equals |
| Field Detail |
|---|
protected boolean _reverseSort
protected int _comparisonType
protected String[] _typeNames
| Constructor Detail |
|---|
protected AbstractComparator(String[] typeNames)
typeNames - An array of type names
NullPointerException - if typeNames is null| Method Detail |
|---|
protected abstract int compareImpl(T o1,
T o2)
o1 - The first object to compareo2 - The second object to compare
ClassCastException - if the object types are not supported by this implementationcompare(Object, Object),
Comparator.compare(java.lang.Object, java.lang.Object)public void setComparisonType(int type)
type - The comparison type.
IllegalArgumentException - if the type is negative or > typeNames.lengthgetComparisonType()public void setComparisonType(String type)
type - The comparison type, contained within _typeNames
IllegalArgumentException - if the type is not found in _typeNamesgetTypeNames()public String[] getTypeNames()
public boolean isReverseSort()
setReverseSort(boolean)public int getComparisonType()
setComparisonType(int),
setComparisonType(String)public final void setReverseSort(boolean rSort)
rSort - TRUE if sorting in descending order, otherwise FALSEisReverseSort()
public final int compare(T o1,
T o2)
compare in interface Comparator<T>o1 - The first object to compareo2 - The second object to compare
ClassCastException - if the object types are not supported by this implementationcompareImpl(Object, Object),
Comparator.compare(java.lang.Object, java.lang.Object)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||