Type doesn't need to be ArrayList, and updating for loops

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@772553 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2009-05-07 08:42:01 +00:00
parent 7d744b2267
commit a60f59ac93

View File

@ -20,9 +20,11 @@
import java.lang.reflect.AccessibleObject; import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.ClassUtils; import org.apache.commons.lang.ClassUtils;
@ -340,9 +342,8 @@ static String[] toNoNullStringArray(Collection<String> collection) {
* @return The given array or a new array without null. * @return The given array or a new array without null.
*/ */
static String[] toNoNullStringArray(Object[] array) { static String[] toNoNullStringArray(Object[] array) {
ArrayList<String> list = new ArrayList<String>(array.length); List<String> list = new ArrayList<String>(array.length);
for (int i = 0; i < array.length; i++) { for (Object e : array) {
Object e = array[i];
if (e != null) { if (e != null) {
list.add(e.toString()); list.add(e.toString());
} }
@ -526,8 +527,7 @@ protected void appendFieldsIn(Class<?> clazz) {
} }
Field[] fields = clazz.getDeclaredFields(); Field[] fields = clazz.getDeclaredFields();
AccessibleObject.setAccessible(fields, true); AccessibleObject.setAccessible(fields, true);
for (int i = 0; i < fields.length; i++) { for (Field field : fields) {
Field field = fields[i];
String fieldName = field.getName(); String fieldName = field.getName();
if (this.accept(field)) { if (this.accept(field)) {
try { try {