|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.util.ReflectUtil.FieldComparator
public static class ReflectUtil.FieldComparator
Imposes an ordering on Fields that is consistent with equals; see compare
for details.
This class is multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields).
Field Summary | |
---|---|
private static ReflectUtil.FieldComparator |
instance
|
private static long |
serialVersionUID
|
Constructor Summary | |
---|---|
ReflectUtil.FieldComparator()
|
Method Summary | |
---|---|
int |
compare(Field f1,
Field f2)
Tries to order f1 and f2 by their names (case irrelevant): returns f1.getName().toLowerCase().compareTo( f2.getName().toLowerCase() ) if that result is ! |
static ReflectUtil.FieldComparator |
getInstance()
Since this class has no instance state, there is no point in creating multiple instances: one instance is the same as another, may be fully concurrently used, etc. |
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 |
---|
private static final ReflectUtil.FieldComparator instance
private static final long serialVersionUID
Constructor Detail |
---|
public ReflectUtil.FieldComparator()
Method Detail |
---|
public static ReflectUtil.FieldComparator getInstance()
public final int compare(Field f1, Field f2) throws IllegalArgumentException, IllegalStateException
Tries to order f1 and f2 by their names (case irrelevant):
returns f1.getName().toLowerCase().compareTo( f2.getName().toLowerCase() )
if that result is != 0.
Else tries to order f1 and f2 by their class names:
returns f1.getDeclaringClass().getName().compareTo( f2.getDeclaringClass().getName() )
if that result is != 0.
Else returns 0 if f1.
is true.
This is the only circumstance in which 0 will ever be returned, thus,
this Comparator is consistent with equals (see equals
(f2)Comparator
for more discussion).
Else throws an IllegalStateException.
compare
in interface Comparator<Field>
IllegalArgumentException
- if f1 or f2 is null
IllegalStateException
- if run out of criteria to order f1 and f2
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |