io.vrap.rmf.base.client.SerializerOnlyApiHttpClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rmf-java-base Show documentation
Show all versions of rmf-java-base Show documentation
The e-commerce SDK from commercetools Composable Commerce for Java
package io.vrap.rmf.base.client;
import java.net.URI;
import java.util.concurrent.CompletableFuture;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* Implementation of a non executable {@link ApiHttpClient}
*/
public class SerializerOnlyApiHttpClient implements ApiHttpClient {
public static final String NO_EXECUTABLE_API_CLIENT = "No executable api client";
private final ResponseSerializer serializer;
private SerializerOnlyApiHttpClient(ResponseSerializer serializer) {
this.serializer = serializer;
}
public static SerializerOnlyApiHttpClient of() {
return new SerializerOnlyApiHttpClient(ResponseSerializer.of());
}
public static SerializerOnlyApiHttpClient of(ObjectMapper objectMapper) {
return new SerializerOnlyApiHttpClient(ResponseSerializer.of(objectMapper));
}
public static SerializerOnlyApiHttpClient of(ResponseSerializer serializer) {
return new SerializerOnlyApiHttpClient(serializer);
}
@Override
public ResponseSerializer getSerializerService() {
return serializer;
}
@Override
public CompletableFuture> execute(ApiHttpRequest request) {
throw new IllegalStateException(NO_EXECUTABLE_API_CLIENT);
}
@Override
public URI getBaseUri() {
return null;
}
@Override
public void close() throws Exception {
}
}