Consistent use of Class<?> in Assert

This commit is contained in:
Juergen Hoeller 2013-05-16 16:10:36 +02:00
parent a19c976f7f
commit 16548d23e9
1 changed files with 7 additions and 7 deletions

View File

@ -184,7 +184,7 @@ public abstract class Assert {
*/ */
public static void doesNotContain(String textToSearch, String substring, String message) { public static void doesNotContain(String textToSearch, String substring, String message) {
if (StringUtils.hasLength(textToSearch) && StringUtils.hasLength(substring) && if (StringUtils.hasLength(textToSearch) && StringUtils.hasLength(substring) &&
textToSearch.indexOf(substring) != -1) { textToSearch.contains(substring)) {
throw new IllegalArgumentException(message); throw new IllegalArgumentException(message);
} }
} }
@ -236,8 +236,8 @@ public abstract class Assert {
*/ */
public static void noNullElements(Object[] array, String message) { public static void noNullElements(Object[] array, String message) {
if (array != null) { if (array != null) {
for (int i = 0; i < array.length; i++) { for (Object element : array) {
if (array[i] == null) { if (element == null) {
throw new IllegalArgumentException(message); throw new IllegalArgumentException(message);
} }
} }
@ -315,7 +315,7 @@ public abstract class Assert {
* @throws IllegalArgumentException if the object is not an instance of clazz * @throws IllegalArgumentException if the object is not an instance of clazz
* @see Class#isInstance * @see Class#isInstance
*/ */
public static void isInstanceOf(Class clazz, Object obj) { public static void isInstanceOf(Class<?> clazz, Object obj) {
isInstanceOf(clazz, obj, ""); isInstanceOf(clazz, obj, "");
} }
@ -331,7 +331,7 @@ public abstract class Assert {
* @throws IllegalArgumentException if the object is not an instance of clazz * @throws IllegalArgumentException if the object is not an instance of clazz
* @see Class#isInstance * @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"); notNull(type, "Type to check against must not be null");
if (!type.isInstance(obj)) { if (!type.isInstance(obj)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@ -348,7 +348,7 @@ public abstract class Assert {
* @param subType the sub type to check * @param subType the sub type to check
* @throws IllegalArgumentException if the classes are not assignable * @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, ""); isAssignable(superType, subType, "");
} }
@ -363,7 +363,7 @@ public abstract class Assert {
* ok when prepended to it. * ok when prepended to it.
* @throws IllegalArgumentException if the classes are not assignable * @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"); notNull(superType, "Type to check against must not be null");
if (subType == null || !superType.isAssignableFrom(subType)) { if (subType == null || !superType.isAssignableFrom(subType)) {
throw new IllegalArgumentException(message + subType + " is not assignable to " + superType); throw new IllegalArgumentException(message + subType + " is not assignable to " + superType);