Package com.networknt.status
Class Status
- java.lang.Object
-
- com.networknt.status.Status
-
public class Status extends Object
For every status response, there is only one message returned. This means the server will fail fast and won't return multiple message at all. Two benefits for this design:1. low latency as server will return the first error without further processing 2. limited attack risks and make the error handling harder to analyzed
- Author:
- Steve Hu
-
-
Field Summary
Fields Modifier and Type Field Description static Map<String,Object>configstatic StringCONFIG_NAMEstatic StringdefaultSeverity
-
Constructor Summary
Constructors Constructor Description Status()Default construction that is only used in reflection.Status(int statusCode, String code, String message, String description)Construct a status object based on all the properties in the object.Status(int statusCode, String code, String message, String description, String severity)Construct a status object based on all the properties in the object.Status(String code, Object... args)Construct a status object based on error code and a list of arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCode()StringgetDescription()StringgetMessage()StringgetSeverity()intgetStatusCode()voidsetCode(String code)voidsetDescription(String description)voidsetMessage(String message)voidsetSeverity(String severity)voidsetStatusCode(int statusCode)StringtoString()
-
-
-
Field Detail
-
CONFIG_NAME
public static final String CONFIG_NAME
- See Also:
- Constant Field Values
-
defaultSeverity
public static final String defaultSeverity
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Status
public Status()
Default construction that is only used in reflection.
-
Status
public Status(String code, Object... args)
Construct a status object based on error code and a list of arguments. It is the most popular way to create status object from status.yml definition.- Parameters:
code- Error Codeargs- A list of arguments that will be populated into the error description
-
Status
public Status(int statusCode, String code, String message, String description)Construct a status object based on all the properties in the object. It is not very often to use this construct to create object.- Parameters:
statusCode- Status Codecode- Codemessage- Messagedescription- Description
-
Status
public Status(int statusCode, String code, String message, String description, String severity)Construct a status object based on all the properties in the object. It is not very often to use this construct to create object.- Parameters:
statusCode- Status Codecode- Codeseverity- Status Severitymessage- Messagedescription- Description
-
-
Method Detail
-
getStatusCode
public int getStatusCode()
-
setStatusCode
public void setStatusCode(int statusCode)
-
getCode
public String getCode()
-
setCode
public void setCode(String code)
-
getMessage
public String getMessage()
-
setMessage
public void setMessage(String message)
-
getDescription
public String getDescription()
-
setDescription
public void setDescription(String description)
-
setSeverity
public void setSeverity(String severity)
-
getSeverity
public String getSeverity()
-
-