litesoft
@ 804
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
package org.litesoft.core.typeutils; import org.litesoft.core.util.*; public class Integers { public static final int[] EMPTY_ARRAY_PRIMITIVES = new int[0]; public static final Integer[] EMPTY_ARRAY = new Integer[0]; public static int assertPositive( String pWhat, int pInt ) { if ( 0 < pInt ) { return pInt; } throw new IllegalArgumentException( pWhat + " expected to be positive, but was: " + pInt ); } public static int assertNonNegative( String pWhat, int pInt ) { if ( 0 <= pInt ) { return pInt; } throw new IllegalArgumentException( pWhat + " expected to be non-negative, but was: " + pInt ); } public static void assertNotEqual( String pObjectName, int pNotExpected, int pActual ) throws IllegalArgumentException { if ( pNotExpected == pActual ) { throw new IllegalArgumentException( pObjectName + ": '" + pNotExpected + "' Not allowed" ); } } public static void assertEqual( String pObjectName, int pExpected, int pActual ) throws IllegalArgumentException { if ( pExpected != pActual ) { throw new IllegalArgumentException( pObjectName + ": Expected '" + pExpected + "', but was '" + pActual + "'" ); } } } |