Class JsonApiError
java.lang.Object
com.toedter.spring.hateoas.jsonapi.JsonApiError
Class to build a single JSON:API compliant error.
This error can be added to
JsonApiErrors.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonApiErrorcreate()booleangetCode()Gets an application-specific error code, expressed as a string value.Gets a human-readable explanation specific to this occurrence of the problem.getId()Gets a unique identifier for this particular occurrence of the problem.getLinks()Gets a links object containing the following members: about: a link that leads to further details about this particular occurrence of the problem.getMeta()Gets a meta object containing non-standard meta-information about the error.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.Gets the HTTP status code applicable to this problem, expressed as a string value.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.inthashCode()toString()withAboutLink(String aboutLink) Adds an about link to the error.Sets an application-specific error code, expressed as a string value.withDetail(String detail) Sets a human-readable explanation specific to this occurrence of the problem.Sets a unique identifier for this particular occurrence of the problem.Sets a meta object containing non-standard meta-information about the error.withSourceParameter(String sourceParameter) Adds a source parameter to the error.withSourcePointer(String sourcePointer) Adds a source pointer to the error.withStatus(String status) Adds the HTTP status code applicable to this problem, expressed as a string value.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 Details
-
JsonApiError
public JsonApiError()Creates an emptyJsonApiError.
-
-
Method Details
-
withSourcePointer
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
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
Adds an about link to the error.- Parameters:
aboutLink- the link describing this error- Returns:
- will never be null.
-
create
- Returns:
- Creates an empty
JsonApiError.
-
equals
-
hashCode
public int hashCode() -
toString
-
getId
Gets a unique identifier for this particular occurrence of the problem.- Returns:
- will never be null.
-
withId
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
thisif an identical value is passed).
-
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
Gets the HTTP status code applicable to this problem, expressed as a string value.- Returns:
- will never be null.
-
withStatus
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
thisif an identical value is passed).
-
getCode
Gets an application-specific error code, expressed as a string value.- Returns:
- will never be null.
-
withCode
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
thisif an identical value is passed).
-
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
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
thisif an identical value is passed).
-
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
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
thisif an identical value is passed).
-
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
Gets a meta object containing non-standard meta-information about the error.- Returns:
- will never be null.
-
withMeta
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
thisif an identical value is passed).
-