|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2024 the original author or authors. |
|
|
|
|
* Copyright 2002-2025 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -649,8 +649,8 @@ public interface RestClient {
@@ -649,8 +649,8 @@ public interface RestClient {
|
|
|
|
|
ResponseSpec retrieve(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Exchange the {@link ClientHttpResponse} for a type {@code T}. This |
|
|
|
|
* can be useful for advanced scenarios, for example to decode the |
|
|
|
|
* Exchange the {@link ClientHttpResponse} for a value of type {@code T}. |
|
|
|
|
* This can be useful for advanced scenarios, for example to decode the |
|
|
|
|
* response differently depending on the response status: |
|
|
|
|
* <pre class="code"> |
|
|
|
|
* Person person = client.get() |
|
|
|
|
@ -670,7 +670,7 @@ public interface RestClient {
@@ -670,7 +670,7 @@ public interface RestClient {
|
|
|
|
|
* function has been invoked. |
|
|
|
|
* @param exchangeFunction the function to handle the response with |
|
|
|
|
* @param <T> the type the response will be transformed to |
|
|
|
|
* @return the value returned from the exchange function |
|
|
|
|
* @return the value returned from the exchange function, potentially {@code null} |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
|
default <T> T exchange(ExchangeFunction<T> exchangeFunction) { |
|
|
|
|
@ -678,8 +678,8 @@ public interface RestClient {
@@ -678,8 +678,8 @@ public interface RestClient {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Exchange the {@link ClientHttpResponse} for a type {@code T}. This |
|
|
|
|
* can be useful for advanced scenarios, for example to decode the |
|
|
|
|
* Exchange the {@link ClientHttpResponse} for a value of type {@code T}. |
|
|
|
|
* This can be useful for advanced scenarios, for example to decode the |
|
|
|
|
* response differently depending on the response status: |
|
|
|
|
* <pre class="code"> |
|
|
|
|
* Person person = client.get() |
|
|
|
|
@ -702,7 +702,7 @@ public interface RestClient {
@@ -702,7 +702,7 @@ public interface RestClient {
|
|
|
|
|
* @param close {@code true} to close the response after |
|
|
|
|
* {@code exchangeFunction} is invoked, {@code false} to keep it open |
|
|
|
|
* @param <T> the type the response will be transformed to |
|
|
|
|
* @return the value returned from the exchange function |
|
|
|
|
* @return the value returned from the exchange function, potentially {@code null} |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
|
<T> T exchange(ExchangeFunction<T> exchangeFunction, boolean close); |
|
|
|
|
@ -716,10 +716,10 @@ public interface RestClient {
@@ -716,10 +716,10 @@ public interface RestClient {
|
|
|
|
|
interface ExchangeFunction<T> { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Exchange the given response into a type {@code T}. |
|
|
|
|
* Exchange the given response into a value of type {@code T}. |
|
|
|
|
* @param clientRequest the request |
|
|
|
|
* @param clientResponse the response |
|
|
|
|
* @return the exchanged type |
|
|
|
|
* @return the exchanged value, potentially {@code null} |
|
|
|
|
* @throws IOException in case of I/O errors |
|
|
|
|
*/ |
|
|
|
|
@Nullable |
|
|
|
|
|