Interface ResponseMapper

All Known Subinterfaces:
WebResponseMapper
All Known Implementing Classes:
DefaultResponseMapper, DefaultWebResponseMapper

public interface ResponseMapper
A strategy interface for converting arbitrary response objects into Message instances.

This abstraction allows handler return values (or other types of responses) to be wrapped in a consistent message format, optionally including Metadata.

Implementations may handle different return types (e.g., plain objects, enriched result objects, or already wrapped Message instances) depending on the needs of the message pipeline.

Use Cases

  • Transforming handler return values into Message envelopes for result publication
  • Injecting custom metadata or headers into result messages
  • Supporting custom serialization formats or protocols
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    map(Object response)
    Maps the given response object to a Message.
    map(Object response, Metadata metadata)
    Maps the given response object and metadata to a Message.
  • Method Details

    • map

      Message map(Object response)
      Maps the given response object to a Message. The response may be a plain object or a Message.
      Parameters:
      response - the response object to be mapped
      Returns:
      a Message representing the response
    • map

      Message map(Object response, Metadata metadata)
      Maps the given response object and metadata to a Message.
      Parameters:
      response - the response object to be transformed
      metadata - optional metadata to include in the message
      Returns:
      a Message representing the response and metadata