From b8d36919f4441ed7a069d8048a38624342393e1e Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sun, 5 Jun 2011 19:13:13 +0000 Subject: [PATCH] Introduced toClassArray(Collection>). git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4464 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../java/org/springframework/util/ClassUtils.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java b/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java index f3583d85d38..ff0440b1828 100644 --- a/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java +++ b/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2011 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. @@ -950,6 +950,19 @@ public abstract class ClassUtils { return sb.toString(); } + /** + * Copy the given Collection into a Class array. + * The Collection must contain Class elements only. + * @param collection the Collection to copy + * @return the Class array (null if the passed-in + * Collection was null) + */ + public static Class[] toClassArray(Collection> collection) { + if (collection == null) { + return null; + } + return collection.toArray(new Class[collection.size()]); + } /** * Return all interfaces that the given instance implements as array,