Class Message
java.lang.Object
dk.cloudcreate.essentials.shared.messages.Message
- All Implemented Interfaces:
Serializable
A
A
Example creating a
Message is an instance of a MessageTemplate with parameters bound to itA
Message instance is e.g. useful for error/validation reporting.Example creating a
Message from a MessageTemplate4:
MessageTemplate4<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);
will create a Message with getMessage():
"Account Account1 is overdrawn by $125. A fee of $10 will be debited on the 2023-2-25" (date formatting is dependent on the Locale)- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMessage(MessageTemplate template, Object... parameters) Create a concrete instance of aMessageTemplate -
Method Summary
Modifier and TypeMethodDescriptiongetKey()TheMessageTemplate.getDefaultMessage()with thegetParameters()applied usingMessageFormat.format(String, Object...)
Example creating aMessagefrom aMessageTemplate4:The concrete parameters for the messageThe message template that this message is based on
-
Constructor Details
-
Method Details
-
getKey
- Returns:
- The
MessageTemplate.getKey()
-
getTemplate
The message template that this message is based on- Returns:
- the message template that this message is based on
-
getParameters
The concrete parameters for the message- Returns:
- the concrete parameters for the message
-
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...)
-