Package org.assertj.core.internal
Class TypeComparators
- java.lang.Object
-
- org.assertj.core.internal.TypeComparators
-
public class TypeComparators extends java.lang.ObjectAn internal holder of the comparators for type. It is used to store comparators for registered classes. When looking for a Comparator for a given class the holder returns the most relevant comparator.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Class<?>,java.util.Comparator<?>>typeComparators
-
Constructor Summary
Constructors Constructor Description TypeComparators()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.util.Comparator<?>get(java.lang.Class<?> clazz)This method returns the most relevant comparator for the given class.inthashCode()booleanisEmpty()<T> voidput(java.lang.Class<T> clazz, java.util.Comparator<T> comparator)Puts thecomparatorfor the givenclazz.java.lang.StringtoString()
-
-
-
Method Detail
-
get
public java.util.Comparator<?> get(java.lang.Class<?> clazz)
This method returns the most relevant comparator for the given class. The most relevant comparator is the comparator which is registered for the class that is closest in the inheritance chain of the givenclazz. The order of checks is the following: 1. If there is a registered comparator forclazzthen this one is used 2. We check if there is a registered comparator for all the superclasses ofclazz3. We check if there is a registered comparator for all the interfaces ifclazz- Parameters:
clazz- the class for which to find a comparator- Returns:
- the most relevant comparator, or
nullif no comparator could be found
-
put
public <T> void put(java.lang.Class<T> clazz, java.util.Comparator<T> comparator)Puts thecomparatorfor the givenclazz.- Type Parameters:
T- the type of the objects for the comparator- Parameters:
clazz- the class for the comparatorcomparator- the comparator it self
-
isEmpty
public boolean isEmpty()
- Returns:
trueis there are registered comparators,falseotherwise
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-