01: /*******************************************************************************
02: * Portions created by Sebastian Thomschke are copyright (c) 2005-2007 Sebastian
03: * Thomschke.
04: *
05: * All Rights Reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * Sebastian Thomschke - initial implementation.
12: *******************************************************************************/package net.sf.oval.internal.util;
13:
14: import java.lang.reflect.Method;
15: import java.util.Collection;
16:
17: /**
18: *
19: * @author Sebastian Thomschke
20: */
21: public final class ArrayUtils {
22: public final static Object[] EMPTY_CLASS_ARRAY = new Class[0];
23: public final static Method[] EMPTY_METHOD_ARRAY = new Method[0];
24: public final static Object[] EMPTY_OBJECT_ARRAY = new Object[0];
25: public final static String[] EMPTY_STRING_ARRAY = new String[0];
26:
27: public static <T> int addAll(final Collection<T> collection,
28: final T... elements) {
29: if (collection == null)
30: throw new IllegalArgumentException(
31: "Argument collection must not be null");
32:
33: int count = 0;
34: for (final T elem : elements) {
35: if (collection.add(elem))
36: count++;
37: }
38: return count;
39: }
40:
41: private ArrayUtils() {
42: // do nothing
43: }
44: }
|