public static final class ValidationMessage.Builder extends Object
ValidationMessage
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 | Field and Description |
|---|---|
private ValidationDomain |
domain
Validation domain
|
(package private) boolean |
fatal
Is this error message fatal?
|
private ObjectNode |
info
Further information associated with the error message
|
private String |
keyword
Keyword associated with the message
|
private String |
message
Error message
|
private static Set<String> |
RESERVED
Reserved set of keywords which will be removed off
info
before the message is built |
| Constructor and Description |
|---|
ValidationMessage.Builder(ValidationDomain domain)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
<T> ValidationMessage.Builder |
addInfo(String key,
Collection<T> values)
Add further information to the message as a
Collection of
objects of an arbitrary type |
ValidationMessage.Builder |
addInfo(String key,
int value)
Add further information to the message as an integer
|
ValidationMessage.Builder |
addInfo(String key,
JsonNode value)
Add further information to the message as a
JsonNode |
<T> ValidationMessage.Builder |
addInfo(String key,
T value)
Add further information to the message for an arbitrary type
|
ValidationMessage |
build()
Build the actual message
|
ValidationMessage.Builder |
clearInfo()
Clear all supplementary information
|
ValidationMessage.Builder |
setFatal(boolean fatal)
Should this error message be marked as fatal?
|
ValidationMessage.Builder |
setKeyword(String keyword)
Set the keyword associated with this message
|
ValidationMessage.Builder |
setMessage(String message)
Set the error message
|
private static final Set<String> RESERVED
info
before the message is builtprivate final ValidationDomain domain
private String keyword
In some events, it may be set to N/A.
private String message
private final ObjectNode info
boolean fatal
public ValidationMessage.Builder(ValidationDomain domain)
domain - the validation domainpublic ValidationMessage.Builder setKeyword(String keyword)
keyword - the keywordpublic ValidationMessage.Builder setMessage(String message)
message - the error messagepublic ValidationMessage.Builder setFatal(boolean fatal)
fatal - true if this error message is fatal (false by default)public ValidationMessage.Builder addInfo(String key, JsonNode value)
JsonNodekey - the keyvalue - the valuepublic <T> ValidationMessage.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> ValidationMessage.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 ValidationMessage.Builder addInfo(String key, int value)
key - the keyvalue - the valuepublic ValidationMessage.Builder clearInfo()
This will not reset the domain, keyword or message.
public ValidationMessage build()
ValidationMessageNullPointerException - the keyword or message are nullCopyright © 2012. All Rights Reserved.