java.lang.Object
io.github.mmm.base.text.AbstractTextFormatMessageHandler
- All Implemented Interfaces:
TextFormatMessageHandler
public abstract class AbstractTextFormatMessageHandler
extends Object
implements TextFormatMessageHandler
Default implementation of
TextFormatMessageHandler.-
Constructor Summary
ConstructorsConstructorDescriptionAbstractTextFormatMessageHandler(boolean throwOnError, boolean collectMessages) The constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(TextFormatMessage message) handle(TextFormatMessage message) Method to allow custom handling or even transformation ofTextFormatMessages.boolean
-
Constructor Details
-
AbstractTextFormatMessageHandler
public AbstractTextFormatMessageHandler(boolean throwOnError, boolean collectMessages) The constructor.- Parameters:
throwOnError- -trueto throw aRuntimeExceptionwhen anerrormessageishandled.collectMessages- the flag forisCollectMessages().
-
-
Method Details
-
add
- Specified by:
addin interfaceTextFormatMessageHandler- Parameters:
message- theTextFormatMessageto add.
-
handle
Method to allow custom handling or even transformation ofTextFormatMessages. Does nothing by default and may be overridden e.g. to log messages and throw aRuntimeExceptionin case of anerror.- Parameters:
message- theTextFormatMessageto handle.- Returns:
- the given
TextFormatMessageor potentially a transformation. - Throws:
RuntimeException- in case theTextFormatMessageshould immediately lead to an exception aborting any further processing. By defaultTextFormatMessages should be collected inTextFormatProcessor.getMessages()in order to allow maximum fault-tolerance.
-
isCollectMessages
public boolean isCollectMessages()- Returns:
trueto collectmessages(default) ornullif noTextFormatMessageshould be collected andTextFormatProcessor.getMessages()will always return theempty list.
-
getMessages
- Specified by:
getMessagesin interfaceTextFormatMessageHandler- Returns:
- the
ListofTextFormatMessages.
-