final NewConcreteType client) {
Checker.notNull("parameter:method", method);
Checker.notNull("parameter:asyncServiceInterface", asyncServiceInterface);
Checker.notNull("parameter:remoteJsonClient", client);
final GeneratorContext context = this.getGeneratorContext();
final String methodName = method.getName();
// build up a list of the parameter types for the async method...
final List<Type> asyncMethodParameters = new ArrayList<Type>();
final Iterator<MethodParameter> serviceMethodParameters = method.getParameters().iterator();
while (serviceMethodParameters.hasNext()) {
final MethodParameter methodParameter = serviceMethodParameters.next();
asyncMethodParameters.add(methodParameter.getType());
}
asyncMethodParameters.add(this.getAsyncCallback());
// make sure that a method with the same signature actually exists on
// the async interface...
Method asyncMethod = asyncServiceInterface.findMostDerivedMethod(methodName, asyncMethodParameters);
if (null == asyncMethod) {
this.throwMatchingAsyncInterfaceMethodNotFoundException(method);
}
if (false == asyncMethod.returnsVoid()) {
this.throwIncompatibleMethodFound(asyncMethod);
}
context.debug("Found matching async interface method: " + asyncMethod);
// create the method on client...
final NewMethod newMethod = asyncMethod.copy(client);
newMethod.setAbstract(false);
newMethod.setFinal(true);
// rename all parameters to parameterN
GeneratorHelper.renameParametersToParameterN(newMethod);
// the last parameter must be called "callback"
final List parameters = newMethod.getParameters();
final NewMethodParameter callback = (NewMethodParameter) parameters.get(parameters.size() - 1);
callback.setName(Constants.CALLBACK_PARAMETER);
context.debug("Finishing renaming parameters, parameters: " + parameters);
return newMethod;
}