Class MessageBuilder


  • public class MessageBuilder
    extends java.lang.Object
    Builder class for constructing messages.

    This class implements the builder pattern for creating messages with various parameters. It is typically not called directly by client code, but is used internally by the Messages API implementations.

    • Constructor Summary

      Constructors 
      Constructor Description
      MessageBuilder​(MessageType type, java.nio.file.Path path, java.util.function.Consumer<Message> consumer)
      Creates a new MessageBuilder.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MessageBuilder cause​(java.lang.Throwable cause)
      Sets the exception cause for the message.
      MessageBuilder column​(int column)
      Sets the column number for the message.
      void create​(java.lang.String message)
      Creates the message object with all collected parameters and informs the consumer.
      MessageBuilder line​(int line)
      Sets the line number for the message.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MessageBuilder

        public MessageBuilder​(MessageType type,
                              java.nio.file.Path path,
                              java.util.function.Consumer<Message> consumer)
        Creates a new MessageBuilder.

        Note: This constructor is usually not called by client code. Use the builder methods provided by the Messages interface instead (e.g., buildError, buildWarning, buildInfo).

        Parameters:
        type - the type of message to build
        path - the file path for which the message should be created
        consumer - the consumer that will receive the constructed message
    • Method Detail

      • line

        public MessageBuilder line​(int line)
        Sets the line number for the message.
        Parameters:
        line - the line number (1-based, use 0 for unknown)
        Returns:
        this builder for method chaining
      • column

        public MessageBuilder column​(int column)
        Sets the column number for the message.
        Parameters:
        column - the column number (1-based, use 0 for unknown)
        Returns:
        this builder for method chaining
      • cause

        public MessageBuilder cause​(java.lang.Throwable cause)
        Sets the exception cause for the message.
        Parameters:
        cause - the exception that caused this message
        Returns:
        this builder for method chaining
      • create

        public void create​(java.lang.String message)
        Creates the message object with all collected parameters and informs the consumer. This method finalizes the builder and creates the message.
        Parameters:
        message - the message text (must not be null or blank)