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