public final class ValidationReport extends Object
Internally, it uses a ListMultimap where:
JsonPointers),
ValidationMessages.You can retrieve messages either as a list of plain strings (ordered by
instance path) or as JSON (ie, a JsonNode).
JsonSchema.validate(JsonNode)| Modifier and Type | Field and Description |
|---|---|
private boolean |
fatal |
private ListMultimap<JsonPointer,ValidationMessage> |
msgMap
Message list
|
private JsonPointer |
path
The current path
|
private static JsonPointer |
ROOT
Root JSON Pointer (ie,
#) |
| Modifier | Constructor and Description |
|---|---|
|
ValidationReport()
Create a new validation report with
ROOT as an instance path |
private |
ValidationReport(JsonPointer path)
Create a new validation report with an arbitraty path
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addMessage(ValidationMessage message)
Add one validation message to the report
|
void |
addMessages(Collection<ValidationMessage> messages)
Add several validation messages to the report
|
JsonNode |
asJsonNode()
Retrieve all messages as a
JsonNode |
ValidationReport |
copy()
Make a copy of this validation report, with an empty message map and
the current path.
|
List<String> |
getMessages()
Get a flat list of validation messages
|
JsonPointer |
getPath()
Get the current path of this report
|
boolean |
hasFatalError() |
boolean |
isSuccess()
Is this report a success?
|
void |
mergeWith(ValidationReport other)
Merge with another validation report
|
void |
setPath(JsonPointer path)
Set the current path of this report
|
int |
size() |
String |
toString() |
private static final JsonPointer ROOT
#)private final ListMultimap<JsonPointer,ValidationMessage> msgMap
private JsonPointer path
private boolean fatal
public ValidationReport()
ROOT as an instance pathprivate ValidationReport(JsonPointer path)
path - the JSON Pointerpublic JsonPointer getPath()
public void setPath(JsonPointer path)
path - the pathpublic boolean addMessage(ValidationMessage message)
message - the messagefatal is
already truepublic void addMessages(Collection<ValidationMessage> messages)
messages - the collection of messagespublic int size()
public boolean isSuccess()
public boolean hasFatalError()
public void mergeWith(ValidationReport other)
other - the report to merge withpublic ValidationReport copy()
public List<String> getMessages()
One message has the form:
#/pointer/here: message here
The list is sorted by pointer.
public JsonNode asJsonNode()
JsonNode
The retrieved JSON document is an object where:
JsonPointers,ValidationMessage.toJsonNode()Copyright © 2012. All Rights Reserved.