ListExtractor implements Extractor { public Object setObjectValue(StringToObjectConverter pConverter, Object pInner, String pIndex, Object pValue) throws IllegalAccessException, InvocationTargetException { List list = (List) pInner; int idx; try { idx = Integer.parseInt(pIndex); } catch (NumberFormatException exp) { throw new IllegalArgumentException("Non-numeric index for accessing collection " + pInner + ". (index = " + pIndex + ", value to set = " + pValue + ")",exp); } Object oldValue = list.get(idx); Object value = oldValue != null ? pConverter.prepareValue(oldValue.getClass().getName(), pValue) : pValue; list.set(idx,value); return oldValue; }  Class getType(); Object extractObject(ObjectToJsonConverter pConverter, Object pValue, Stack<String> pPathParts,boolean jsonify); Object setObjectValue(StringToObjectConverter pConverter, Object pInner, String pIndex, Object  pValue); boolean canSetValue();  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testSetValueInvalidIndex() throws Exception { List list = Arrays.asList("null", "bla"); extractor.setObjectValue(stringToObjectConverter, list, "NaN", "blub"); }
@Test(expectedExceptions = IndexOutOfBoundsException.class) public void testSetValueIndexOutOfBounds() throws Exception { List list = Arrays.asList("null", "bla"); extractor.setObjectValue(stringToObjectConverter, list, "3", "blub"); }