I want to create a request for JSON-RPC with three parameters - String, Integer and my own object. Request should look like this:
{"method":"MyMethod", "params":["text", 123, {"name": "any text", "num": 15}], "id":1}
Ideally, I would like to create an AutoBean like this (but it does not work):
interface JsonRpcRequest {
String getJsonrpc();
void setJsonrpc(String value);
String getMethod();
void setMethod(String value);
List<Object> getParams(); // ERROR: Type Object may not be used
void setParams(List<Object> params); // ERROR: Type Object may not be used
}
interface JsonRpcRequestFactory extends AutoBeanFactory {
AutoBean<JsonRpcRequest> jsonRpcRequest();
}
The problem is that the AutoBean framework does not allows the use of List<Object>
inside interface.
Is there another way to create a list/array of elements of different based and non-based types?
No, you simply can't. AutoBean requires everything to be statically typed: no polymorphism, and no mixed-typed lists of maps.
You might be interested by RequestFactory's built-in support for JSON-RPC though.