public class TypeMessages extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Map<Class<?>,T> |
typeHolder |
| Constructor and Description |
|---|
TypeMessages() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all registered entities.
|
Stream<Map.Entry<Class<?>,T>> |
entityByTypes()
Returns a sequence of all type-entity pairs which the current holder supplies.
|
boolean |
equals(Object o) |
T |
get(Class<?> clazz)
This method returns the most relevant entity for the given class.
|
String |
getMessageForType(Class<?> clazz)
This method returns the most relevant error message for the given class.
|
boolean |
hasEntity(Class<?> type)
Checks, whether an entity is associated with the giving type.
|
int |
hashCode() |
boolean |
hasMessageForType(Class<?> type)
Checks, whether an any custom error message is associated with the giving type.
|
boolean |
isEmpty() |
Stream<Map.Entry<Class<?>,String>> |
messageByTypes()
Returns a sequence of all type-message pairs which the current holder supplies.
|
void |
put(Class<?> clazz,
T entity)
Puts the
entity for the given clazz. |
<T> void |
registerMessage(Class<T> clazz,
String message)
Puts the
message for the given clazz. |
String |
toString() |
public String getMessageForType(Class<?> clazz)
clazz.
The order of checks is the following:
1. If there is a registered message for clazz then this one is used
2. We check if there is a registered message for a superclass of clazz
3. We check if there is a registered message for an interface of clazzclazz - the class for which to find an error messagenull if no message could be foundpublic boolean hasMessageForType(Class<?> type)
type - the type for which to check a error messagepublic <T> void registerMessage(Class<T> clazz, String message)
message for the given clazz.T - the type of the objects to associate with the message forclazz - the class for the error messagemessage - the error message itselfpublic Stream<Map.Entry<Class<?>,String>> messageByTypes()
public T get(Class<?> clazz)
clazz.
The order of checks is the following:
1. If there is a registered entity for clazz then this one is used
2. We check if there is a registered entity for a superclass of clazz
3. We check if there is a registered entity for an interface of clazzclazz - the class for which to find a entitynull if on entity could be foundpublic void put(Class<?> clazz, T entity)
entity for the given clazz.clazz - the class for the comparatorentity - the entity itselfpublic boolean hasEntity(Class<?> type)
type - the type for which to check an entitypublic boolean isEmpty()
true is there are registered entities, false otherwisepublic void clear()
public Stream<Map.Entry<Class<?>,T>> entityByTypes()
Copyright © 2025. All rights reserved.