Class MessageConfig.BuilderBase<T, BUILDER extends MessageConfig.BuilderBase<T, BUILDER, PROTOTYPE>, PROTOTYPE extends MessageConfig<T>>

java.lang.Object
io.helidon.messaging.MessageConfig.BuilderBase<T, BUILDER, PROTOTYPE>
Type Parameters:
T - payload type
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
Prototype.Builder<BUILDER, PROTOTYPE>
Direct Known Subclasses:
MessageConfig.Builder
Enclosing interface:
MessageConfig<T>

public abstract static class MessageConfig.BuilderBase<T, BUILDER extends MessageConfig.BuilderBase<T, BUILDER, PROTOTYPE>, PROTOTYPE extends MessageConfig<T>> extends Object implements Prototype.Builder<BUILDER, PROTOTYPE>
Fluent API builder base for MessageConfig.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(MessageConfig<T> prototype)
      Update this builder from an existing prototype instance. This method disables automatic service discovery.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(MessageConfig.BuilderBase<T,?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • header

      public BUILDER header(String name, String value)
      Set a portable text header, replacing all values with the same exact name.
      Parameters:
      name - header name
      value - header value
      Returns:
      updated builder instance
      Throws:
      NullPointerException - if name or value is null
    • header

      public BUILDER header(String name, MessageHeaderValue value)
      Set a portable typed header, replacing all values with the same exact name.
      Parameters:
      name - header name
      value - header value
      Returns:
      updated builder instance
      Throws:
      NullPointerException - if name or value is null
    • addHeader

      public BUILDER addHeader(String name, String value)
      Append a portable text header, retaining values with the same exact name.
      Parameters:
      name - header name
      value - header value
      Returns:
      updated builder instance
      Throws:
      NullPointerException - if name or value is null
    • addHeader

      public BUILDER addHeader(String name, MessageHeaderValue value)
      Append a portable typed header, retaining values with the same exact name.
      Parameters:
      name - header name
      value - header value
      Returns:
      updated builder instance
      Throws:
      NullPointerException - if name or value is null
    • headers

      public BUILDER headers(MessageHeaders headers)
      Replace all portable headers with the supplied immutable snapshot.
      Parameters:
      headers - portable headers
      Returns:
      updated builder instance
      Throws:
      NullPointerException - if headers is null
    • headers

      public BUILDER headers(Consumer<MessageHeaders.Builder> consumer)
      Replace all portable headers using an initially empty headers builder.
      Parameters:
      consumer - headers builder consumer
      Returns:
      updated builder instance
      Throws:
      NullPointerException - if consumer is null
    • headers

      public BUILDER headers(Supplier<? extends MessageHeaders> supplier)
      Replace all portable headers using a supplier evaluated immediately.
      Parameters:
      supplier - portable headers supplier
      Returns:
      updated builder instance
      Throws:
      NullPointerException - if supplier or its result is null
    • localMetadata

      public BUILDER localMetadata(String name, String value)
      Set a local text metadata value, replacing the value with the same exact name.
      Parameters:
      name - exact metadata name
      value - text value
      Returns:
      updated builder instance
      Throws:
      NullPointerException - if name or value is null
    • localMetadata

      public BUILDER localMetadata(MessageMetadata localMetadata)
      Replace all local metadata with the supplied immutable snapshot.
      Parameters:
      localMetadata - local metadata
      Returns:
      updated builder instance
      Throws:
      NullPointerException - if localMetadata is null
    • localMetadata

      public BUILDER localMetadata(Consumer<MessageMetadata.Builder> consumer)
      Replace all local metadata using an initially empty metadata builder.
      Parameters:
      consumer - metadata builder consumer
      Returns:
      updated builder instance
      Throws:
      NullPointerException - if consumer is null
    • localMetadata

      public BUILDER localMetadata(Supplier<? extends MessageMetadata> supplier)
      Replace all local metadata using a supplier evaluated immediately.
      Parameters:
      supplier - local metadata supplier
      Returns:
      updated builder instance
      Throws:
      NullPointerException - if supplier or its result is null
    • entity

      public BUILDER entity(T entity)
      Non-null message payload.
      Parameters:
      entity - payload
      Returns:
      updated builder instance
      See Also:
    • clearHeaders

      public BUILDER clearHeaders()
      Clear all headers.
      Returns:
      updated builder instance
      See Also:
    • headers

      public BUILDER headers(List<? extends MessageHeader> headers)
      Ordered portable headers. Defaults to an empty list. Setting this option replaces the current entries; adding headers preserves their order and duplicate names. The builder accumulates entries in a mutable list and the prototype contains an immutable snapshot.
      Parameters:
      headers - portable headers
      Returns:
      updated builder instance
      See Also:
    • addHeaders

      public BUILDER addHeaders(List<? extends MessageHeader> headers)
      Ordered portable headers. Defaults to an empty list. Setting this option replaces the current entries; adding headers preserves their order and duplicate names. The builder accumulates entries in a mutable list and the prototype contains an immutable snapshot.
      Parameters:
      headers - portable headers
      Returns:
      updated builder instance
      See Also:
    • addHeader

      public BUILDER addHeader(MessageHeader header)
      Ordered portable headers. Defaults to an empty list. Setting this option replaces the current entries; adding headers preserves their order and duplicate names. The builder accumulates entries in a mutable list and the prototype contains an immutable snapshot.
      Parameters:
      header - add single portable headers
      Returns:
      updated builder instance
      See Also:
    • localMetadata

      public BUILDER localMetadata(Map<String, ? extends MessageHeaderValue> localMetadata)
      Metadata local to this message envelope. Defaults to an empty map. Setting this option replaces the current entries; adding a value replaces the value with the same exact name. The builder accumulates entries in a mutable map and the prototype contains an immutable snapshot. Local metadata remains in-process and is not part of portable headers or generic connector mapping. This method replaces all values with the new ones.
      Parameters:
      localMetadata - local metadata
      Returns:
      updated builder instance
      See Also:
    • addLocalMetadata

      public BUILDER addLocalMetadata(Map<String, ? extends MessageHeaderValue> localMetadata)
      Metadata local to this message envelope. Defaults to an empty map. Setting this option replaces the current entries; adding a value replaces the value with the same exact name. The builder accumulates entries in a mutable map and the prototype contains an immutable snapshot. Local metadata remains in-process and is not part of portable headers or generic connector mapping. This method keeps existing values, then puts all new values into the map.
      Parameters:
      localMetadata - local metadata
      Returns:
      updated builder instance
      See Also:
    • localMetadata

      public BUILDER localMetadata(String key, MessageHeaderValue localMetadata)
      Metadata local to this message envelope. Defaults to an empty map. Setting this option replaces the current entries; adding a value replaces the value with the same exact name. The builder accumulates entries in a mutable map and the prototype contains an immutable snapshot. Local metadata remains in-process and is not part of portable headers or generic connector mapping. This method adds a new value to the map, or replaces it if the key already exists.
      Parameters:
      key - key to add or replace
      localMetadata - new value for the key
      Returns:
      updated builder instance
      See Also:
    • entity

      public Optional<T> entity()
      Non-null message payload.
      Returns:
      payload
    • headers

      public List<MessageHeader> headers()
      Ordered portable headers. Defaults to an empty list. Setting this option replaces the current entries; adding headers preserves their order and duplicate names. The builder accumulates entries in a mutable list and the prototype contains an immutable snapshot.
      Returns:
      portable headers
    • localMetadata

      public Map<String, MessageHeaderValue> localMetadata()
      Metadata local to this message envelope. Defaults to an empty map. Setting this option replaces the current entries; adding a value replaces the value with the same exact name. The builder accumulates entries in a mutable map and the prototype contains an immutable snapshot. Local metadata remains in-process and is not part of portable headers or generic connector mapping.
      Returns:
      local metadata
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and decorators.
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.
    • buildPrototype

      protected final MessageConfig<T> buildPrototype(MessageConfig.BuilderBase<T,?,?> builder)
      Create a new prototype instance from a builder.
      Parameters:
      builder - builder used to create the prototype
      Returns:
      new prototype instance