com.jslsolucoes.jax.rs.client.se.api.impl.DefaultJaxRsApiClientRequest Maven / Gradle / Ivy
package com.jslsolucoes.jax.rs.client.se.api.impl;
import java.util.Map;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.core.MultivaluedHashMap;
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 Builder builder;
private JaxRsApiClient jaxRsApiClient;
private Integer retryAttempts = 3;
private Integer retryDelay = 3000;
public DefaultJaxRsApiClientRequest(JaxRsApiClient jaxRsApiClient,Builder builder) {
this.jaxRsApiClient = jaxRsApiClient;
this.builder = builder;
}
@Override
public JaxRsApiClientRequest accept(String mediaType) {
return new DefaultJaxRsApiClientRequest(jaxRsApiClient,builder.accept(mediaType));
}
@Override
public JaxRsApiClientRequest header(String name, Object value) {
return new DefaultJaxRsApiClientRequest(jaxRsApiClient,builder.header(name, value));
}
@Override
public JaxRsApiClientRequest headers(Map headers) {
return new DefaultJaxRsApiClientRequest(jaxRsApiClient,builder.headers(new MultivaluedHashMap<>(headers)));
}
@Override
public JaxRsApiClientRequestAsync async() {
return new DefaultJaxRsApiClientRequestAsync(jaxRsApiClient,builder);
}
@Override
public JaxRsApiClientResponse get() {
return async().retryAttempts(retryAttempts).retryDelay(retryDelay).get().join();
}
@Override
public JaxRsApiClientResponse delete() {
return async().retryAttempts(retryAttempts).retryDelay(retryDelay).delete().join();
}
@Override
public JaxRsApiClientResponse post(Entity> entity) {
return async().retryAttempts(retryAttempts).retryDelay(retryDelay).post(entity).join();
}
@Override
public JaxRsApiClientResponse put(Entity> entity) {
return async().retryAttempts(retryAttempts).retryDelay(retryDelay).put(entity).join();
}
@Override
public JaxRsApiClientResponse post(Object object) {
return async().retryAttempts(retryAttempts).retryDelay(retryDelay).post(object).join();
}
@Override
public JaxRsApiClientResponse put(Object object) {
return async().retryAttempts(retryAttempts).retryDelay(retryDelay).put(object).join();
}
@Override
public JaxRsApiClientRequest retryAttempts(Integer retryAttempts) {
this.retryAttempts = retryAttempts;
return this;
}
@Override
public JaxRsApiClientRequest retryDelay(Integer retryDelay) {
this.retryDelay = retryDelay;
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy