Interface ApiResponseBuilder


  • @ProviderType
    public interface ApiResponseBuilder
    An interface for creating ApiResponse instances. To create an ApiResponseBuilder instance use ApiResponseBuilderFactory.createBuilder()
    • Method Detail

      • setStatus

        ApiResponseBuilder setStatus​(java.lang.Integer code,
                                     java.lang.String message)
        Set the HTTP status
        Parameters:
        code - The status code
        message - The status message
        Returns:
        This ApiResponseBuilder instance
      • withHeader

        ApiResponseBuilder withHeader​(java.lang.String key,
                                      java.lang.String value)
        Set an HTTP header to be used in the response. If a header with this key already exists it will be replaced with the value specified in this method.
        Parameters:
        key - The HTTP header name
        value - The HTTP header value
        Returns:
        This ApiResponseBuilder instance
      • withHeader

        ApiResponseBuilder withHeader​(java.lang.String key,
                                      java.lang.String[] values)
        Set an HTTP header with multiple values. If a header with this key already exists it will be replaced with the values specified in this method.
        Parameters:
        key - The HTTP header name
        values - The HTTP header values
        Returns:
        This ApiResponseBuilder instance
      • setEntity

        ApiResponseBuilder setEntity​(Resource entity)
        Set an entity to be used as the response body. The entity must be a Resource that can be interpreted by the HTTP API Framework
        Parameters:
        entity - A resource to be used as the entity
        Returns:
        This ApiResponseBuilder instance
      • setBody

        ApiResponseBuilder setBody​(java.lang.Object body)
        Set the body to be returned in the response. The body must be an instance of CharSequence or a byte[]
        Parameters:
        body - An instance of CharSequence or a byte[] to be used in the body of the response.
        Returns:
        This ApiResponseBuilder instance
      • setContentType

        ApiResponseBuilder setContentType​(java.lang.String contentType)
        Set the content type of the body.
        Parameters:
        contentType - The content type.
        Returns:
        This ApiResponseBuilder instance.
      • withChange

        ApiResponseBuilder withChange​(Modification modification)
        Add a Modification to be returned in the changes section of the response.
        Parameters:
        modification - The Modification to be added.
        Returns:
        This ApiResponseBuilder
      • build

        ApiResponse build()
        Build the ApiResponse instance with the values specified in this ApiRespoonseBuilder.
        Returns:
        The ApiResponse instance