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

com.route4me.sdk.RequestMethod Maven / Gradle / Ivy

Go to download

>This SDK makes it easier for you use the Route4Me API, which creates optimally sequenced driving routes for many drivers.

There is a newer version: 1.15.0
Show newest version
package com.route4me.sdk;

import com.route4me.sdk.http.HttpDeleteWithBody;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpRequestBase;

public enum RequestMethod {

    GET(HttpGet.class), POST(HttpPost.class), DELETE(HttpDeleteWithBody.class), PUT(HttpPut.class);

    private final Class clazz;

    RequestMethod(Class clazz) {
        this.clazz = clazz;
    }

    public HttpRequestBase create(URI uri) {
        try {
            return this.clazz.getConstructor(URI.class).newInstance(uri);
        } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
            //(almost) unreachable path
            throw new RuntimeException(ex);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy