/** Examine a RequestContext method to see if it returns a transportable type. */ private boolean validateContextMethodAndSetDataType( RequestMethod.Builder methodBuilder, JMethod method, boolean allowSetters) throws UnableToCompleteException { JClassType requestReturnType = method.getReturnType().isInterface(); JClassType invocationReturnType; if (requestReturnType == null) { // Primitive return type poison(badContextReturnType(method, requestInterface, instanceRequestInterface)); return false; } if (instanceRequestInterface.isAssignableFrom(requestReturnType)) { // Instance method invocation JClassType[] params = ModelUtils.findParameterizationOf(instanceRequestInterface, requestReturnType); methodBuilder.setInstanceType(getEntityProxyType(params[0])); invocationReturnType = params[1]; } else if (requestInterface.isAssignableFrom(requestReturnType)) { // Static method invocation JClassType[] params = ModelUtils.findParameterizationOf(requestInterface, requestReturnType); invocationReturnType = params[0]; } else { // Unhandled return type, must be something random poison(badContextReturnType(method, requestInterface, instanceRequestInterface)); return false; } // Validate the parameters boolean paramsOk = true; JParameter[] params = method.getParameters(); for (int i = 0; i < params.length; ++i) { JParameter param = params[i]; paramsOk = validateTransportableType(new RequestMethod.Builder(), param.getType(), false) && paramsOk; } // Validate any extra properties on the request type for (JMethod maybeSetter : requestReturnType.getInheritableMethods()) { if (JBeanMethod.SET.matches(maybeSetter) || JBeanMethod.SET_BUILDER.matches(maybeSetter)) { if (allowSetters) { methodBuilder.addExtraSetter(maybeSetter); } else { poison(noSettersAllowed(maybeSetter)); } } } return validateTransportableType(methodBuilder, invocationReturnType, true); }