uk.co.mruoc.camunda.client.ResponseConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of camunda-rest-client Show documentation
Show all versions of camunda-rest-client Show documentation
Template repo to speed up creating new library projects
package uk.co.mruoc.camunda.client;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import uk.co.mruoc.json.JsonConverter;
import java.net.http.HttpResponse;
@Slf4j
@RequiredArgsConstructor
public class ResponseConverter {
private final JsonConverter jsonConverter;
public T toTypeOrThrowError(HttpResponse response, Class type) {
String body = response.body();
if (isSuccessful(response)) {
log.info(body);
return jsonConverter.toObject(body, type);
}
throw new CamundaClientException(body);
}
private boolean isSuccessful(HttpResponse response) {
var status = response.statusCode();
return status >= 200 && status <= 299;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy