Package org.assertj.core.internal
Class TypeMessages
java.lang.Object
org.assertj.core.internal.TypeMessages
An internal holder of the custom message for type. It is used to store messages for registered classes.
When looking for a message for a given class the holder returns the most relevant comparator.
-
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.booleanThis method returns the most relevant entity for the given class.getMessageForType(Class<?> clazz) This method returns the most relevant error message for the given class.booleanChecks, whether an entity is associated with the giving type.inthashCode()booleanhasMessageForType(Class<?> type) Checks, whether an any custom error message is associated with the giving type.booleanisEmpty()Returns a sequence of all type-message pairs which the current holder supplies.voidPuts theentityfor the givenclazz.<T> voidregisterMessage(Class<T> clazz, String message) Puts themessagefor the givenclazz.toString()
-
Field Details
-
typeHolder
-
-
Constructor Details
-
TypeMessages
public TypeMessages()
-
-
Method Details
-
getMessageForType
This method returns the most relevant error message for the given class. The most relevant message is the message 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 message forclazzthen this one is used 2. We check if there is a registered message for a superclass ofclazz3. We check if there is a registered message for an interface ofclazz- Parameters:
clazz- the class for which to find an error message- Returns:
- the most relevant error message, or
nullif no message could be found
-
hasMessageForType
Checks, whether an any custom error message is associated with the giving type.- Parameters:
type- the type for which to check a error message- Returns:
- is the giving type associated with any custom error message
-
registerMessage
Puts themessagefor the givenclazz.- Type Parameters:
T- the type of the objects to associate with the message for- Parameters:
clazz- the class for the error messagemessage- the error message itself
-
messageByTypes
Returns a sequence of all type-message pairs which the current holder supplies.- Returns:
- sequence of field-message pairs
-
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
-
equals
-
hashCode
public int hashCode() -
toString
-