public static final class Message.Builder extends Object
Message
To build a validation message, you instantiate this class, fill the
necessary information and finally call build()
to obtain the
message.
In most cases, you won't need to instantiate one directly:
SyntaxChecker
, an instance of this
class will be passed as an argument, already filled with the
correct domain and keyword;KeywordValidator
, you can obtain an
instance also filled with the correct domain and keyword.Modifier and Type | Method and Description |
---|---|
<T> Message.Builder |
addInfo(String key,
Collection<T> values)
Add further information to the message as a
Collection of
objects of an arbitrary type |
Message.Builder |
addInfo(String key,
int value)
Add further information to the message as an integer
|
Message.Builder |
addInfo(String key,
JsonNode value)
Add further information to the message as a
JsonNode |
<T> Message.Builder |
addInfo(String key,
T value)
Add further information to the message for an arbitrary type
|
Message |
build()
Build the actual message
|
Message.Builder |
clearInfo()
Clear all supplementary information
|
Message.Builder |
setFatal(boolean fatal)
Should this error message be marked as fatal?
|
Message.Builder |
setKeyword(String keyword)
Set the keyword associated with this message
|
Message.Builder |
setMessage(String message)
Set the error message
|
public Message.Builder setKeyword(String keyword)
keyword
- the keywordpublic Message.Builder setMessage(String message)
message
- the error messagepublic Message.Builder setFatal(boolean fatal)
fatal
- true if this error message is fatal (false by default)public Message.Builder addInfo(String key, JsonNode value)
JsonNode
key
- the keyvalue
- the valuepublic <T> Message.Builder addInfo(String key, T value)
This will call Object.toString()
on the passed value. It
is therefore important that objects passed as arguments implement it
correctly.
T
- the type of the valuekey
- the keyvalue
- the valuepublic <T> Message.Builder addInfo(String key, Collection<T> values)
Collection
of
objects of an arbitrary type
This will call Object.toString()
on each element of the
collection.It is therefore important that objects passed as arguments
implement it correctly.
T
- the type of values in the collectionskey
- the keyvalues
- the collectionaddInfo(String, Object)
public Message.Builder addInfo(String key, int value)
key
- the keyvalue
- the valuepublic Message.Builder clearInfo()
This will not reset the domain, keyword or message.
public Message build()
Message
NullPointerException
- the keyword or message are nullCopyright © 2013. All Rights Reserved.