Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Instantable
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 Details

    • getInstant

      Instant getInstant()
      Returns the Instant that this object represents.
      Returns:
      an Instant, or null if none is defined
    • extractInstant

      default MacroStringMap extractInstant(MacroKey baseKey, FormatStyle formatStyle, AdapterContextContainer ctx)
      Extracts a formatted timestamp field from this Instantable, based on the given FormatStyle and locale context.
      Parameters:
      baseKey - the macro key prefix under which the INSTANT field will be inserted
      formatStyle - the FormatStyle to use for localization
      ctx - the adapter context container providing a LocaleProvider
      Returns:
      a MacroStringMap with the formatted timestamp under baseKey.INSTANT
    • formatInstant

      static Optional<String> formatInstant(Instant instant, FormatStyle formatStyle, LocaleProvider localeProvider)
      Formats the provided Instant using the specified FormatStyle and locale.
      Parameters:
      instant - the instant to format
      formatStyle - the formatting style to use
      localeProvider - a provider of the current locale and timezone
      Returns:
      an Optional<String> containing the formatted timestamp, or empty if the instant is null