Skip to content

Commit 7307f3d

Browse files
committed
Introduced toClassArray(Collection<Class<?>>).
1 parent 5976bec commit 7307f3d

File tree

1 file changed

+14
-1
lines changed
  • org.springframework.core/src/main/java/org/springframework/util

1 file changed

+14
-1
lines changed

org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2011 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -950,6 +950,19 @@ public static String classNamesToString(Collection<Class> classes) {
950950
return sb.toString();
951951
}
952952

953+
/**
954+
* Copy the given Collection into a Class array.
955+
* The Collection must contain Class elements only.
956+
* @param collection the Collection to copy
957+
* @return the Class array (<code>null</code> if the passed-in
958+
* Collection was <code>null</code>)
959+
*/
960+
public static Class<?>[] toClassArray(Collection<Class<?>> collection) {
961+
if (collection == null) {
962+
return null;
963+
}
964+
return collection.toArray(new Class<?>[collection.size()]);
965+
}
953966

954967
/**
955968
* Return all interfaces that the given instance implements as array,

0 commit comments

Comments
 (0)