mirror of
https://github.com/LingCoder/OnJava8.git
synced 2026-08-24 23:13:28 +08:00
Update 16-Validating-Your-Code.md
This commit is contained in:
@@ -905,13 +905,13 @@ public class NonNullConstruction {
|
||||
}
|
||||
```
|
||||
|
||||
**checkArgument()** 接受布尔表达式来对参数进行更具体的测试, 失败时抛出 **IllegalArgumentException**,**checkState()**用于测试对象的状态(例如,不变性检查),而不是检查参数,并在失败时抛出 **IllegalStateException** 。
|
||||
**checkArgument()** 接受布尔表达式来对参数进行更具体的测试, 失败时抛出 **IllegalArgumentException**,**checkState()** 用于测试对象的状态(例如,不变性检查),而不是检查参数,并在失败时抛出 **IllegalStateException** 。
|
||||
|
||||
最后三个方法在失败时抛出 **IndexOutOfBoundsException**。**checkElementIndex**() 确保其第一个参数是列表、字符串或数组的有效元素索引,其大小由第二个参数指定。**checkPositionIndex()**确保它的第一个参数在 0 到第二个参数(包括第二个参数)的范围内。**checkPositionIndexes()** 检查 **[first_arg, second_arg]** 是一个列表的有效子列表,由第三个参数指定大小的字符串或数组。
|
||||
最后三个方法在失败时抛出 **IndexOutOfBoundsException**。**checkElementIndex**() 确保其第一个参数是列表、字符串或数组的有效元素索引,其大小由第二个参数指定。**checkPositionIndex()** 确保它的第一个参数在 0 到第二个参数(包括第二个参数)的范围内。 **checkPositionIndexes()** 检查 **[first_arg, second_arg]** 是一个列表的有效子列表,由第三个参数指定大小的字符串或数组。
|
||||
|
||||
所有Guava前置条件对于基本类型和对象都有必要的重载。
|
||||
|
||||
<!-- Test-Driven Development -->。
|
||||
<!-- Test-Driven Development -->
|
||||
|
||||
## 测试驱动开发
|
||||
|
||||
|
||||
Reference in New Issue
Block a user