io.keen.client.java.http.Response Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of keen-client-java-core Show documentation
Show all versions of keen-client-java-core Show documentation
Java Client Core Library for Keen
package io.keen.client.java.http;
/**
* Encapsulates an HTTP response.
*
* @author Kevin Litwack ([email protected])
* @since 2.0.0
*/
public final class Response {
///// PROPERTIES /////
public final int statusCode;
public final String body;
///// PUBLIC CONSTRUCTORS /////
public Response(int statusCode, String body) {
this.statusCode = statusCode;
this.body = body;
}
///// PUBLIC METHODS /////
public boolean isSuccess() {
return isSuccessCode(statusCode);
}
///// PRIVATE STATIC METHODS /////
/**
* Checks whether an HTTP status code indicates success.
*
* @param statusCode The HTTP status code.
* @return {@code true} if the status code indicates success (2xx), otherwise {@code false}.
*/
private static boolean isSuccessCode(int statusCode) {
return (statusCode / 100 == 2);
}
}