Class JsonApiError

java.lang.Object
com.toedter.spring.hateoas.jsonapi.JsonApiError

public final class JsonApiError extends Object
Class to build a single JSON:API compliant error. This error can be added to JsonApiErrors.
  • Constructor Details

    • JsonApiError

      public JsonApiError()
      Creates an empty JsonApiError.
  • Method Details

    • withSourcePointer

      public JsonApiError withSourcePointer(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(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(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(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getId

      public String getId()
      Gets a unique identifier for this particular occurrence of the problem.
      Returns:
      will never be null.
    • withId

      public JsonApiError withId(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 Map<String,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 String getStatus()
      Gets the HTTP status code applicable to this problem, expressed as a string value.
      Returns:
      will never be null.
    • withStatus

      public JsonApiError withStatus(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 String getCode()
      Gets an application-specific error code, expressed as a string value.
      Returns:
      will never be null.
    • withCode

      public JsonApiError withCode(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 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(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 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(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 Map<String,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 Map<String,Object> getMeta()
      Gets a meta object containing non-standard meta-information about the error.
      Returns:
      will never be null.
    • withMeta

      public JsonApiError withMeta(Map<String,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).