Class MessageTemplateValidator
- java.lang.Object
-
- pl.edu.icm.unity.engine.api.msgtemplate.MessageTemplateValidator
-
public class MessageTemplateValidator extends java.lang.Object
Helper: checks if given message or text has only variables supported by a template consumer.- Author:
- P. Piernik
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MessageTemplateValidator.IllegalVariablesException
static class
MessageTemplateValidator.MandatoryVariablesException
-
Constructor Summary
Constructors Constructor Description MessageTemplateValidator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Set<java.lang.String>
extractCustomVariables(pl.edu.icm.unity.types.I18nMessage message)
static java.util.Set<java.lang.String>
extractVariables(pl.edu.icm.unity.types.I18nMessage message)
static void
validateMessage(pl.edu.icm.unity.base.msgtemplates.MessageTemplateDefinition consumer, pl.edu.icm.unity.types.I18nMessage message)
Validates a singleMessageTemplate.Message
static void
validateText(pl.edu.icm.unity.base.msgtemplates.MessageTemplateDefinition consumer, java.lang.String text, boolean checkMandatory)
-
-
-
Method Detail
-
validateMessage
public static void validateMessage(pl.edu.icm.unity.base.msgtemplates.MessageTemplateDefinition consumer, pl.edu.icm.unity.types.I18nMessage message) throws MessageTemplateValidator.IllegalVariablesException, MessageTemplateValidator.MandatoryVariablesException
Validates a singleMessageTemplate.Message
- Parameters:
consumer
-message
-- Throws:
MessageTemplateValidator.MandatoryVariablesException
pl.edu.icm.unity.exceptions.WrongArgumentException
MessageTemplateValidator.IllegalVariablesException
-
extractVariables
public static java.util.Set<java.lang.String> extractVariables(pl.edu.icm.unity.types.I18nMessage message)
- Returns:
- all variables used in message template (union over all language variants)
-
extractCustomVariables
public static java.util.Set<java.lang.String> extractCustomVariables(pl.edu.icm.unity.types.I18nMessage message)
- Returns:
- all non-built-in variables used in message template (union over all language variants)
-
validateText
public static void validateText(pl.edu.icm.unity.base.msgtemplates.MessageTemplateDefinition consumer, java.lang.String text, boolean checkMandatory) throws MessageTemplateValidator.IllegalVariablesException, MessageTemplateValidator.MandatoryVariablesException
-
-