Google Cloud Endpoints Object绝不是空的

时间:2014-06-12 22:15:20

标签: rest google-cloud-endpoints

我有以下云端点:

@ApiMethod(name = "test.insert")
public Test insertTest(final Test test)
{
// test is Test here, but not null
}

我在Android客户端上传递null作为参数:

api.test().insert(null).execute();

在后端,创建一个Test对象,其中所有字段都为null。但是对象本身并不是空的。

  • 如何测试对象的null或阻止将null传递给API?

我知道我可以创建@Named参数@Nullable,但对于object参数,它看起来像GCE或REST不会按预期重建空对象。

1 个答案:

答案 0 :(得分:0)

使用com.google.api.client.util.Data.isNull方法检查值是否为空。