foundry-0.9.1

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 Fields 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.
 
Method Summary
 int compare(Object o1, Object o2)
          Compares two Objects for equality, but only when both Objects are in fact Fields.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

FieldComparator

FieldComparator()
Constructs a new FieldComparator.
Method Detail

compare

public int compare(Object o1,
                   Object o2)
            throws ClassCastException
Compares two Objects for equality, but only when both Objects are in fact Fields. Each Field's getDeclaringClass() and getName() methods are called, and their String representations concatenated. The resulting Strings 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

foundry-0.9.1

Copyright © 2000 - Laird Jarrett Nelson