我有以下代码:
public interface Person {
/***
*@Throws Exception x must be greater than 0 ****/
setAge(int x);
}
public class Man implements Person {
setAge(int x) {
if(x <= 0) thrown new Exception("x <= ");
}
}
我打破了 DRY 原则,因为我在每个实现中都重复了检查,并且文档也重复了它。在这种情况下检查论点的最佳方法是什么?