public class TypeComparators
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.Class<?>,java.util.Comparator<?>> |
typeComparators |
Constructor and Description |
---|
TypeComparators() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
java.util.Comparator<?> |
get(java.lang.Class<?> clazz)
This method returns the most relevant comparator for the given class.
|
int |
hashCode() |
boolean |
isEmpty() |
<T> void |
put(java.lang.Class<T> clazz,
java.util.Comparator<T> comparator)
Puts the
comparator for the given clazz . |
java.lang.String |
toString() |
private java.util.Map<java.lang.Class<?>,java.util.Comparator<?>> typeComparators
public java.util.Comparator<?> get(java.lang.Class<?> clazz)
clazz
.
The order of checks is the following:
1. If there is a registered comparator for clazz
then this one is used
2. We check if there is a registered comparator for all the superclasses of clazz
3. We check if there is a registered comparator for all the interfaces if clazz
clazz
- the class for which to find a comparatornull
if no comparator could be foundpublic <T> void put(java.lang.Class<T> clazz, java.util.Comparator<T> comparator)
comparator
for the given clazz
.T
- the type of the objects for the comparatorclazz
- the class for the comparatorcomparator
- the comparator it selfpublic boolean isEmpty()
true
is there are registered comparators, false
otherwisepublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object