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

global.maplink.geocode.async.GeocodeAsyncAPI Maven / Gradle / Ivy

There is a newer version: 1.5.14
Show newest version
package global.maplink.geocode.async;

import global.maplink.MapLinkSDK;
import global.maplink.env.Environment;
import global.maplink.geocode.extensions.GeocodeExtensionManager;
import global.maplink.geocode.schema.Type;
import global.maplink.geocode.schema.crossCities.CrossCitiesRequest;
import global.maplink.geocode.schema.reverse.ReverseRequest;
import global.maplink.geocode.schema.structured.StructuredRequest;
import global.maplink.geocode.schema.suggestions.SuggestionsRequest;
import global.maplink.geocode.schema.suggestions.SuggestionsResult;

import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

import static global.maplink.MapLinkServiceRequestAsyncRunner.createRunner;
import static java.util.Arrays.asList;

public interface GeocodeAsyncAPI {

    default CompletableFuture suggestions(String query) {
        return suggestions(SuggestionsRequest.builder().query(query).build());
    }

    default CompletableFuture suggestions(String query, Type type) {
        return suggestions(SuggestionsRequest.builder().query(query).type(type).build());
    }

    CompletableFuture suggestions(SuggestionsRequest request);

    CompletableFuture structured(StructuredRequest request);

    default CompletableFuture reverse(ReverseRequest.Entry... request) {
        return reverse(asList(request));
    }

    default CompletableFuture reverse(List request) {
        return reverse(ReverseRequest.of(request));
    }

    CompletableFuture reverse(ReverseRequest request);

    default CompletableFuture crossCities(CrossCitiesRequest.Point... points) {
        return crossCities(asList(points));
    }

    default CompletableFuture crossCities(List points) {
        return crossCities(CrossCitiesRequest.of(points));
    }

    CompletableFuture crossCities(CrossCitiesRequest request);

    static GeocodeAsyncAPI getInstance() {
        return getInstance(null);
    }

    static GeocodeAsyncAPI getInstance(Environment environment) {
        MapLinkSDK sdk = MapLinkSDK.getInstance();
        return new GeocodeAsyncApiImpl(
                createRunner(
                        Optional.ofNullable(environment).orElse(sdk.getEnvironment()),
                        sdk
                ),
                GeocodeExtensionManager.from(sdk.getExtensions())
        );
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy