Class ApiOptionalResponse<R>

  • Type Parameters:
    R - type of the (optional) response object created from entity
    Direct Known Subclasses:

    public class ApiOptionalResponse<R>
    extends ApiResponse
    A response for requests that may or may not return an entity, such as GET requests that may have a 404 response code.
    • Method Detail

      • apiResponseBuilder

        public static <X,​R> ApiOptionalResponse.Builder<X,​R> apiResponseBuilder()
        A builder to create an optional response. Method name is not builder to allow subclasses to define their own builder methods.
        Type Parameters:
        X - expected entity (such as JsonObject
        R - type of object used to represent the entity
        a new builder
      • entity

        public Optional<R> entity()
        Get the entity if it is present.
        optional with the entity
      • map

        public <U> ApiOptionalResponse<U> map​(Function<R,​U> mapper)
        Map the (possible) response entity to a different type.
        Type Parameters:
        U - new type
        mapper - mapper function
        new optional response with the mapped entity