Interface Instantable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
An interface for types that expose a single
Instant
value, such as a timestamp
for creation, expiration, modification, or other moments in time.
When used with the MessageBuilderLib adapter pipeline, implementing this interface enables support for macro placeholders like:
[OBJECT.INSTANT
}
which will be automatically replaced with a localized string representation of the instant,
using the system’s configured FormatStyle
and Locale
.
This allows plugin-defined types to seamlessly integrate timestamp-based information into translatable message strings.
-
Method Summary
Modifier and TypeMethodDescriptiondefault MacroStringMap
extractInstant
(MacroKey baseKey, FormatStyle formatStyle, AdapterContextContainer ctx) Extracts a formatted timestamp field from thisInstantable
, based on the givenFormatStyle
and locale context.formatInstant
(Instant instant, FormatStyle formatStyle, LocaleProvider localeProvider) Formats the providedInstant
using the specifiedFormatStyle
and locale.Returns theInstant
that this object represents.
-
Method Details
-
getInstant
Instant getInstant()Returns theInstant
that this object represents.- Returns:
- an
Instant
, ornull
if none is defined
-
extractInstant
default MacroStringMap extractInstant(MacroKey baseKey, FormatStyle formatStyle, AdapterContextContainer ctx) Extracts a formatted timestamp field from thisInstantable
, based on the givenFormatStyle
and locale context.- Parameters:
baseKey
- the macro key prefix under which theINSTANT
field will be insertedformatStyle
- theFormatStyle
to use for localizationctx
- the adapter context container providing aLocaleProvider
- Returns:
- a
MacroStringMap
with the formatted timestamp underbaseKey.INSTANT
-
formatInstant
static Optional<String> formatInstant(Instant instant, FormatStyle formatStyle, LocaleProvider localeProvider) Formats the providedInstant
using the specifiedFormatStyle
and locale.- Parameters:
instant
- the instant to formatformatStyle
- the formatting style to uselocaleProvider
- a provider of the current locale and timezone- Returns:
- an
Optional<String>
containing the formatted timestamp, or empty if the instant isnull
-