From 16548d23e9ef5d0abcef38d677241d5945c427c1 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 16 May 2013 16:10:36 +0200 Subject: [PATCH] Consistent use of Class in Assert --- .../main/java/org/springframework/util/Assert.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/util/Assert.java b/spring-core/src/main/java/org/springframework/util/Assert.java index 193d461a0547..55b2325d5111 100644 --- a/spring-core/src/main/java/org/springframework/util/Assert.java +++ b/spring-core/src/main/java/org/springframework/util/Assert.java @@ -184,7 +184,7 @@ public static void hasText(String text) { */ public static void doesNotContain(String textToSearch, String substring, String message) { if (StringUtils.hasLength(textToSearch) && StringUtils.hasLength(substring) && - textToSearch.indexOf(substring) != -1) { + textToSearch.contains(substring)) { throw new IllegalArgumentException(message); } } @@ -236,8 +236,8 @@ public static void notEmpty(Object[] array) { */ public static void noNullElements(Object[] array, String message) { if (array != null) { - for (int i = 0; i < array.length; i++) { - if (array[i] == null) { + for (Object element : array) { + if (element == null) { throw new IllegalArgumentException(message); } } @@ -315,7 +315,7 @@ public static void notEmpty(Map map) { * @throws IllegalArgumentException if the object is not an instance of clazz * @see Class#isInstance */ - public static void isInstanceOf(Class clazz, Object obj) { + public static void isInstanceOf(Class clazz, Object obj) { isInstanceOf(clazz, obj, ""); } @@ -331,7 +331,7 @@ public static void isInstanceOf(Class clazz, Object obj) { * @throws IllegalArgumentException if the object is not an instance of clazz * @see Class#isInstance */ - public static void isInstanceOf(Class type, Object obj, String message) { + public static void isInstanceOf(Class type, Object obj, String message) { notNull(type, "Type to check against must not be null"); if (!type.isInstance(obj)) { throw new IllegalArgumentException( @@ -348,7 +348,7 @@ public static void isInstanceOf(Class type, Object obj, String message) { * @param subType the sub type to check * @throws IllegalArgumentException if the classes are not assignable */ - public static void isAssignable(Class superType, Class subType) { + public static void isAssignable(Class superType, Class subType) { isAssignable(superType, subType, ""); } @@ -363,7 +363,7 @@ public static void isAssignable(Class superType, Class subType) { * ok when prepended to it. * @throws IllegalArgumentException if the classes are not assignable */ - public static void isAssignable(Class superType, Class subType, String message) { + public static void isAssignable(Class superType, Class subType, String message) { notNull(superType, "Type to check against must not be null"); if (subType == null || !superType.isAssignableFrom(subType)) { throw new IllegalArgumentException(message + subType + " is not assignable to " + superType);