Class Message
- java.lang.Object
-
- dk.cloudcreate.essentials.shared.messages.Message
-
- All Implemented Interfaces:
Serializable
public class Message extends Object implements Serializable
AMessageis an instance of aMessageTemplatewith parameters bound to it
AMessageinstance is e.g. useful for error/validation reporting.
Example creating aMessagefrom aMessageTemplate4:
will create aMessageTemplate4<String, BigDecimal, BigDecimal, LocalDate> ACCOUNT_OVERDRAWN = ROOT.key4("ACCOUNT_OVERDRAWN", "Account {0} is overdrawn by ${1}. A fee of ${2} will be debited on the {3}"); String accountId = "Account1"; BigDecimal overdrawnAmount = new BigDecimal("125"); BigDecimal feeAmount = new BigDecimal("10"); LocalDate feeDebitDate = LocalDate.of(2023, 2, 25); Message msg = ACCOUNT_OVERDRAWN.create(accountId, overdrawnAmount, feeAmount, feeDebitDate);MessagewithgetMessage():"Account Account1 is overdrawn by $125. A fee of $10 will be debited on the 2023-2-25"(date formatting is dependent on theLocale)- See Also:
MessageTemplate,MessageTemplates, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Message(MessageTemplate template, Object... parameters)Create a concrete instance of aMessageTemplate
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetKey()StringgetMessage()TheMessageTemplate.getDefaultMessage()with thegetParameters()applied usingMessageFormat.format(String, Object...)
Example creating aMessagefrom aMessageTemplate4:List<Object>getParameters()The concrete parameters for the messageMessageTemplategetTemplate()The message template that this message is based on
-
-
-
Constructor Detail
-
Message
public Message(MessageTemplate template, Object... parameters)
Create a concrete instance of aMessageTemplate- Parameters:
template- the message templateparameters- the parameters for the message template
-
-
Method Detail
-
getKey
public String getKey()
- Returns:
- The
MessageTemplate.getKey()
-
getTemplate
public MessageTemplate getTemplate()
The message template that this message is based on- Returns:
- the message template that this message is based on
-
getParameters
public List<Object> getParameters()
The concrete parameters for the message- Returns:
- the concrete parameters for the message
-
getMessage
public String getMessage()
TheMessageTemplate.getDefaultMessage()with thegetParameters()applied usingMessageFormat.format(String, Object...)
Example creating aMessagefrom aMessageTemplate4:
will create aMessageTemplate4<String, BigDecimal, BigDecimal, LocalDate> ACCOUNT_OVERDRAWN = ROOT.key4("ACCOUNT_OVERDRAWN", "Account {0} is overdrawn by ${1}. A fee of ${2} will be debited on the {3}"); String accountId = "Account1"; BigDecimal overdrawnAmount = new BigDecimal("125"); BigDecimal feeAmount = new BigDecimal("10"); LocalDate feeDebitDate = LocalDate.of(2023, 2, 25); Message msg = ACCOUNT_OVERDRAWN.create(accountId, overdrawnAmount, feeAmount, feeDebitDate);MessagewithgetMessage():"Account Account1 is overdrawn by $125. A fee of $10 will be debited on the 2023-2-25"(date formatting is dependent on theLocale)- Returns:
- The
MessageTemplate.getDefaultMessage()with thegetParameters()applied usingMessageFormat.format(String, Object...)
-
-