litesoft
Diff Revisions
820
vs
821
for /trunk/Java/core/Anywhere/src/org/litesoft/core/typeutils/Integers.java
|
@@ -1,28 +1,37 @@ |
1 |
1 |
|
package org.litesoft.core.typeutils; |
2 |
2 |
|
|
3 |
|
- |
import org.litesoft.core.util.*; |
4 |
|
- |
|
5 |
|
- |
public class Integers |
|
3 |
+ |
public class Integers extends Numerics |
6 |
4 |
|
{ |
7 |
5 |
|
public static final int[] EMPTY_ARRAY_PRIMITIVES = new int[0]; |
8 |
6 |
|
public static final Integer[] EMPTY_ARRAY = new Integer[0]; |
9 |
7 |
|
|
10 |
|
- |
public static int assertPositive( String pWhat, int pInt ) |
|
8 |
+ |
public static Integer assertNonNegative( String pName, Integer pValue ) |
|
9 |
+ |
throws IllegalArgumentException |
|
10 |
+ |
{ |
|
11 |
+ |
if ( pValue != null ) |
|
12 |
+ |
{ |
|
13 |
+ |
assertNonNegative( pName, pValue.intValue() ); |
|
14 |
+ |
} |
|
15 |
+ |
return pValue; |
|
16 |
+ |
} |
|
17 |
+ |
|
|
18 |
+ |
public static int assertNonNegative( String pName, int pValue ) |
|
19 |
+ |
throws IllegalArgumentException |
11 |
20 |
|
{ |
12 |
|
- |
if ( 0 < pInt ) |
|
21 |
+ |
if ( pValue < 0 ) |
13 |
22 |
|
{ |
14 |
|
- |
return pInt; |
|
23 |
+ |
throw new IllegalArgumentException( pName + CANNOT_BE_NEGATIVE + ", but was: " + pValue ); |
15 |
24 |
|
} |
16 |
|
- |
throw new IllegalArgumentException( pWhat + " expected to be positive, but was: " + pInt ); |
|
25 |
+ |
return pValue; |
17 |
26 |
|
} |
18 |
27 |
|
|
19 |
|
- |
public static int assertNonNegative( String pWhat, int pInt ) |
|
28 |
+ |
public static int assertPositive( String pWhat, int pValue ) |
20 |
29 |
|
{ |
21 |
|
- |
if ( 0 <= pInt ) |
|
30 |
+ |
if ( 0 < pValue ) |
22 |
31 |
|
{ |
23 |
|
- |
return pInt; |
|
32 |
+ |
return pValue; |
24 |
33 |
|
} |
25 |
|
- |
throw new IllegalArgumentException( pWhat + " expected to be non-negative, but was: " + pInt ); |
|
34 |
+ |
throw new IllegalArgumentException( pWhat + MUST_BE_POSITIVE + ", but was: " + pValue ); |
26 |
35 |
|
} |
27 |
36 |
|
|
28 |
37 |
|
public static void assertNotEqual( String pObjectName, int pNotExpected, int pActual ) |