diff --git a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java index 2f27225605..5e84aee859 100644 --- a/spring-core/src/main/java/org/springframework/util/CollectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/CollectionUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,8 +42,8 @@ import java.util.Set; public abstract class CollectionUtils { /** - * Return {@code true} if the supplied Collection is {@code null} - * or empty. Otherwise, return {@code false}. + * Return {@code true} if the supplied Collection is {@code null} or empty. + * Otherwise, return {@code false}. * @param collection the Collection to check * @return whether the given Collection is empty */ @@ -52,8 +52,8 @@ public abstract class CollectionUtils { } /** - * Return {@code true} if the supplied Map is {@code null} - * or empty. Otherwise, return {@code false}. + * Return {@code true} if the supplied Map is {@code null} or empty. + * Otherwise, return {@code false}. * @param map the Map to check * @return whether the given Map is empty */ @@ -62,17 +62,20 @@ public abstract class CollectionUtils { } /** - * Convert the supplied array into a List. A primitive array gets - * converted into a List of the appropriate wrapper type. - *

A {@code null} source value will be converted to an - * empty List. + * Convert the supplied array into a List. A primitive array gets converted + * into a List of the appropriate wrapper type. + *

NOTE: Generally prefer the standard {@link Arrays#asList} method. + * This {@code arrayToList} method is just meant to deal with an incoming Object + * value that might be an {@code Object[]} or a primitive array at runtime. + *

A {@code null} source value will be converted to an empty List. * @param source the (potentially primitive) array * @return the converted List result * @see ObjectUtils#toObjectArray(Object) + * @see Arrays#asList(Object[]) */ - @SuppressWarnings("unchecked") - public static List arrayToList(Object source) { - return (List) Arrays.asList(ObjectUtils.toObjectArray(source)); + @SuppressWarnings("rawtypes") + public static List arrayToList(Object source) { + return Arrays.asList(ObjectUtils.toObjectArray(source)); } /**