use of org.webpieces.router.api.controller.actions.Redirect in project webpieces by deanhiller.
the class ControllerLoader method htmlPreconditionCheck.
private void htmlPreconditionCheck(Object meta, Method controllerMethod, boolean isPostOnly) {
if (isPostOnly) {
Class<?> clazz = controllerMethod.getReturnType();
if (CompletableFuture.class.isAssignableFrom(clazz)) {
Type genericReturnType = controllerMethod.getGenericReturnType();
ParameterizedType t = (ParameterizedType) genericReturnType;
Type type2 = t.getActualTypeArguments()[0];
if (!(type2 instanceof Class))
throw new IllegalArgumentException("Since this route=" + meta + " is for POST, the method MUST return a type 'Redirect' or 'CompletableFuture<Redirect>' for this method=" + controllerMethod);
@SuppressWarnings("rawtypes") Class<?> type = (Class) type2;
if (!Redirect.class.isAssignableFrom(type))
throw new IllegalArgumentException("Since this route=" + meta + " is for POST, the method MUST return a type 'Redirect' or 'XFuture<Redirect>' not 'XFuture<" + type.getSimpleName() + ">'for this method=" + controllerMethod);
} else if (!Redirect.class.isAssignableFrom(clazz))
throw new IllegalArgumentException("Since this route=" + meta + " is for POST, the method MUST return a type 'Redirect' or 'XFuture<Redirect>' not '" + clazz.getSimpleName() + "' for this method=" + controllerMethod);
} else {
Class<?> clazz = controllerMethod.getReturnType();
if (CompletableFuture.class.isAssignableFrom(clazz)) {
Type genericReturnType = controllerMethod.getGenericReturnType();
ParameterizedType t = (ParameterizedType) genericReturnType;
Type type2 = t.getActualTypeArguments()[0];
if (!(type2 instanceof Class))
throw new IllegalArgumentException("This route=" + meta + " has a method that MUST return a type 'Action' or 'XFuture<Action>' for this method(and did not)=" + controllerMethod);
@SuppressWarnings("rawtypes") Class<?> type = (Class) type2;
if (!Action.class.isAssignableFrom(type))
throw new IllegalArgumentException("This route=" + meta + " has a method that MUST return a type 'Action' or 'XFuture<Action>' not 'XFuture<" + type.getSimpleName() + ">'for this method=" + controllerMethod);
} else if (!Action.class.isAssignableFrom(clazz))
throw new IllegalArgumentException("This route=" + meta + " has a method that MUST return a type 'Action' or 'XFuture<Action>' not '" + clazz.getSimpleName() + "' for this method=" + controllerMethod);
}
}
Aggregations