net.sf.aguacate.http.HttpMethods Maven / Gradle / Ivy
package net.sf.aguacate.http;
public final class HttpMethods {
public static final String M_DELETE = "DELETE";
public static final String M_PUT = "PUT";
public static final String M_POST = "POST";
public static final String M_GET = "GET";
public static final String M_GET0 = "GET0";
public static final String M_PATCH = "PATCH";
private HttpMethods() {
}
public static boolean acceptsBodyRequest(String method) {
switch (method) {
case M_GET:
case M_DELETE:
case M_GET0:
return false;
case M_POST:
case M_PUT:
case M_PATCH:
return true;
default:
throw new IllegalArgumentException(method);
}
}
public static boolean acceptsBodyResponse(String method) {
switch (method) {
case M_GET0:
case M_GET:
case M_POST:
case M_PATCH:
return true;
case M_PUT:
case M_DELETE:
return false;
default:
throw new IllegalArgumentException(method);
}
}
public static boolean acceptsPathParameters(String method) {
switch (method) {
case M_PUT:
return false;
case M_GET:
case M_POST:
case M_DELETE:
case M_PATCH:
return true;
default:
throw new IllegalArgumentException(method);
}
}
public static boolean optionalPathParameters(String method) {
switch (method) {
case M_GET:
return true;
case M_POST:
case M_DELETE:
case M_PATCH:
return false;
case M_PUT:
default:
throw new IllegalArgumentException(method);
}
}
}