What does using @NonNull on a void method do?

What's the point in Lombok annotation @NonNull for a method?

class MyClass {
    @NonNull
    void run() {
        // code here
    }
}

Are we check the instance of class MyClass (MyClass obj == null)?

Jon Skeet
people
quotationmark

For a void method, there's no point.

For a method with a return type, it shows that it won't return null:

@NonNull String foo() {
    // I promise I won't return null herre!
}

Judging by the tutorial, it looks like it won't generate a check within the method to ensure that it isn't null, but it tells any caller that they can realistically expect a non-null value to be returned.

people

See more on this question at Stackoverflow