问题
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