@API(status=STABLE)
public interface Problem
Problem instances are required to be immutable.| Modifier and Type | Field and Description |
|---|---|
static URI |
DEFAULT_TYPE |
| Modifier and Type | Method and Description |
|---|---|
static ProblemBuilder |
builder() |
default @Nullable String |
getDetail()
A human readable explanation specific to this occurrence of the problem.
|
default @Nullable URI |
getInstance()
An absolute URI that identifies the specific occurrence of the problem.
|
default Map<String,Object> |
getParameters()
Optional, additional attributes of the problem.
|
default @Nullable StatusType |
getStatus()
The HTTP status code generated by the origin server for this
occurrence of the problem.
|
default @Nullable String |
getTitle()
A short, human-readable summary of the problem type.
|
default URI |
getType()
An absolute URI that identifies the problem type.
|
static String |
toString(Problem problem)
Specification by example:
|
static ThrowableProblem |
valueOf(StatusType status) |
static ThrowableProblem |
valueOf(StatusType status,
@Nullable String detail) |
static ThrowableProblem |
valueOf(StatusType status,
@Nullable String detail,
@Nullable URI instance) |
static ThrowableProblem |
valueOf(StatusType status,
@Nullable URI instance) |
static final URI DEFAULT_TYPE
default URI getType()
default @Nullable String getTitle()
default @Nullable StatusType getStatus()
default @Nullable String getDetail()
default @Nullable URI getInstance()
default Map<String,Object> getParameters()
static ProblemBuilder builder()
static ThrowableProblem valueOf(StatusType status)
static ThrowableProblem valueOf(StatusType status, @Nullable String detail)
static ThrowableProblem valueOf(StatusType status, @Nullable URI instance)
static ThrowableProblem valueOf(StatusType status, @Nullable String detail, @Nullable URI instance)
static String toString(Problem problem)
// 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();
problem - the problemvalueOf(StatusType),
valueOf(StatusType, String),
valueOf(StatusType, URI),
valueOf(StatusType, String, URI)Copyright © 2015–2021 Zalando SE. All rights reserved.