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

com.jslsolucoes.jax.rs.client.se.api.impl.DefaultJaxRsApiClientRequest Maven / Gradle / Ivy

There is a newer version: 1.0.32
Show newest version
package com.jslsolucoes.jax.rs.client.se.api.impl;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;

import com.jslsolucoes.jax.rs.client.se.api.JaxRsApiClient;
import com.jslsolucoes.jax.rs.client.se.api.JaxRsApiClientRequest;
import com.jslsolucoes.jax.rs.client.se.api.JaxRsApiClientRequestAsync;
import com.jslsolucoes.jax.rs.client.se.api.JaxRsApiClientResponse;

public class DefaultJaxRsApiClientRequest implements JaxRsApiClientRequest {

    private Set accepts = new HashSet<>();
    private Map headers = new HashMap();
    private Integer retryAttempts = 3;
    private Integer retryDelay = 3000;
    private WebTarget webTarget;
    private JaxRsApiClient jaxRsApiClient;

    public DefaultJaxRsApiClientRequest(JaxRsApiClient jaxRsApiClient,WebTarget webTarget) {
	this.jaxRsApiClient = jaxRsApiClient;
	this.webTarget = webTarget;
    }

    @Override
    public DefaultJaxRsApiClientRequest accept(String mediaType) {
	this.accepts.add(mediaType);
	return this;
    }

    @Override
    public DefaultJaxRsApiClientRequest header(String name,Object value) {
	this.headers.put(name, value);
	return this;
    }

    @Override
    public DefaultJaxRsApiClientRequest headers(Map headers) {
	this.headers.putAll(headers);
	return this;
    }

    @Override
    public JaxRsApiClientResponse post(Object object) {
	return async().post(object).join();
    }

    @Override
    public JaxRsApiClientResponse put(Object object) {
	return async().put(object).join();
    }

    @Override
    public JaxRsApiClientResponse get() {
	return async().get().join();
    }
    
    @Override
    public JaxRsApiClientResponse delete() {
	return async().delete().join();
    }

    @Override
    public JaxRsApiClientResponse post(Entity entity) {
	return async().post(entity).join();
    }

    @Override
    public JaxRsApiClientResponse put(Entity entity) {
	return async().put(entity).join();
    }

    @Override
    public JaxRsApiClientRequest retryAttempts(Integer retryAttempts) {
	this.retryAttempts = retryAttempts;
	return this;
    }

    @Override
    public JaxRsApiClientRequest retryDelay(Integer retryDelay) {
	this.retryDelay = retryDelay;
	return this;
    }

    @Override
    public JaxRsApiClientRequestAsync async() {
	return new DefaultJaxRsApiClientRequestAsync(jaxRsApiClient, webTarget, accepts, headers, retryAttempts, retryDelay);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy