All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vrap.rmf.base.client.SerializerOnlyApiHttpClient Maven / Gradle / Ivy

There is a newer version: 17.17.0
Show newest version

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 {

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy