net.sf.uadetector.internal.util
Class CompareNullSafe<T>
java.lang.Object
net.sf.uadetector.internal.util.CompareNullSafe<T>
- All Implemented Interfaces:
- java.io.Serializable, java.util.Comparator<T>
- Direct Known Subclasses:
- BrowserOperatingSystemMappingComparator, IdentifiableComparator, OrderedPatternComparator
public abstract class CompareNullSafe<T>
- extends java.lang.Object
- implements java.util.Comparator<T>, java.io.Serializable
Compares two references to each other and null is assumed to be less than a non-null value. This
class provides the first check for null safe comparison.
- Author:
- André Rouél
- See Also:
- Serialized Form
|
Method Summary |
int |
compare(T o1,
T o2)
Compares two objects null safe to each other. |
static int |
compareInt(int a,
int b)
Compares to integers. |
abstract int |
compareType(T o1,
T o2)
|
| 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 |
CompareNullSafe
public CompareNullSafe()
compareInt
public static int compareInt(int a,
int b)
- Compares to integers.
- Parameters:
a - first integerb - second integer
- Returns:
-1 if a is less, 0 if equal, or 1 if greater than b
compare
public int compare(T o1,
T o2)
- Compares two objects null safe to each other.
- Specified by:
compare in interface java.util.Comparator<T>
- Parameters:
o1 - the first referenceo2 - the second reference
- Returns:
- a negative value if o1 < o2, zero if o1 = o2 and a positive value if o1 > o2
compareType
public abstract int compareType(T o1,
T o2)
Copyright © 2011-2014. All Rights Reserved.