Class ProxiedResource.NodeResponse<ResponseType>

java.lang.Object
org.graylog2.shared.rest.resources.ProxiedResource.NodeResponse<ResponseType>
Enclosing class:
ProxiedResource

public abstract static class ProxiedResource.NodeResponse<ResponseType> extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Convenience method that returns either the body of a successful request or if that one is null, it returns the error body.
    abstract int
    Returns the HTTP status code of the response.
    static <ResponseType>
    ProxiedResource.NodeResponse<ResponseType>
    create(boolean isSuccess, int code, ResponseType entity, byte[] error)
     
    Returns the typed response object if the request was successful.
    abstract Optional<byte[]>
    Returns the error response if the request wasn't successful.
     
    abstract boolean
    Indicates whether the request has been successful or not.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NodeResponse

      public NodeResponse()
  • Method Details

    • isSuccess

      public abstract boolean isSuccess()
      Indicates whether the request has been successful or not.
      Returns:
      true for a successful request, false otherwise
    • code

      public abstract int code()
      Returns the HTTP status code of the response.
      Returns:
      HTTP status code
    • entity

      public abstract Optional<ResponseType> entity()
      Returns the typed response object if the request was successful. Otherwise it returns an empty Optional.
      Returns:
      typed response object or empty Optional
    • error

      public abstract Optional<byte[]> error()
      Returns the error response if the request wasn't successful. Otherwise it returns an empty Optional.
      Returns:
      error response or empty Optional
    • body

      public Object body()
      Convenience method that returns either the body of a successful request or if that one is null, it returns the error body.

      Use entity() the get the typed response object. (only available if isSuccess() is true)

      Returns:
      either the entity() or the error()
    • errorText

      @Nullable public String errorText()
    • create

      public static <ResponseType> ProxiedResource.NodeResponse<ResponseType> create(boolean isSuccess, int code, @Nullable ResponseType entity, @Nullable byte[] error)