diff --git a/src/java/org/apache/commons/lang/Entities.java b/src/java/org/apache/commons/lang/Entities.java index 058829515..b05f383ca 100644 --- a/src/java/org/apache/commons/lang/Entities.java +++ b/src/java/org/apache/commons/lang/Entities.java @@ -749,8 +749,8 @@ public String name(int value) { * 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])); } } diff --git a/src/java/org/apache/commons/lang/Validate.java b/src/java/org/apache/commons/lang/Validate.java index c1769d59b..bb038f546 100644 --- a/src/java/org/apache/commons/lang/Validate.java +++ b/src/java/org/apache/commons/lang/Validate.java @@ -258,9 +258,7 @@ public static void notEmpty(Object[] array, String message) { * @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 @@ public static void notEmpty(Object[] array) { * @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 @@ public static void notEmpty(Collection collection, String message) { * @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 @@ public static void notEmpty(Collection collection) { * @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 @@ public static void notEmpty(Map map, String message) { * @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 @@ public static void notEmpty(String string, String message) { * @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