@ParametersAreNonnullByDefault 是否也适用于方法返回值? [英] Is @ParametersAreNonnullByDefault applies to method return values too?
问题描述
文档@ParametersAreNonnullByDefault
说:
此注解可以应用于包、类或方法,以指示该元素中的方法参数默认为非空,除非...
This annotation can be applied to a package, class or method to indicate that the method parameters in that element are nonnull by default unless ...
我不认为方法的返回类型/值是它的参数.这只是其签名的一部分,所以这对我来说有点模棱两可.
I don't consider a method's return type/value to be it's parameter. It is only part of its signature, so this is kind of ambiguous for me.
Java 方法教程 似乎认为我.
正如 Joachim Sauer 在他的 answer,名称 @ParametersAreNonnullByDefault
(parameters) 应该清楚地向我表明此注释不适用于方法的返回类型/值.我瞎了眼!:) 谢谢约阿希姆!
As Joachim Sauer pointed out for me in the comments section of his answer, the name @ParametersAreNonnullByDefault
(parameters) should've clearly indicated for me that this annotation doesn't apply to methods' return types/values. I was blind! :) Thanks Joachim!
鉴于此,我只能说 @EverythingIsNonnullByDefault
应该存在于某处.:)
In light of this I can only says that an @EverythingIsNonnullByDefault
should exist somwhere. :)
推荐答案
我不明白为什么 @ParametersAreNonnullByDefault
应该应用于返回值.
I don't see a reason why @ParametersAreNonnullByDefault
should apply to return values.
这篇关于@ParametersAreNonnullByDefault 是否也适用于方法返回值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!