Philipp Claßen Philipp Claßen - 1 year ago 99
Java Question

Is there a @NonNullByDefault annotation in IDEA?

Eclipse has the

annotation, which treats all values as
unless you explicitly annotate them as

Is there an equivalent option in IntelliJ IDEA, or do you have to always use

Answer Source

No, it is currently not supported by IDEA.

As a proof, see lena's link about the open feature request to allow 'NotNull' as the default element behavior for a given class or package.

Maybe a similar feature will be become standard with JSR-305, which may include the @ParametersAreNonnullByDefault annotation and also the opposite annotation @ParametersAreNullableByDefault. Note that in contrast to @NonNullByDefault, return values are not covered by those two annotations. So, you still had to annotate the return value explicitely.

All that doesn't change the current state, though. Neither has JSR-305 become a standard, nor does IDEA implement it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download