Interface Problem

    • 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
      • 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)