Can I return a generic in Google Cloud End Point

2020-07-18 05:45发布

问题:

When I return a generic the end point api file seems to disappear. Sample code is pasted.

@ApiMethod
public RestResponse<Container> testGeneric() {
    Container container = new Container();

    container.testLong =  (long)4345;
    container.testDate = new Date();
    container.testString = "sathya";
    container.testDouble = 123.98;
    container.testInt = 123;

    RestResponse<Container> response = new RestResponse<Container>();
    response.t = container;

    return response;        
}

Is this a bug in endpoint and is such a thing not allowed at all ?

Regards, Sathya

回答1:

I don't think it's a bug, but it's just not supported, in the same way that you can't return a String form your Endpoint...

In order to check what's the problem, if you're using the Google Plugin for Eclipse, you can look at the error log under Window -> Show View -> Error Log to get more info.