Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/GWT_Sandbox/FormEngine/src/com/temp/shared/utils/Validate.java

Diff revisions: vs.
  @@ -1,46 +1,46 @@
1 - package com.temp.shared.utils;
2 -
3 - public class Validate {
4 - public static void notNull( String what, Object toCheck ) {
5 - if ( toCheck == null ) {
6 - throw new IllegalArgumentException( what + " Not Allowed to be Null" );
7 - }
8 - }
9 -
10 - public static String noEmpty( String what, String toCheck ) {
11 - toCheck = StringUtils.noEmpty( toCheck );
12 - if ( toCheck == null ) {
13 - throw new IllegalArgumentException( what + " Not Allowed to be Null or Empty" );
14 - }
15 - return toCheck;
16 - }
17 -
18 - public static String noEmptyIdentifier( String what, String toCheck ) {
19 - toCheck = noEmpty( what, toCheck );
20 - if ( toCheck != null ) {
21 - int errorIndex = StringUtils.checkIdentifier( toCheck );
22 - if ( errorIndex == 0 ) {
23 - throw new IllegalArgumentException( "First Character Unacceptable for an Identifier: '" + toCheck + "'" );
24 - }
25 - if ( errorIndex != -1 ) {
26 - throw new IllegalArgumentException(
27 - "Character (" + (errorIndex + 1) + ":'" + toCheck.charAt( errorIndex ) + "') Unacceptable for an Identifier: '" + toCheck + "'" );
28 - }
29 - }
30 - return toCheck;
31 - }
32 -
33 - public static Integer optionalLength( String what, Integer length ) {
34 - if ( length != null ) {
35 - length( what, length );
36 - }
37 - return length;
38 - }
39 -
40 - public static int length( String what, int length ) {
41 - if ( length < 1 ) {
42 - throw new IllegalArgumentException( what + " Must be at least 1" );
43 - }
44 - return length;
45 - }
46 - }
1 + package com.temp.shared.utils;
2 +
3 + public class Validate {
4 + public static void notNull( String what, Object toCheck ) {
5 + if ( toCheck == null ) {
6 + throw new IllegalArgumentException( what + " Not Allowed to be Null" );
7 + }
8 + }
9 +
10 + public static String noEmpty( String what, String toCheck ) {
11 + toCheck = StringUtils.noEmpty( toCheck );
12 + if ( toCheck == null ) {
13 + throw new IllegalArgumentException( what + " Not Allowed to be Null or Empty" );
14 + }
15 + return toCheck;
16 + }
17 +
18 + public static String noEmptyIdentifier( String what, String toCheck ) {
19 + toCheck = noEmpty( what, toCheck );
20 + if ( toCheck != null ) {
21 + int errorIndex = StringUtils.checkIdentifier( toCheck );
22 + if ( errorIndex == 0 ) {
23 + throw new IllegalArgumentException( "First Character Unacceptable for an Identifier: '" + toCheck + "'" );
24 + }
25 + if ( errorIndex != -1 ) {
26 + throw new IllegalArgumentException(
27 + "Character (" + (errorIndex + 1) + ":'" + toCheck.charAt( errorIndex ) + "') Unacceptable for an Identifier: '" + toCheck + "'" );
28 + }
29 + }
30 + return toCheck;
31 + }
32 +
33 + public static Integer optionalLength( String what, Integer length ) {
34 + if ( length != null ) {
35 + length( what, length );
36 + }
37 + return length;
38 + }
39 +
40 + public static int length( String what, int length ) {
41 + if ( length < 1 ) {
42 + throw new IllegalArgumentException( what + " Must be at least 1" );
43 + }
44 + return length;
45 + }
46 + }