Package org.assertj.core.internal
Class TypeComparators
java.lang.Object
org.assertj.core.internal.TypeComparators
An 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
FieldsModifier and TypeFieldDescriptionprivate static final Comparator<Class<?>>private static final DoubleComparatorprivate static final FloatComparatorprivate static final doubleprivate static final float(package private) Map<Class<?>,Comparator<?>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all registered comparators.Stream<Map.Entry<Class<?>,Comparator<?>>> static TypeComparatorsbooleanprivate static StringformatRegisteredComparator(Map.Entry<Class<?>, Comparator<?>> next) Comparator<?>This method returns the most relevant comparator for the given class.booleanhasComparatorForType(Class<?> type) inthashCode()booleanisEmpty()<T> voidput(Class<T> clazz, Comparator<? super T> comparator) Puts thecomparatorfor the givenclazz.toString()
-
Field Details
-
DOUBLE_COMPARATOR_PRECISION
private static final double DOUBLE_COMPARATOR_PRECISION- See Also:
-
DEFAULT_DOUBLE_COMPARATOR
-
FLOAT_COMPARATOR_PRECISION
private static final float FLOAT_COMPARATOR_PRECISION- See Also:
-
DEFAULT_FLOAT_COMPARATOR
-
CLASS_COMPARATOR
-
typeComparators
Map<Class<?>,Comparator<?>> typeComparators
-
-
Constructor Details
-
TypeComparators
public TypeComparators()
-
-
Method Details
-
defaultTypeComparators
-
get
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 a superclass ofclazz3. We check if there is a registered comparator for an interface ofclazz- Parameters:
clazz- the class for which to find a comparator- Returns:
- the most relevant comparator, or
nullif no comparator could be found
-
hasComparatorForType
-
put
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
-
clear
public void clear()Removes all registered comparators. -
comparatorByTypes
-
hashCode
public int hashCode() -
equals
-
toString
-
formatRegisteredComparator
-