Package io.milton.common
Class JsonResult
java.lang.Object
io.milton.common.JsonResult
Value object holding the result of some operation in a generic form
which is suitable for outputting as JSON.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassRepresents a message (usually a validation error) pertaining to a field The field name is the name of the POST variable which caused the error -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJsonResult(boolean status) JsonResult(boolean status, String message) JsonResult(boolean status, String message, String nextHref) JsonResult(boolean status, String nextHref, List<String> messages, List<JsonResult.FieldMessage> fieldMessages) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFieldMessage(String field, String message) static JsonResultstatic JsonResultfieldError(String field, String fieldMessage) getData()Any JSON friendly objectList of messages relating to specific fields.Any messages which are not specific to certain fieldsIf an object was created this should be the href of that object.booleanisStatus()Flag to indicate success or failure of the operationstatic JsonResultreturnData(Object data) static JsonResultreturnData(String href, Object data) voidvoidsetFieldMessages(List<JsonResult.FieldMessage> fieldMessages) voidsetMessages(List<String> messages) voidsetNextHref(String nextHref) voidsetStatus(boolean status)
-
Field Details
-
CONTENT_TYPE
-
-
Constructor Details
-
JsonResult
public JsonResult() -
JsonResult
public JsonResult(boolean status, String nextHref, List<String> messages, List<JsonResult.FieldMessage> fieldMessages) -
JsonResult
public JsonResult(boolean status) -
JsonResult
-
JsonResult
-
-
Method Details
-
error
-
fieldError
-
returnData
-
returnData
-
addFieldMessage
-
isStatus
public boolean isStatus()Flag to indicate success or failure of the operation- Returns:
- the status
-
setStatus
public void setStatus(boolean status) - Parameters:
status- the status to set
-
getNextHref
If an object was created this should be the href of that object. If the operation completed was part of a workflow then this should be the href of the next step in the workflow- Returns:
- the nextHref
-
setNextHref
- Parameters:
nextHref- the nextHref to set
-
getMessages
Any messages which are not specific to certain fields- Returns:
- the messages
-
setMessages
- Parameters:
messages- the messages to set
-
getFieldMessages
List of messages relating to specific fields. The field name must correspond to a POST variable name- Returns:
- the fieldMessages
-
setFieldMessages
- Parameters:
fieldMessages- the fieldMessages to set
-
getData
Any JSON friendly object- Returns:
-
setData
-