commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r770891 - in /commons/proper/lang/trunk/src/java/org/apache/commons/lang: Entities.java Validate.java
Date Sat, 02 May 2009 05:20:36 GMT
Author: bayard
Date: Sat May  2 05:20:35 2009
New Revision: 770891

URL: http://svn.apache.org/viewvc?rev=770891&view=rev
Log:
Applying Hendrik Maryns' generics changes for Entities + Validate from LANG-336

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/Entities.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/Entities.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/Entities.java?rev=770891&r1=770890&r2=770891&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/Entities.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/Entities.java Sat May  2 05:20:35
2009
@@ -749,8 +749,8 @@
      *            array of entities to be added
      */
     public void addEntities(String[][] entityArray) {
-        for (int i = 0; i < entityArray.length; ++i) {
-            addEntity(entityArray[i][0], Integer.parseInt(entityArray[i][1]));
+        for (String[] element : entityArray) {
+            addEntity(element[0], Integer.parseInt(element[1]));
         }
     }
 

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java?rev=770891&r1=770890&r2=770891&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java Sat May  2 05:20:35
2009
@@ -258,9 +258,7 @@
      * @throws IllegalArgumentException if the array is empty
      */
     public static void notEmpty(Object[] array) {
-        if (array == null || array.length == 0) {
-            throw new IllegalArgumentException("The validated array is empty");
-        }
+        notEmpty(array, "The validated array is empty");
     }
 
     // notEmpty collection
@@ -278,7 +276,7 @@
      * @param message  the exception message you would like to see if the collection is empty
      * @throws IllegalArgumentException if the collection is empty
      */
-    public static void notEmpty(Collection collection, String message) {
+    public static void notEmpty(Collection<?> collection, String message) {
         if (collection == null || collection.size() == 0) {
             throw new IllegalArgumentException(message);
         }
@@ -297,10 +295,8 @@
      * @param collection  the collection to check is not empty
      * @throws IllegalArgumentException if the collection is empty
      */
-    public static void notEmpty(Collection collection) {
-        if (collection == null || collection.size() == 0) {
-            throw new IllegalArgumentException("The validated collection is empty");
-        }
+    public static void notEmpty(Collection<?> collection) {
+        notEmpty(collection, "The validated collection is empty");
     }
 
     // notEmpty map
@@ -318,7 +314,7 @@
      * @param message  the exception message you would like to see if the map is empty
      * @throws IllegalArgumentException if the map is empty
      */
-    public static void notEmpty(Map map, String message) {
+    public static void notEmpty(Map<?,?> map, String message) {
         if (map == null || map.size() == 0) {
             throw new IllegalArgumentException(message);
         }
@@ -337,10 +333,8 @@
      * @param map  the map to check is not empty
      * @throws IllegalArgumentException if the map is empty
      */
-    public static void notEmpty(Map map) {
-        if (map == null || map.size() == 0) {
-            throw new IllegalArgumentException("The validated map is empty");
-        }
+    public static void notEmpty(Map<?,?> map) {
+        notEmpty(map, "The validated map is empty");
     }
 
     // notEmpty string
@@ -378,9 +372,7 @@
      * @throws IllegalArgumentException if the string is empty
      */
     public static void notEmpty(String string) {
-        if (string == null || string.length() == 0) {
-            throw new IllegalArgumentException("The validated string is empty");
-        }
+        notEmpty(string, "The validated string is empty");
     }
 
     // notNullElements array



Mime
View raw message