Class MessageBuilder

java.lang.Object
org.codehaus.plexus.build.messages.MessageBuilder

public class MessageBuilder extends 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 Details

    • MessageBuilder

      public MessageBuilder(MessageType type, Path path, 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 Details

    • 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(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(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)