How can I annotate enum.values() as NotNull?

已回答

It is not possible for an MyEnum.values() call to return a null, however Idea's annotation processing tags it as nullable.

Since values isn't actually a method call, I can't figure out how to use the External Annotations file to tag it as NonNull.

I can create a getValues() wrapper around values(), annotate it as @NotNull and then ignore the warnings but that really seems wrong and verbose since you'd have to do this for EVERY enum you define and couldn't do it for external enums at all.

0

请先登录再写评论。