@Test @SuppressWarnings("unchecked") void testToStringArray() { assertEquals(0, LazyList.toStringArray(null).length); assertEquals(1, LazyList.toStringArray("a").length); assertEquals("a", LazyList.toStringArray("a")[0]); @SuppressWarnings("rawtypes") ArrayList l = new ArrayList(); l.add("a"); l.add(null); l.add(new Integer(2)); String[] a = LazyList.toStringArray(l); assertEquals(3, a.length); assertEquals("a", a[0]); assertEquals(null, a[1]); assertEquals("2", a[2]); }
public static String[] toStringArray(Object list) { if (list == null) return __EMPTY_STRING_ARRAY; if (list instanceof List) { List<?> l = (List<?>) list; String[] a = new String[l.size()]; for (int i = l.size(); i-- > 0; ) { Object o = l.get(i); if (o != null) a[i] = o.toString(); } return a; } return new String[]{list.toString()}; }
LazyList implements Cloneable, Serializable { public static String[] toStringArray(Object list) { if (list == null) return __EMPTY_STRING_ARRAY; if (list instanceof List) { List<?> l = (List<?>) list; String[] a = new String[l.size()]; for (int i = l.size(); i-- > 0; ) { Object o = l.get(i); if (o != null) a[i] = o.toString(); } return a; } return new String[]{list.toString()}; } }
LazyList implements Cloneable, Serializable { public static String[] toStringArray(Object list) { if (list == null) return __EMPTY_STRING_ARRAY; if (list instanceof List) { List<?> l = (List<?>) list; String[] a = new String[l.size()]; for (int i = l.size(); i-- > 0; ) { Object o = l.get(i); if (o != null) a[i] = o.toString(); } return a; } return new String[]{list.toString()}; } private  LazyList(); }
LazyList implements Cloneable, Serializable { public static String[] toStringArray(Object list) { if (list == null) return __EMPTY_STRING_ARRAY; if (list instanceof List) { List<?> l = (List<?>) list; String[] a = new String[l.size()]; for (int i = l.size(); i-- > 0; ) { Object o = l.get(i); if (o != null) a[i] = o.toString(); } return a; } return new String[]{list.toString()}; } private  LazyList(); @SuppressWarnings("unchecked") static Object add(Object list, Object item); @SuppressWarnings("unchecked") static Object add(Object list, int index, Object item); static Object addCollection(Object list, Collection<?> collection); static Object addArray(Object list, Object[] array); static Object ensureSize(Object list, int initialSize); static Object remove(Object list, Object o); static Object remove(Object list, int i); static List<E> getList(Object list); @SuppressWarnings("unchecked") static List<E> getList(Object list, boolean nullForEmpty); static boolean hasEntry(Object list); static boolean isEmpty(Object list); static String[] toStringArray(Object list); static Object toArray(Object list, Class<?> clazz); static int size(Object list); @SuppressWarnings("unchecked") static E get(Object list, int i); static boolean contains(Object list, Object item); static Object clone(Object list); static String toString(Object list); @SuppressWarnings("unchecked") static Iterator<E> iterator(Object list); @SuppressWarnings("unchecked") static ListIterator<E> listIterator(Object list); }
LazyList implements Cloneable, Serializable { public static String[] toStringArray(Object list) { if (list == null) return __EMPTY_STRING_ARRAY; if (list instanceof List) { List<?> l = (List<?>) list; String[] a = new String[l.size()]; for (int i = l.size(); i-- > 0; ) { Object o = l.get(i); if (o != null) a[i] = o.toString(); } return a; } return new String[]{list.toString()}; } private  LazyList(); @SuppressWarnings("unchecked") static Object add(Object list, Object item); @SuppressWarnings("unchecked") static Object add(Object list, int index, Object item); static Object addCollection(Object list, Collection<?> collection); static Object addArray(Object list, Object[] array); static Object ensureSize(Object list, int initialSize); static Object remove(Object list, Object o); static Object remove(Object list, int i); static List<E> getList(Object list); @SuppressWarnings("unchecked") static List<E> getList(Object list, boolean nullForEmpty); static boolean hasEntry(Object list); static boolean isEmpty(Object list); static String[] toStringArray(Object list); static Object toArray(Object list, Class<?> clazz); static int size(Object list); @SuppressWarnings("unchecked") static E get(Object list, int i); static boolean contains(Object list, Object item); static Object clone(Object list); static String toString(Object list); @SuppressWarnings("unchecked") static Iterator<E> iterator(Object list); @SuppressWarnings("unchecked") static ListIterator<E> listIterator(Object list);  }