Package org.assertj.core.internal
Class TypeHolder<T>
java.lang.Object
org.assertj.core.internal.TypeHolder<T>
- Type Parameters:
T- entity type
- Direct Known Subclasses:
TypeComparators,TypeMessages
An abstract type holder which provides to pair a specific entities for types.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all registered entities.Returns a sequence of all type-entity pairs which the current holder supplies.booleanprivate static <T> StringformatRegisteredEntity(Map.Entry<Class<?>, T> entry) This method returns the most relevant entity for the given class.private Class<?> getRelevantClass(Class<?> cls) Returns the most relevant class for the given type from the giving collection of types.booleanChecks, whether an entity is associated with the giving type.inthashCode()booleanisEmpty()voidPuts theentityfor the givenclazz.toString()
-
Field Details
-
DEFAULT_CLASS_COMPARATOR
-
typeHolder
-
-
Constructor Details
-
TypeHolder
public TypeHolder() -
TypeHolder
-
-
Method Details
-
get
This method returns the most relevant entity for the given class. The most relevant entity is the entity 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 entity forclazzthen this one is used 2. We check if there is a registered entity for a superclass ofclazz3. We check if there is a registered entity for an interface ofclazz- Parameters:
clazz- the class for which to find a entity- Returns:
- the most relevant entity, or
nullif on entity could be found
-
put
Puts theentityfor the givenclazz.- Parameters:
clazz- the class for the comparatorentity- the entity itself
-
hasEntity
Checks, whether an entity is associated with the giving type.- Parameters:
type- the type for which to check an entity- Returns:
- is the giving type associated with any entity
-
isEmpty
public boolean isEmpty()- Returns:
trueis there are registered entities,falseotherwise
-
clear
public void clear()Removes all registered entities. -
entityByTypes
Returns a sequence of all type-entity pairs which the current holder supplies.- Returns:
- sequence of field-entity pairs
-
getRelevantClass
Returns the most relevant class for the given type from the giving collection of types.The order of checks is the following:
- If there is a registered message for
clazzthen this one is used - We check if there is a registered message for a superclass of
clazz - We check if there is a registered message for an interface of
clazz
nullwill be returned.- Parameters:
cls- type to find a relevant class.- Returns:
- the most relevant class.
- If there is a registered message for
-
equals
-
hashCode
public int hashCode() -
toString
-
formatRegisteredEntity
-