litesoft
@ 964
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / common / shared / utils / Validate.java
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 46 |
package com.temp.common.shared.utils; public class Validate { public static void notNull( String what, Object toCheck ) { if ( toCheck == null ) { throw new IllegalArgumentException( what + " Not Allowed to be Null" ); } } public static String noEmpty( String what, String toCheck ) { toCheck = StringUtils.noEmpty( toCheck ); if ( toCheck == null ) { throw new IllegalArgumentException( what + " Not Allowed to be Null or Empty" ); } return toCheck; } public static String noEmptyIdentifier( String what, String toCheck ) { toCheck = noEmpty( what, toCheck ); if ( toCheck != null ) { int errorIndex = StringUtils.checkIdentifier( toCheck ); if ( errorIndex == 0 ) { throw new IllegalArgumentException( "First Character Unacceptable for an Identifier: '" + toCheck + "'" ); } if ( errorIndex != -1 ) { throw new IllegalArgumentException( "Character (" + (errorIndex + 1) + ":'" + toCheck.charAt( errorIndex ) + "') Unacceptable for an Identifier: '" + toCheck + "'" ); } } return toCheck; } public static Integer optionalLength( String what, Integer length ) { if ( length != null ) { length( what, length ); } return length; } public static int length( String what, int length ) { if ( length < 1 ) { throw new IllegalArgumentException( what + " Must be at least 1" ); } return length; } } |
Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/common/shared/utils/Validate.java
Revision | Author | Commited | Message |
---|---|---|---|
964 | GeorgeS | Fri 01 Aug, 2014 03:18:23 +0000 | ! |