* Only support extra properties in JSON-RPC payloads. Could add this to
* standard requests to provide out-of-band data.
*/
if (method.getDialect().equals(Dialect.JSON_RPC)) {
for (JMethod setter : request.getExtraSetters()) {
PropertyName propertyNameAnnotation = setter.getAnnotation(PropertyName.class);
String propertyName = propertyNameAnnotation == null
? JBeanMethod.SET.inferName(setter)
: propertyNameAnnotation.value();
String maybeReturn = JBeanMethod.SET_BUILDER.matches(setter)
? "return this;" : "";
sw.println(
"%s { getRequestData().setNamedParameter(\"%s\", %s); %s}",
setter.getReadableDeclaration(false, false, false, false, true),
propertyName, setter.getParameters()[0].getName(), maybeReturn);
}
}
// end class X{}
sw.outdent();
sw.println("}");
// Instantiate, enqueue, and return
sw.println("X x = new X();");
if (request.getApiVersion() != null) {
sw.println("x.getRequestData().setApiVersion(\"%s\");",
Generator.escape(request.getApiVersion()));
}
// JSON-RPC payloads send their parameters in a by-name fashion
if (method.getDialect().equals(Dialect.JSON_RPC)) {
for (JParameter param : jmethod.getParameters()) {
PropertyName annotation = param.getAnnotation(PropertyName.class);
String propertyName = annotation == null ? param.getName()
: annotation.value();
boolean isContent = param.isAnnotationPresent(JsonRpcContent.class);
if (isContent) {
sw.println("x.getRequestData().setRequestContent(%s);",
param.getName());
} else {