TJ-Bot icon indicating copy to clipboard operation
TJ-Bot copied to clipboard

Add @MethodsReturnNonnullByDefault

Open Zabuzard opened this issue 3 years ago • 0 comments

Similar to #541 , we should take the next step and make our methods also return @Nonnull by default. Fortunately, this is fairly simple with a custom annotation:

@Nonnull
@TypeQualifierDefault({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface MethodsReturnNonnullByDefault {
}

(credits go to Minecraft where I snacked this annotation from - kudos to Quinteger#4169 who raised awareness)

The annotation then goes into all package-info.java just like seen in #541 . In the same wave, we should go through the code base and eliminate all explicit @Nonnull, hurray 🙌


If there is an actual dependency introducing this type already, we should use it instead of "reinventing the wheel".

Zabuzard avatar Aug 29 '22 08:08 Zabuzard