Reverted arrayToList signature to return plain List
This is necessary for source compatibility with existing callers, such as code found in Spring Integration: e.g. passing the arrayToList result into a typed HashSet constructor.
This commit is contained in:
parent
bd8469990d
commit
676ad125a1
|
|
@ -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.
|
||||
* <p>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.
|
||||
* <p><b>NOTE:</b> 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.
|
||||
* <p>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 <E> List<E> arrayToList(Object source) {
|
||||
return (List<E>) Arrays.asList(ObjectUtils.toObjectArray(source));
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static List arrayToList(Object source) {
|
||||
return Arrays.asList(ObjectUtils.toObjectArray(source));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue