2014-06-12 26 views
0

我有以下雲端點:谷歌雲端點對象永遠不能爲null

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

我傳遞null作爲Android客戶端上的參數:

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

在後端,將創建一個測試對象,所有字段都爲空。但對象本身不是null。

  • 如何測試對象爲null或防止null傳入API?

我知道我可以使@Name參數@Nullable,但對於對象參數,它看起來像GCE或REST不會按預期重新構造空對象。

回答

0

使用com.google.api.client.util.Data.isNull方法檢查值爲空。