use of com.tvd12.ezyfox.reflect.EzyClassTree in project ezyfox-server by youngmonkeys.
the class EzyExceptionHandlerImplementer method makeHandleExceptionMethodContent.
protected String makeHandleExceptionMethodContent() {
EzyMethod method = getHandleExceptionMethod();
EzyFunction function = new EzyFunction(method).throwsException();
EzyBody body = function.body();
Class<?>[] exceptionClasses = handlerMethod.getExceptionClasses();
EzyClassTree exceptionTree = new EzyClassTree(exceptionClasses);
for (Class<?> exceptionClass : exceptionTree.toList()) {
EzyInstruction instructionIf = new EzyInstruction("\t", "\n", false).append("if(arg4 instanceof ").append(exceptionClass.getName()).append(") {");
body.append(instructionIf);
EzyInstruction instructionHandle = new EzyInstruction("\t\t", "\n");
instructionHandle.append("this.exceptionHandler.").append(handlerMethod.getName()).bracketopen();
appendHandleExceptionMethodArguments(instructionHandle, exceptionClass);
instructionHandle.bracketclose();
body.append(instructionHandle);
body.append(new EzyInstruction("\t", "\n", false).append("}"));
}
body.append(new EzyInstruction("\t", "\n", false).append("else {"));
body.append(new EzyInstruction("\t\t", "\n").append("throw arg4"));
body.append(new EzyInstruction("\t", "\n", false).append("}"));
return function.toString();
}
use of com.tvd12.ezyfox.reflect.EzyClassTree in project ezyhttp by youngmonkeys.
the class ExceptionHandlerImplementer method makeHandleExceptionMethodContent.
protected String makeHandleExceptionMethodContent() {
EzyMethod method = getHandleExceptionMethod();
EzyFunction function = new EzyFunction(method);
EzyBody body = function.body();
Class<?>[] exceptionClasses = handlerMethod.getExceptionClasses();
EzyClassTree exceptionTree = new EzyClassTree(exceptionClasses);
for (Class<?> exceptionClass : exceptionTree.toList()) {
EzyInstruction instructionIf = new EzyInstruction("\t", "\n", false).append("if (arg1 instanceof ").append(exceptionClass.getName()).append(") {");
body.append(instructionIf);
EzyInstruction instructionHandle = new EzyInstruction("\t\t", "\n");
Class<?> returnType = handlerMethod.getReturnType();
if (returnType != void.class) {
instructionHandle.answer();
}
instructionHandle.append("this.exceptionHandler.").append(handlerMethod.getName()).bracketopen();
appendHandleExceptionMethodArguments(handlerMethod, instructionHandle, exceptionClass);
instructionHandle.bracketclose();
body.append(instructionHandle);
if (returnType == void.class) {
body.append(new EzyInstruction("\t\t", "\n").append("return null"));
}
body.append(new EzyInstruction("\t", "\n", false).append("}"));
}
body.append(new EzyInstruction("\t", "\n").append("throw arg1"));
return toThrowExceptionFunction(method, function);
}
use of com.tvd12.ezyfox.reflect.EzyClassTree in project ezyhttp by youngmonkeys.
the class RequestHandlerImplementer method makeHandleExceptionMethodContent.
protected String makeHandleExceptionMethodContent() {
EzyMethod method = getHandleExceptionMethod();
EzyFunction function = new EzyFunction(method).throwsException();
EzyBody body = function.body();
Map<Class<?>, ExceptionHandlerMethod> exceptionHandlerMethodMap = controller.getExceptionHandlerMethodMap();
Set<Class<?>> exceptionClasses = exceptionHandlerMethodMap.keySet();
EzyClassTree exceptionTree = new EzyClassTree(exceptionClasses);
for (Class<?> exceptionClass : exceptionTree.toList()) {
ExceptionHandlerMethod m = exceptionHandlerMethodMap.get(exceptionClass);
EzyInstruction instructionIf = new EzyInstruction("\t", "\n", false).append("if (arg1 instanceof ").append(exceptionClass.getName()).append(") {");
body.append(instructionIf);
EzyInstruction instructionHandle = new EzyInstruction("\t\t", "\n");
Class<?> returnType = m.getReturnType();
if (returnType != void.class) {
instructionHandle.answer();
}
instructionHandle.append("this.controller.").append(m.getName()).bracketopen();
appendHandleExceptionMethodArguments(m, instructionHandle, exceptionClass);
instructionHandle.bracketclose();
body.append(instructionHandle);
if (returnType == void.class) {
body.append(new EzyInstruction("\t\t", "\n").append("return null"));
}
body.append(new EzyInstruction("\t", "\n", false).append("}"));
}
body.append(new EzyInstruction("\t", "\n").append("throw arg1"));
return function.toString();
}
use of com.tvd12.ezyfox.reflect.EzyClassTree in project ezyfox-server by youngmonkeys.
the class EzyRequestHandlerImplementer method makeHandleExceptionMethodContent.
protected String makeHandleExceptionMethodContent() {
EzyMethod method = getHandleExceptionMethod();
EzyFunction function = new EzyFunction(method).throwsException();
EzyBody body = function.body();
Map<Class<?>, EzyExceptionHandlerMethod> exceptionHandlerMethodMap = controller.getExceptionHandlerMethodMap();
Set<Class<?>> exceptionClasses = exceptionHandlerMethodMap.keySet();
EzyClassTree exceptionTree = new EzyClassTree(exceptionClasses);
for (Class<?> exceptionClass : exceptionTree.toList()) {
EzyExceptionHandlerMethod m = exceptionHandlerMethodMap.get(exceptionClass);
EzyInstruction instructionIf = new EzyInstruction("\t", "\n", false).append("if(arg3 instanceof ").append(exceptionClass.getName()).append(") {");
body.append(instructionIf);
EzyInstruction instructionHandle = new EzyInstruction("\t\t", "\n");
instructionHandle.append("this.controller.").append(m.getName()).bracketopen();
appendHandleExceptionMethodArguments(m, instructionHandle, exceptionClass);
instructionHandle.bracketclose();
body.append(instructionHandle);
body.append(new EzyInstruction("\t", "\n", false).append("}"));
}
if (exceptionClasses.size() > 0) {
body.append(new EzyInstruction("\t", "\n", false).append("else {"));
body.append(new EzyInstruction("\t\t", "\n").append("throw arg3"));
body.append(new EzyInstruction("\t", "\n", false).append("}"));
} else {
body.append(new EzyInstruction("\t", "\n").append("throw arg3"));
}
return function.toString();
}
Aggregations