Interface ProblemLocalizationStrategy

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

SPI seam for locale-aware translation of Problem.getTitle() / Problem.getDetail() (and any other human-readable fields) before serialization.

The default in-tree implementation is IDENTITY — a pass-through that returns the input unchanged. Server-side wiring consults the resource's bean store for a registered ProblemLocalizationStrategy bean, and falls back to IDENTITY when none is registered, so the seam is invisible at zero cost on the hot path until a deliberate strategy is contributed.

Status

This interface is shipped in juneau-bean-rfc7807 as the future-work hook for an eventual Messages-driven (resource-bundle) translation pass. The reference Messages integration is intentionally out of scope for the v1 RFC 7807 server wiring; the no-op IDENTITY default keeps the call site stable so a future implementation can be dropped in without changing the processor contract.

Example

@Bean public ProblemLocalizationStrategy localize() { return (p, locale) -> { // Future work: look up titles/details from a ResourceBundle keyed by locale. return p; }; }

See Also:
  • Field Details

    • IDENTITY

      Default no-op strategy. Returns the input Problem unchanged.

      The server-side processor uses this constant as the fallback whenever no ProblemLocalizationStrategy bean is registered with the resource. Implementations that need to opt out of localization for a specific Problem can return this constant's behavior by simply returning the input.

  • Method Details

    • localize

      Problem localize(Problem problem, Locale locale)
      Translates the supplied Problem for the given Locale.

      Implementations may mutate and return the input Problem, or return a fresh bean — the processor treats the return value as the bean to serialize. A null return is treated as "no opinion" and the original (pre-localization) Problem is used instead.

      Parameters:
      problem - The Problem to localize. Never null.
      locale - The negotiated locale for the current request, or null when no locale is available.
      Returns:
      The localized Problem to emit, or the input problem for pass-through.