All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
io.github.saoxuequ.http.request.smooth.builder.InvokerFactory Maven / Gradle / Ivy
package io.github.saoxuequ.http.request.smooth.builder;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import io.github.saoxuequ.http.request.core.HttpExecutor;
import io.github.saoxuequ.http.request.light.reader.FileResponse;
import io.github.saoxuequ.http.request.light.reader.FixedFileResponse;
import io.github.saoxuequ.http.request.light.reader.JsonObjectResponse;
import io.github.saoxuequ.http.request.light.reader.JsonResponse;
import io.github.saoxuequ.http.request.light.reader.StringResponse;
import io.github.saoxuequ.http.request.light.reader.TypedJsonResponse;
import io.github.saoxuequ.http.request.smooth.CookieProvider;
import io.github.saoxuequ.http.request.smooth.Invoker;
import io.github.saoxuequ.http.request.utils.UriTemplate;
import java.io.File;
public class InvokerFactory {
private final HttpExecutor httpExecutor;
private final CookieProvider cookieProvider;
private final String method;
private final UriTemplate urlTemplate;
public InvokerFactory(HttpExecutor httpExecutor,
CookieProvider cookieProvider,
String method, UriTemplate urlTemplate) {
this.httpExecutor = httpExecutor;
this.cookieProvider = cookieProvider;
this.method = method;
this.urlTemplate = urlTemplate;
}
public Invoker forString() {
return new Invoker<>(httpExecutor, cookieProvider, method, urlTemplate, new StringResponse());
}
public Invoker forJson(Class type) {
return new Invoker<>(httpExecutor, cookieProvider, method, urlTemplate, new JsonResponse<>(type));
}
public Invoker forJson(TypeReference type) {
return new Invoker<>(httpExecutor, cookieProvider, method, urlTemplate, new TypedJsonResponse<>(type));
}
public Invoker forJson() {
return new Invoker<>(httpExecutor, cookieProvider, method, urlTemplate, new JsonObjectResponse());
}
public Invoker forJsonArray() {
return new Invoker<>(httpExecutor, cookieProvider, method, urlTemplate, new JsonObjectResponse());
}
public Invoker forFile() {
return new Invoker<>(httpExecutor, cookieProvider, method, urlTemplate, new FileResponse());
}
public Invoker forFile(String path) {
return new Invoker<>(httpExecutor, cookieProvider, method, urlTemplate, new FixedFileResponse(path));
}
}