我正在开发一种API,想知道通常提及空参数的方式:
A. 像这样写 @throw NullPointerException if P is null
,假设所有文档未提到此问题的方法都将接受空参数:
/**
/* Does something...
/* @param p the paramteter to do something...
/* @throws NullPointerException if p is null
...
B. 像这个参数可以为空
这样写,假设没有提到不接受空参数:
/**
/* Does something...
/* @param p the parameter... this can be null
...
在常识中,我觉得A更合理,但是一直写这个确实很痛苦。
你会选择哪种方式?
谢谢!