Tagged: @notnull

a wrong hint from netbeans


public class User {

    public void setUsername(final String username) {
        if (this.username != null) {
            throw new IllegalArgumentException(
                    "already has a username");
        this.username = username;

    private String username;

NetBeans shows a hint for the line 4.

Unnecessary test for null – the expression is never null

That’s simply wrong. NetBeans see the @NotNull and he (or she) thinks the field will never null at any time.