umontreal.iro.lecuyer.xmlconfig
Class ParamReader.MethodComparator
java.lang.Object
umontreal.iro.lecuyer.xmlconfig.ParamReader.MethodComparator
- All Implemented Interfaces:
- Comparator<Method>
- Enclosing class:
- ParamReader
public static class ParamReader.MethodComparator
- extends Object
- implements Comparator<Method>
Comparator for sorting the methods returned by
Introspection.getMethods(java.lang.Class>)
. For more consistent searching of
overloaded methods, the ParamReader.processElement(org.w3c.dom.Element, umontreal.iro.lecuyer.xmlconfig.Param)
method sorts the methods
returned by Introspection.getMethods(java.lang.Class>)
. Methods with different
names are sorted in alphabetical order. If two or more methods have the
same name, they are sorted from the greatest to the smallest visibility:
public, protected, package-private, and private. If two methods share the
same name and visibility, they are sorted from the greatest to the
smallest number of arguments.
When methods with the same name, visibility, and same number of arguments
must be compared, the comparator applies a test to each argument, until
the methods can be ordered. First, argument 0 is compared with other
methods' argument 0. If the arguments are equal, or cannot be ordered, the
test is performed with argument 1, 2, etc., until the arguments can be
ordered. If all the arguments are equal or cannot be ordered, the methods
cannot be ordered and are declared equal by the comparator. In this case,
the final order of the methods depends on the Virtual Machine being used.
Table 4:
Score
assigned to classes when comparing arguments
|
Arguments are compared based on their types only. To compare data types,
the comparator assigns a score to each one and orders the type with the
smallest score first. For array types, the score of the component type is
multipled by two. If types have the same score, they are equal or cannot
be ordered by this algorithm. Table 4 gives the score
assigned to each class.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ParamReader.MethodComparator
public ParamReader.MethodComparator()
compare
public int compare(Method m1,
Method m2)
- Specified by:
compare
in interface Comparator<Method>
To submit a bug or ask questions, send an e-mail to
Richard Simard.