|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.util.MethodComparator<T>
T - DOCUMENT ME!public class MethodComparator<T>
compares objects by the return value of a specified method name. This Comparator uses reflection to access the return values of the methods to be compared.
| Constructor Summary | |
|---|---|
MethodComparator(java.lang.String methodName)
calls MethodComparator(methodName, true) |
|
MethodComparator(java.lang.String methodName,
boolean ascending)
the methodName (usually a 'getter'-method) must have no arguments for the objects to be compared. |
|
| Method Summary | |
|---|---|
int |
compare(T o1,
T o2)
if the object returned by the specified method of the first given object doesn't implement Comparable, the
toString() value of that object is used instead. |
java.lang.String |
getMethodName()
DOCUMENT ME! |
static java.lang.String[] |
getUsableMethodNames(java.lang.Class c,
boolean comparableReturnValuesOnly)
lists all method names of the given class that take no parameters and return something but void - and are therefore usable for a MethodComparator. |
boolean |
isAscending()
DOCUMENT ME! |
| 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 |
| Constructor Detail |
|---|
public MethodComparator(java.lang.String methodName)
MethodComparator(methodName, true)
public MethodComparator(java.lang.String methodName,
boolean ascending)
compareTo(Object) will be reversed.
| Method Detail |
|---|
public static java.lang.String[] getUsableMethodNames(java.lang.Class c,
boolean comparableReturnValuesOnly)
c - DOCUMENT ME!comparableReturnValuesOnly - DOCUMENT ME!
public java.lang.String getMethodName()
public boolean isAscending()
public int compare(T o1,
T o2)
throws java.lang.ClassCastException
Comparable, the
toString() value of that object is used instead. If a null
value is encountered, it is considered to come before any other value.
compare in interface java.util.Comparator<T>o1 - DOCUMENT ME!o2 - DOCUMENT ME!
java.lang.ClassCastException - if any of the following Exceptions occur:
InvocationTargetException, NoSuchMethodException,
NoSuchMethodException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||