[Request] Add @Notnull and @Nullable annotations.
CubeSugarCheese opened this issue ยท 3 comments
I am a kotlin developer.
When I using architectury-api, I found my IDE remind me to declare the type explicitly. I think @Notnull
and @Nullable
annotations are useful.
But I found #216 , it said
Remove All
@NotNull
I want to know why. I think those annotations are useful. So why not add those to code?
From a Java perspective, NotNull
is purely spam since we typically assume a type is only null if it's Nullable
. It's extra work for not much benefit (note that even in Kotlin, you can assume that !
types aren't null).
It was also done inconsistently in Arch code - we didn't have it everywhere where it should've been.
Yep, architectury code is just annotated with @nullable where applicable now, you can assume that types without nullable is not nullable
Like Juuz said, it is usually safe to assume a Java platform type T!
is not null within both Architectury and Minecraft code unless it is explicitly annotated as @Nullable
(in which case Kotlin will correctly pick that up anyways)
We will likely not be adding explicit NotNull annotations everywhere, considering it's mostly just ... visual clutter within the source code and because of the convention mentioned above applying on the Java side as well