Package de.chkal.mvctoolbox.core.message
Class MvcMessage
java.lang.Object
de.chkal.mvctoolbox.core.message.MvcMessage
- All Implemented Interfaces:
Serializable
Represents a single message which is meant to be displayed to the user. Every message consists
of a human readable text and a severity. Optionally a message can be associated with a parameter.
This is typically useful for validation errors which always relate to a specific parameter. If
the message is not associated with a parameter, the message is called a global message.
- Author:
- Christian Kaltepoth
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionMvcMessage(MvcMessage.Severity severity, String text) Creates a new global message with the given severity.MvcMessage(MvcMessage.Severity severity, String param, String text) Creates a new message referring to the given parameter.MvcMessage(String text) Creates a new global message with a severity of INFO. -
Method Summary
Modifier and TypeMethodDescriptionstatic MvcMessageCreates a new global error message.static MvcMessageCreates a new error message referring to the given parameter.getParam()Returns the parameter the message is associated with or null for global messagesReturns the severity of of the messagegetText()Returns the text of the messagestatic MvcMessageCreates a new global info message.static MvcMessageCreates a new info message referring to the given parameter.booleanisGlobal()Returns true for global messages which is equivalent to param being null.static MvcMessageCreates a new global warning message.static MvcMessageCreates a new warning message referring to the given parameter.
-
Constructor Details
-
MvcMessage
Creates a new global message with a severity of INFO.- Parameters:
text- The text of the message, must not be null
-
MvcMessage
Creates a new global message with the given severity.- Parameters:
severity- The severity of the message, must not be nulltext- The text of the message, must not be null
-
MvcMessage
Creates a new message referring to the given parameter.- Parameters:
severity- The severity of the message, must not be nullparam- The name of parameter this message refers to or nulltext- The text of the message, must not be null
-
-
Method Details
-
info
Creates a new global info message.- Parameters:
text- The text of the message, must not be null- Returns:
- a new
MvcMessageinstance
-
info
Creates a new info message referring to the given parameter.- Parameters:
param- The name of parameter this message refers to or nulltext- The text of the message, must not be null- Returns:
- a new
MvcMessageinstance
-
warning
Creates a new global warning message.- Parameters:
text- The text of the message, must not be null- Returns:
- a new
MvcMessageinstance
-
warning
Creates a new warning message referring to the given parameter.- Parameters:
param- The name of parameter this message refers to or nulltext- The text of the message, must not be null- Returns:
- a new
MvcMessageinstance
-
error
Creates a new global error message.- Parameters:
text- The text of the message, must not be null- Returns:
- a new
MvcMessageinstance
-
error
Creates a new error message referring to the given parameter.- Parameters:
param- The name of parameter this message refers to or nulltext- The text of the message, must not be null- Returns:
- a new
MvcMessageinstance
-
getSeverity
Returns the severity of of the message- Returns:
- the severity of the message
-
getParam
Returns the parameter the message is associated with or null for global messages- Returns:
- the parameter or null
-
getText
Returns the text of the message- Returns:
- the text of the message
-
isGlobal
public boolean isGlobal()Returns true for global messages which is equivalent to param being null.- Returns:
- whether or not the message is global
-