foundry.classutils
Class FieldComparator
java.lang.Object
|
+--foundry.classutils.FieldComparator
- All Implemented Interfaces:
- Comparator
- final class FieldComparator
- extends Object
- implements Comparator
A Comparator
that sorts Field
s lexicographically,
based solely on their declaring class' name and their name.
- Version:
- $Revision: 1.3 $
- Author:
- Laird Nelson
- See Also:
Field.getDeclaringClass()
,
Field.getName()
,
Comparator
Constructor Summary |
(package private) |
FieldComparator()
Constructs a new FieldComparator . |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
FieldComparator
FieldComparator()
- Constructs a new
FieldComparator
.
compare
public int compare(Object o1,
Object o2)
throws ClassCastException
- Compares two
Object
s for equality, but only when both
Object
s are in fact Field
s. Each Field
's
getDeclaringClass()
and getName()
methods are called, and their String
representations concatenated. The resulting String
s are compared to each other using the String.compareTo(java.lang.String)
method, and its result is
returned.
- Specified by:
compare
in interface Comparator
- Parameters:
o1
- the first Field
o2
- the second Field
- Returns:
-1
if o1
< o2
,
0
if o1
== o2
or
1
if o1
> o2
- Throws:
ClassCastException
- if either o1
or
o2
is not an instance of Field
Copyright © 2000 - Laird Jarrett Nelson