Class JsonApiError
- java.lang.Object
-
- com.toedter.spring.hateoas.jsonapi.JsonApiError
-
public final class JsonApiError extends java.lang.Object
Class to build a single JSON:API compliant error. This error can be added toJsonApiErrors
.
-
-
Constructor Summary
Constructors Constructor Description JsonApiError()
Creates an emptyJsonApiError
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JsonApiError
create()
boolean
equals(java.lang.Object o)
java.lang.String
getCode()
Gets an application-specific error code, expressed as a string value.java.lang.String
getDetail()
Gets a human-readable explanation specific to this occurrence of the problem.java.lang.String
getId()
Gets a unique identifier for this particular occurrence of the problem.java.util.Map<java.lang.String,java.lang.String>
getLinks()
Gets a links object containing the following members: about: a link that leads to further details about this particular occurrence of the problem.java.util.Map<java.lang.String,java.lang.Object>
getMeta()
Gets a meta object containing non-standard meta-information about the error.java.util.Map<java.lang.String,java.lang.String>
getSource()
Gets an object containing references to the source of the error, optionally including any of the following members: pointer: a JSON Pointer [RFC6901] to the associated entity in the request document [e.g.java.lang.String
getStatus()
Gets the the HTTP status code applicable to this problem, expressed as a string value.java.lang.String
getTitle()
Gets a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.int
hashCode()
java.lang.String
toString()
JsonApiError
withAboutLink(java.lang.String aboutLink)
Adds an about link to the error.JsonApiError
withCode(java.lang.String code)
Sets an application-specific error code, expressed as a string value.JsonApiError
withDetail(java.lang.String detail)
Sets a human-readable explanation specific to this occurrence of the problem.JsonApiError
withId(java.lang.String id)
Sets a unique identifier for this particular occurrence of the problem.JsonApiError
withMeta(java.util.Map<java.lang.String,java.lang.Object> meta)
Sets a meta object containing non-standard meta-information about the error.JsonApiError
withSourceParameter(java.lang.String sourceParameter)
Adds a source parameter to the error.JsonApiError
withSourcePointer(java.lang.String sourcePointer)
Adds a source pointer to the error.JsonApiError
withStatus(java.lang.String status)
Adds the HTTP status code applicable to this problem, expressed as a string value.JsonApiError
withTitle(java.lang.String title)
Sets a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.
-
-
-
Constructor Detail
-
JsonApiError
public JsonApiError()
Creates an emptyJsonApiError
.
-
-
Method Detail
-
withSourcePointer
public JsonApiError withSourcePointer(java.lang.String sourcePointer)
Adds a source pointer to the error.- Parameters:
sourcePointer
- a JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object, or "/data/attributes/title" for a specific attribute].- Returns:
- will never be null.
-
withSourceParameter
public JsonApiError withSourceParameter(java.lang.String sourceParameter)
Adds a source parameter to the error.- Parameters:
sourceParameter
- a string indicating which URI query parameter caused the error.- Returns:
- will never be null.
-
withAboutLink
public JsonApiError withAboutLink(java.lang.String aboutLink)
Adds an about link to the error.- Parameters:
aboutLink
- the link describing this error- Returns:
- will never be null.
-
create
public static JsonApiError create()
- Returns:
- Creates an empty
JsonApiError
.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getId
public java.lang.String getId()
Gets a unique identifier for this particular occurrence of the problem.- Returns:
- will never be null.
-
withId
public JsonApiError withId(java.lang.String id)
Sets a unique identifier for this particular occurrence of the problem.- Parameters:
id
- the unique identifier of the error.- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
getLinks
public java.util.Map<java.lang.String,java.lang.String> getLinks()
Gets a links object containing the following members: about: a link that leads to further details about this particular occurrence of the problem.- Returns:
- will never be null.
-
getStatus
public java.lang.String getStatus()
Gets the the HTTP status code applicable to this problem, expressed as a string value.- Returns:
- will never be null.
-
withStatus
public JsonApiError withStatus(java.lang.String status)
Adds the HTTP status code applicable to this problem, expressed as a string value.- Parameters:
status
- the HTTP status code.- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
getCode
public java.lang.String getCode()
Gets an application-specific error code, expressed as a string value.- Returns:
- will never be null.
-
withCode
public JsonApiError withCode(java.lang.String code)
Sets an application-specific error code, expressed as a string value.- Parameters:
code
- code of the error.- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
getTitle
public java.lang.String getTitle()
Gets a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.- Returns:
- will never be null.
-
withTitle
public JsonApiError withTitle(java.lang.String title)
Sets a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.- Parameters:
title
- title of the error.- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
getDetail
public java.lang.String getDetail()
Gets a human-readable explanation specific to this occurrence of the problem. Like title, the value can be localized.- Returns:
- will never be null.
-
withDetail
public JsonApiError withDetail(java.lang.String detail)
Sets a human-readable explanation specific to this occurrence of the problem. Like title, the value can be localized.- Parameters:
detail
- error detail.- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
getSource
public java.util.Map<java.lang.String,java.lang.String> getSource()
Gets an object containing references to the source of the error, optionally including any of the following members: pointer: a JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object, or "/data/attributes/title" for a specific attribute]. parameter: a string indicating which URI query parameter caused the error.- Returns:
- can be null.
-
getMeta
public java.util.Map<java.lang.String,java.lang.Object> getMeta()
Gets a meta object containing non-standard meta-information about the error.- Returns:
- will never be null.
-
withMeta
public JsonApiError withMeta(java.util.Map<java.lang.String,java.lang.Object> meta)
Sets a meta object containing non-standard meta-information about the error.- Parameters:
meta
- meta object added to the error.- Returns:
- a clone of this object, except with this updated property (returns
this
if an identical value is passed).
-
-