Package org.zalando.problem
Interface Problem
-
- All Known Subinterfaces:
Exceptional
- All Known Implementing Classes:
AbstractThrowableProblem,DefaultProblem,ThrowableProblem
@API(status=STABLE) @Immutable public interface Problem- See Also:
- RFC 7807: Problem Details for HTTP APIs
-
-
Field Summary
Fields Modifier and Type Field Description static URIDEFAULT_TYPE
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description static ProblemBuilderbuilder()default StringgetDetail()A human readable explanation specific to this occurrence of the problem.default URIgetInstance()An absolute URI that identifies the specific occurrence of the problem.default Map<String,Object>getParameters()Optional, additional attributes of the problem.default StatusTypegetStatus()The HTTP status code generated by the origin server for this occurrence of the problem.default StringgetTitle()A short, human-readable summary of the problem type.default URIgetType()An absolute URI that identifies the problem type.static StringtoString(Problem problem)Specification by example:static ThrowableProblemvalueOf(StatusType status)static ThrowableProblemvalueOf(StatusType status, String detail)static ThrowableProblemvalueOf(StatusType status, String detail, URI instance)static ThrowableProblemvalueOf(StatusType status, URI instance)
-
-
-
Field Detail
-
DEFAULT_TYPE
static final URI DEFAULT_TYPE
-
-
Method Detail
-
getType
default URI getType()
An absolute URI that identifies the problem type. When dereferenced, it SHOULD provide human-readable documentation for the problem type (e.g., using HTML). When this member is not present, its value is assumed to be "about:blank".- Returns:
- an absolute URI that identifies this problem's type
-
getTitle
@Nullable default String getTitle()
A short, human-readable summary of the problem type. It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localisation.- Returns:
- a short, human-readable summary of this problem
-
getStatus
@Nullable default StatusType getStatus()
The HTTP status code generated by the origin server for this occurrence of the problem.- Returns:
- the HTTP status code
-
getDetail
@Nullable default String getDetail()
A human readable explanation specific to this occurrence of the problem.- Returns:
- A human readable explaination of this problem
-
getInstance
@Nullable default URI getInstance()
An absolute URI that identifies the specific occurrence of the problem. It may or may not yield further information if dereferenced.- Returns:
- an absolute URI that identifies this specific problem
-
getParameters
default Map<String,Object> getParameters()
Optional, additional attributes of the problem. Implementations can choose to ignore this in favor of concrete, typed fields.- Returns:
- additional parameters
-
builder
static ProblemBuilder builder()
-
valueOf
static ThrowableProblem valueOf(StatusType status)
-
valueOf
static ThrowableProblem valueOf(StatusType status, String detail)
-
valueOf
static ThrowableProblem valueOf(StatusType status, URI instance)
-
valueOf
static ThrowableProblem valueOf(StatusType status, String detail, URI instance)
-
toString
static String toString(Problem problem)
Specification by example:// Returns "about:blank{404, Not Found}" Problem.valueOf(NOT_FOUND).toString(); // Returns "about:blank{404, Not Found, Order 123}" Problem.valueOf(NOT_FOUND, "Order 123").toString(); // Returns "about:blank{404, Not Found, instance=https://example.org/}" Problem.valueOf(NOT_FOUND, URI.create("https://example.org/")).toString(); // Returns "about:blank{404, Not Found, Order 123, instance=https://example.org/"} Problem.valueOf(NOT_FOUND, "Order 123", URI.create("https://example.org/")).toString(); // Returns "https://example.org/problem{422, Oh, oh!, Crap., instance=https://example.org/problem/123} Problem.builder() .withType(URI.create("https://example.org/problem")) .withTitle("Oh, oh!") .withStatus(UNPROCESSABLE_ENTITY) .withDetail("Crap.") .withInstance(URI.create("https://example.org/problem/123")) .build() .toString();- Parameters:
problem- the problem- Returns:
- a string representation of the problem
- See Also:
valueOf(StatusType),valueOf(StatusType, String),valueOf(StatusType, URI),valueOf(StatusType, String, URI)
-
-