Using Validate where possible in builder package.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1593622 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3728344459
commit
10641f9ae7
|
@ -25,6 +25,7 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -536,12 +537,8 @@ public class HashCodeBuilder implements Builder<Integer> {
|
|||
* if the number is even
|
||||
*/
|
||||
public HashCodeBuilder(final int initialOddNumber, final int multiplierOddNumber) {
|
||||
if (initialOddNumber % 2 == 0) {
|
||||
throw new IllegalArgumentException("HashCodeBuilder requires an odd initial value");
|
||||
}
|
||||
if (multiplierOddNumber % 2 == 0) {
|
||||
throw new IllegalArgumentException("HashCodeBuilder requires an odd multiplier");
|
||||
}
|
||||
Validate.isTrue(initialOddNumber % 2 != 0, "HashCodeBuilder requires an odd initial value");
|
||||
Validate.isTrue(multiplierOddNumber % 2 != 0, "HashCodeBuilder requires an odd multiplier");
|
||||
iConstant = multiplierOddNumber;
|
||||
iTotal = initialOddNumber;
|
||||
}
|
||||
|
|
|
@ -60,8 +60,13 @@ public class HashCodeBuilderTest {
|
|||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testConstructorExEven() {
|
||||
new HashCodeBuilder(2, 2);
|
||||
public void testConstructorExEvenFirst() {
|
||||
new HashCodeBuilder(2, 3);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testConstructorExEvenSecond() {
|
||||
new HashCodeBuilder(3, 2);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
|
|
Loading…
Reference in New Issue