Class Message.Builder

java.lang.Object
org.faktorips.runtime.Message.Builder
Enclosing class:
Message

public static class Message.Builder extends Object
A builder for the Message class. This builder has been designed due to heavy constructor overloading with many parameters. It helps instantiating global variables of Message.

To use the builder simply create an instance by calling the Message(String, Severity) or by calling one of the static creation methods like Message.error(String), Message.warning(String) or Message.info(String). Afterwards add needed information to the builder for example call invalidObjectWithProperties(Object object, String...properties) to provide some invalid object properties. When the builder has every information that is needed to create a proper message call create().

See Also:
  • Constructor Details

    • Builder

      public Builder(String text, Severity severity)
      Creates a new builder that is able to create a proper Message with all needed information.
      Parameters:
      text - The human readable text of this message
      severity - The message's severity: Message.ERROR, Message.WARNING or Message.INFO
    • Builder

      public Builder(Message message)
      Creates a new builder from a given Message to create a copy of the Message with all information.
      Parameters:
      message - the Message to copy
  • Method Details

    • code

      public Message.Builder code(String code)
      Set the message's code that identifies the kind of the message.
      Parameters:
      code - A message code that identifies the kind of the message
      Returns:
      This builder instance to directly add further properties
    • text

      public Message.Builder text(String text)
      Set the message's text which is human readable.
      Parameters:
      text - The human readable text of this message
      Returns:
      This builder instance to directly add further properties
    • severity

      public Message.Builder severity(Severity severity)
      Set the message's severity, in exact Message.ERROR, Message.WARNING or Message.INFO.
      Parameters:
      severity - Severity of the message: Message.ERROR, Message.WARNING or Message.INFO
      Returns:
      This builder instance to directly add further properties
    • invalidObjects

      public Message.Builder invalidObjects(List<ObjectProperty> invalidObjectProperties)
      Add a list of object properties that the message refers to.
      Parameters:
      invalidObjectProperties - A list of object properties that the message refers to
      Returns:
      This builder instance to directly add further properties
    • invalidObject

      public Message.Builder invalidObject(ObjectProperty invalidObjectProperty)
      Add an object property that the message refers to.
      Parameters:
      invalidObjectProperty - An object property that the message refers to
      Returns:
      This builder instance to directly add further properties
    • invalidObjects

      public Message.Builder invalidObjects(ObjectProperty... invalidObjectProperties)
      Add object properties that the message refers to.
      Parameters:
      invalidObjectProperties - Object properties that the message refers to
      Returns:
      This builder instance to directly add further properties
    • invalidObjectWithProperties

      public Message.Builder invalidObjectWithProperties(Object object, String... properties)
      Add some object properties the message refers to by creating instances of ObjectProperty for every given property and the given object.
      Parameters:
      object - The object the message refers to
      properties - Some properties the message refers to
      Returns:
      This builder instance to directly add further properties
    • replacements

      public Message.Builder replacements(List<MsgReplacementParameter> replacementParams)
      A list of replacement parameters the message should reference.
      Parameters:
      replacementParams - a list of replacement parameters
      Returns:
      This builder instance to directly add further properties
    • replacements

      public Message.Builder replacements(MsgReplacementParameter... replacementParams)
      Some replacement parameters the message should reference.
      Parameters:
      replacementParams - Some replacement parameters
      Returns:
      This builder instance to directly add further properties
    • replacements

      public Message.Builder replacements(String name, Object value)
      Creates a new MsgReplacementParameter the message should reference
      Parameters:
      name - The name of the MsgReplacementParameter
      value - The value of the MsgReplacementParameter
      Returns:
      This builder instance to directly add further properties
    • markers

      public Message.Builder markers(Collection<? extends IMarker> markers)
      Set a collection of markers that should be provided to the new message.
      Parameters:
      markers - a set of markers
      Returns:
      This builder instance to directly add further properties
    • markers

      public Message.Builder markers(IMarker... markers)
      Set some markers that should be provided to the new message.
      Parameters:
      markers - Some markers
      Returns:
      This builder instance to directly add further properties
    • create

      public Message create()
      Creates a new Message with all previously given properties.
      Returns:
      A new message that has the parameters of this builder.