org.faktorips.runtime
Class Message.Builder

java.lang.Object
  extended by 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:
Message.error(String), Message.warning(String), Message.info(String)

Constructor Summary
Message.Builder(String text, Severity severity)
          Creates a new builder that is able to create a proper Message with all needed information.
 
Method Summary
 Message.Builder code(String code)
          Set the message's code that identifies the kind of the message.
 Message create()
          Creates a new Message with all previously given properties.
 Message.Builder invalidObject(ObjectProperty invalidObjectProperty)
          Set an object property that message refers to.
 Message.Builder invalidObjects(List<ObjectProperty> invalidObjectProperties)
          Add a list of object properties that message refers to.
 Message.Builder invalidObjects(ObjectProperty... invalidObjectProperties)
          Set object properties that message refers to.
 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.
 Message.Builder markers(Collection<? extends IMarker> markers)
          Set a collection of markers that should be provided to the new message.
 Message.Builder markers(IMarker... markers)
          Set some markers that should be provided to the new message.
 Message.Builder replacements(List<MsgReplacementParameter> replacementParams)
          A list of replacement parameters the message should reference.
 Message.Builder replacements(MsgReplacementParameter... replacementParams)
          Some replacement parameters the message should reference.
 Message.Builder replacements(String name, Object value)
          Creates a new MsgReplacementParameter the message should reference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Message.Builder

public Message.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
Method Detail

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

invalidObjects

public Message.Builder invalidObjects(List<ObjectProperty> invalidObjectProperties)
Add a list of object properties that message refers to.

Parameters:
invalidObjectProperties - A list of object properties that message refers to
Returns:
This builder instance to directly add further properties

invalidObject

public Message.Builder invalidObject(ObjectProperty invalidObjectProperty)
Set an object property that message refers to.

Parameters:
invalidObjectProperty - An object property that message refers to
Returns:
This builder instance to directly add further properties

invalidObjects

public Message.Builder invalidObjects(ObjectProperty... invalidObjectProperties)
Set object properties that message refers to.

Parameters:
invalidObjectProperties - Object properties that 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.


Copyright © 2015. All rights reserved.