### Question:
ReflectionHelper { public static Object getIndexedValue(Object value, Integer index) { if ( value == null ) { return null; } Iterator<?> iter; Type type = value.getClass(); if ( isIterable( type ) ) { iter = ( ( Iterable<?> ) value ).iterator(); } else if ( TypeUtils.isArray( type ) ) { List<?> arrayList = Arrays.asList( ( Object ) value ); iter = arrayList.iterator(); } else { return null; } int i = 0; Object o; while ( iter.hasNext() ) { o = iter.next(); if ( i == index ) { return o; } i++; } return null; } private  ReflectionHelper(); @SuppressWarnings("unchecked") static T getAnnotationParameter(Annotation annotation, String parameterName, Class<T> type); static String getPropertyName(Member member); static Class<?> getType(Member member); static Class<?> getAnnotations(Member member); static Type typeOf(Member member); static Object getValue(Member member, Object object); static void setAccessibility(Member member); static Class<?> loadClass(String name, Class<?> caller); static Type getIndexedType(Type type); static boolean isIterable(Type type); static boolean isMap(Type type); static boolean isList(Type type); static Object getIndexedValue(Object value, Integer index); static Object getMappedValue(Object value, Object key); static boolean containsMember(Class<?> clazz, String property); static boolean containsField(Class<?> clazz, String fieldName); static Field getField(Class<?> clazz, String fieldName); static boolean containsMethod(Class<?> clazz, String methodName); static Method getMethod(Class<?> clazz, String methodName); static Class<?> classForName(String name, Class<?> caller); static Class<?> boxedTyp(Type primitiveType);  }### Answer:
@Test public void testGetIndexedValueForList() { List<Object> list = new ArrayList<Object>(); Object testObject = new Object(); list.add( testObject ); Object value = ReflectionHelper.getIndexedValue( list, 0 ); assertEquals( value, testObject, "We should be able to retrieve the indexed object" ); value = ReflectionHelper.getIndexedValue( list, 2 ); assertNull( value, "A non existent index should return the null value" ); }
@Test public void testGetIndexedValueForNull() { Object value = ReflectionHelper.getIndexedValue( null, 0 ); assertNull( value ); }