View Javadoc

1   package com.atlassian.sal.api.net;
2   
3   /**
4    * Callback interface used by the {@link Request#executeAndReturn(ReturningResponseHandler)}
5    * method. Implementation of this interface performs actual handling of the
6    * response.
7    * <p>
8    * If no result will be produced, then instead of using this class, implement
9    * {@link com.atlassian.sal.api.net.ResponseHandler} and pass it to
10   * {@link Request#execute(ResponseHandler)}.
11   *
12   * @since 2.2
13   */
14  public interface ReturningResponseHandler<T extends Response, R> {
15      /**
16       * Triggered when response from {@link Request#executeAndReturn(ReturningResponseHandler)}
17       * method becomes available. Implementations of this method should handle the response.
18       *
19       * @param response a response object. Never {@code null}.
20       * @return the result produces by this handler.
21       * @throws ResponseException If the response cannot be retrieved
22       */
23      R handle(T response) throws ResponseException;
24  }