Is there a NonNullByDefault annotation for Android Studio

对着背影说爱祢 提交于 2020-01-04 05:37:28

问题


I am really missing @NonNullByDefault from eclipse in Android Studio. Is there a way to get this or something similar? I only saw one using javax's @TypeQualifierDefault, but this seems not to be available in the android project.


回答1:


I have not found a @NonNullByDefault functionality. BUT you can at least let the inspector handle all unannotated members & parameters as if they were annotated as @Nullable. Which will at least help to get 100% null-analyzation coverage. Basically a @NullByDefault.




回答2:


I wrote a gradle script to handle project-wide @NonNullByDefault annotation for Android Studio.

It goes through all the subpackages to check whether package-info.java files are generated inside each of them.

The script is run before each assembleDebug task so that you can force @ParametersAreNonnullByDefault annotation on all java classes in your project.

NonNullByDefault for all java classes inside a project



来源:https://stackoverflow.com/questions/34766657/is-there-a-nonnullbydefault-annotation-for-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!