net.sf.adatagenerator.util
Class DefaultNullComparator

java.lang.Object
  extended by net.sf.adatagenerator.util.DefaultNullComparator
Type Parameters:
V - A class that implements Comparable
All Implemented Interfaces:
Comparator

public class DefaultNullComparator
extends Object
implements Comparator

Compares two Comparable objects.

This is a fly-weight class with no instance data.

Author:
rphall

Constructor Summary
DefaultNullComparator()
           
 
Method Summary
 int compare(Object o1, Object o2)
          Compares two objects.
static int compareComparables(Object o1, Object o2)
          A static comparison method that compares two comparable objects and deals with null values.
static Comparator<?> getComparator()
           
 
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

DefaultNullComparator

public DefaultNullComparator()
Method Detail

getComparator

public static Comparator<?> getComparator()

compare

public int compare(Object o1,
                   Object o2)
            throws ClassCastException
Compares two objects.

Specified by:
compare in interface Comparator
Throws:
ClassCastException
See Also:
#compareComparables(Comparable, Comparable)

compareComparables

public static int compareComparables(Object o1,
                                     Object o2)
A static comparison method that compares two comparable objects and deals with null values. This method won't bind to generics.

Type Parameters:
G - a comparable type
Throws:
ClassCastException - if the objects aren't comparable


Copyright © 2011-2012. All Rights Reserved.