2017-12-15 9 views
0

코드가 있지만 컴파일러에서 accounts != null 부분을 메서드 참조로 바꿉니다. 내가 어떻게 해? 아마 다른 가능성은메서드 참조로 바꿀 수 있습니다

mMainApi.accounts(user, password) 
      .filter(accounts -> accounts != null) 
      .map(/* Something here */) 
      .subscribe(); 

내가 찾은 하나 개의 솔루션이 .filter(Objects::nonNull)를 사용하는 것을 확인할 수있다하지만이 솔루션은 안드로이드 API> (24)를 필요하므로이 실제로 도움이되지 않습니다.

답변

0

당신이 코드 아래에 시도 할 수 있습니다

mMainApi.accounts(user, password) 
      .filter(accounts ->{ 
       return accounts!=null; 
      }) 
      .map(/* Something here */) 
      .subscribe();