Class Problem
Represents the canonical application/problem+json document. The five standard members defined by
§3.1 are modelled as typed
properties; arbitrary §3.2
extension members flatten into the top-level JSON object via a @BeanProp("*") triplet.
Example:
Problem
Notes:
- The
typefield is nullable.getType()returns the raw value (possiblynull);getTypeOrDefault()returns the spec default"about:blank"per RFC 7807 §3.1 when the field is unset. The field is never eagerly defaulted, so a freshProblemround-trips without a synthetic"type":"about:blank"on the wire. - RFC 7807 was obsoleted by RFC 9457 in
July 2023, but the data model and the
application/problem+jsonIANA registration are unchanged.
See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGeneric extension-member keyset.static ProblemfromStatus(int status, String title, String detail) Convenience factory for the common "build a problem from a status code + title + detail" call site.Generic extension-member getter.The detail — a human-readable explanation specific to this occurrence of the problem.The instance URI that identifies the specific occurrence of the problem.The status — the HTTP status code originally generated by the origin server for this occurrence.getTitle()The title — a short, human-readable summary of the problem type.getType()The type URI that identifies the problem type.Returns thetypeURI, defaulting toDEFAULT_TYPE("about:blank") per RFC 7807 §3.1 when the field isnull .Generic extension-member setter.Sets thedetail.setInstance(URI value) Sets theinstanceURI.Sets thestatusHTTP status code.Sets thetitle.Sets thetypeURI.
-
Field Details
-
DEFAULT_TYPE
-
-
Constructor Details
-
Problem
public Problem()
-
-
Method Details
-
fromStatus
Convenience factory for the common "build a problem from a status code + title + detail" call site.Populates only the
status,title, anddetailmembers. Callers wire fromThrowables or HTTP exception types themselves — for example:Problem.
fromStatus (e .getStatusCode(),e .getStatusLine().getReasonPhrase(),e .getMessage());- Parameters:
status- The HTTP status code (e.g.404).title- A short, human-readable summary of the problem type. Can benull to leave the title unset.detail- A human-readable explanation specific to this occurrence. Can benull to leave the detail unset.- Returns:
- A new
Problempopulated with the supplied values.
-
getType
The type URI that identifies the problem type.Returns the raw field value, which may be
null when thetypemember is absent. UsegetTypeOrDefault()to get the spec default"about:blank"for absent values.- Returns:
- The
typeURI, ornull if not set.
-
getTypeOrDefault
Returns thetypeURI, defaulting toDEFAULT_TYPE("about:blank") per RFC 7807 §3.1 when the field isnull .The underlying field is left untouched, so this method never causes a synthetic
"type":"about:blank"to appear on the wire.- Returns:
- The
typeURI, nevernull .
-
setType
Sets thetypeURI.- Parameters:
value- The new value. Can benull to unset the property.- Returns:
- This object.
-
getTitle
The title — a short, human-readable summary of the problem type.- Returns:
- The title, or
null if not set.
-
setTitle
Sets thetitle.- Parameters:
value- The new value. Can benull to unset the property.- Returns:
- This object.
-
getStatus
The status — the HTTP status code originally generated by the origin server for this occurrence.Modelled as
Integer(boxed) because RFC 7807 declaresstatusas OPTIONAL.- Returns:
- The status code, or
null if not set.
-
setStatus
Sets thestatusHTTP status code.- Parameters:
value- The new value. Can benull to unset the property.- Returns:
- This object.
-
getDetail
The detail — a human-readable explanation specific to this occurrence of the problem.- Returns:
- The detail, or
null if not set.
-
setDetail
Sets thedetail.- Parameters:
value- The new value. Can benull to unset the property.- Returns:
- This object.
-
getInstance
The instance URI that identifies the specific occurrence of the problem.- Returns:
- The
instanceURI, ornull if not set.
-
setInstance
Sets theinstanceURI.- Parameters:
value- The new value. Can benull to unset the property.- Returns:
- This object.
-
extraKeys
Generic extension-member keyset.- Returns:
- All extension keys on this problem. Never
null .
-
get
Generic extension-member getter.Used by the bean framework to read arbitrary §3.2 extension members that flatten into the top-level JSON object.
- Parameters:
property- The property name to retrieve. Can benull (anull key simply resolves to no value).- Returns:
- The property value, or
null if the property does not exist.
-
set
Generic extension-member setter.Used by the bean framework to set arbitrary §3.2 extension members. The extension map is lazily initialised on first use.
- Parameters:
property- The property name to set. Can benull (LinkedHashMaptolerates anull key).value- The new value for the property. Can benull (stored asnull ).- Returns:
- This object.
-