Subversion Repository Public Repository

litesoft

Diff Revisions 958 vs 959 for /trunk/Java/ScarPlus/src/com/esotericsoftware/utils/Util.java

Diff revisions: vs.
  @@ -3,12 +3,10 @@
3 3 import org.litesoft.logger.*;
4 4
5 5 @SuppressWarnings({"UnusedDeclaration"})
6 - public class Util
7 - {
6 + public class Util {
8 7 public static LineSink PROGRESS_LINE_SINK = LineSink.SYSTEM_OUT;
9 8
10 - public static void progress( String pMessage )
11 - {
9 + public static void progress( String pMessage ) {
12 10 PROGRESS_LINE_SINK.addLine( pMessage );
13 11 }
14 12
  @@ -26,83 +24,66 @@
26 24
27 25 public static final Logger LOGGER = LoggerFactory.getLogger( Util.class );
28 26
29 - public static String noEmpty( String pToTest )
30 - {
31 - if ( pToTest != null )
32 - {
33 - if ( (pToTest = pToTest.trim()).length() != 0 )
34 - {
27 + public static String noEmpty( String pToTest ) {
28 + if ( pToTest != null ) {
29 + if ( (pToTest = pToTest.trim()).length() != 0 ) {
35 30 return pToTest;
36 31 }
37 32 }
38 33 return null;
39 34 }
40 35
41 - public static <T> T deNull( T pToTest, T pDefaultValue )
42 - {
36 + public static <T> T deNull( T pToTest, T pDefaultValue ) {
43 37 return (pToTest != null) ? pToTest : pDefaultValue;
44 38 }
45 39
46 - public static <T> T assertNotNull( String pWhat, T pToTest )
47 - {
48 - if ( pToTest == null )
49 - {
40 + public static <T> T assertNotNull( String pWhat, T pToTest ) {
41 + if ( pToTest == null ) {
50 42 throw new IllegalArgumentException( pWhat + " cannot be null." );
51 43 }
52 44 return pToTest;
53 45 }
54 46
55 - public static String assertNotEmpty( String pWhat, String pToTest )
56 - {
57 - if ( (pToTest = assertNotNull( pWhat, pToTest ).trim()).length() == 0 )
58 - {
47 + public static String assertNotEmpty( String pWhat, String pToTest ) {
48 + if ( (pToTest = assertNotNull( pWhat, pToTest ).trim()).length() == 0 ) {
59 49 throw new IllegalArgumentException( pWhat + " cannot be empty/blank." );
60 50 }
61 51 return pToTest;
62 52 }
63 53
64 - public static void assertNotEmpty( String pWhat, String[] pToTest )
65 - {
54 + public static void assertNotEmpty( String pWhat, String[] pToTest ) {
66 55 assertNotNull( pWhat, pToTest );
67 - if ( pToTest.length == 0 )
68 - {
56 + if ( pToTest.length == 0 ) {
69 57 throw new IllegalArgumentException( pWhat + " cannot be empty." );
70 58 }
71 59 }
72 60
73 - public static int assertNotNegative( String pWhat, int pInt )
74 - {
75 - if ( pInt < 0 )
76 - {
61 + public static int assertNotNegative( String pWhat, int pInt ) {
62 + if ( pInt < 0 ) {
77 63 throw new IllegalArgumentException( pWhat + " was " + pInt + ", cannot be negative." );
78 64 }
79 65 return pInt;
80 66 }
81 67
82 - public static void assertPairedEntries( String pWhat, Object[] pArray )
83 - {
68 + public static void assertPairedEntries( String pWhat, Object[] pArray ) {
84 69 if ( (pArray != null) && ((pArray.length & 1) == 1) ) // Odd Length == Not Paired!
85 70 {
86 71 throw new IllegalArgumentException( pWhat + " had '" + pArray.length + "' entries, should have been either '" + (pArray.length - 1) + "' or '" + (pArray.length + 1) + "'" );
87 72 }
88 73 }
89 74
90 - public static String replace( String pSource, String pOfInterest, String pReplaceWith )
91 - {
92 - for ( int at; -1 != (at = pSource.indexOf( pOfInterest )); )
93 - {
75 + public static String replace( String pSource, String pOfInterest, String pReplaceWith ) {
76 + for ( int at; -1 != (at = pSource.indexOf( pOfInterest )); ) {
94 77 pSource = pSource.substring( 0, at ) + pReplaceWith + pSource.substring( at + pOfInterest.length() );
95 78 }
96 79 return pSource;
97 80 }
98 81
99 - public static String toString( Object o )
100 - {
82 + public static String toString( Object o ) {
101 83 return (o != null) ? o.toString() : null;
102 84 }
103 85
104 - public int intForNotNull( int pNotNullIntValue, Object pObjectToCheck )
105 - {
86 + public int intForNotNull( int pNotNullIntValue, Object pObjectToCheck ) {
106 87 return (pObjectToCheck != null) ? pNotNullIntValue : 0;
107 88 }
108 89 }