Right way to use the @NonNull annotation in Android Studio

前端 未结 3 972
甜味超标
甜味超标 2020-12-29 22:20

I\'d like to use the @NonNull annotation in Android, but I can\'t figure out just the right way to do it. I propose you this example:

public voi         


        
3条回答
  •  情深已故
    2020-12-29 22:23

    Google examples do it as follows

    import static com.google.common.base.Preconditions.checkNotNull;
    
    ...
    
    public void doStuff(@NonNull String sParm){
         this.sParm= checkNotNull(s, "sParm cannot be null!");
    }
    

提交回复
热议问题