@Test public void settingShouldNullifyUpToIndex() throws Exception { accessor.setProperty(context, instance, 1, "hello"); assertThat(instance.get(0), is(Matchers.nullValue())); assertThat(instance.get(1), is(Matchers.equalTo("hello"))); }
@Override @SuppressWarnings("unchecked") public void setProperty(Map context, Object target, Object key, Object value) throws OgnlException { List<?> list = (List<?>) target; int index = (Integer) key; for (int i = list.size(); i <= index; i++) { list.add(null); } if (value instanceof String) { OgnlContext ctx = (OgnlContext) context; Type genericType = extractGenericType(ctx, target); Class type = getActualType(genericType); Converter<?> converter = converters.to(type); ResourceBundle bundle = (ResourceBundle) context.get(ResourceBundle.class); Object result = converter.convert((String) value, type, bundle); super.setProperty(context, target, key, result); return; } super.setProperty(context, target, key, value); }
ListAccessor extends ListPropertyAccessor { @Override @SuppressWarnings("unchecked") public void setProperty(Map context, Object target, Object key, Object value) throws OgnlException { List<?> list = (List<?>) target; int index = (Integer) key; for (int i = list.size(); i <= index; i++) { list.add(null); } if (value instanceof String) { OgnlContext ctx = (OgnlContext) context; Type genericType = extractGenericType(ctx, target); Class type = getActualType(genericType); Converter<?> converter = converters.to(type); ResourceBundle bundle = (ResourceBundle) context.get(ResourceBundle.class); Object result = converter.convert((String) value, type, bundle); super.setProperty(context, target, key, result); return; } super.setProperty(context, target, key, value); } }
ListAccessor extends ListPropertyAccessor { @Override @SuppressWarnings("unchecked") public void setProperty(Map context, Object target, Object key, Object value) throws OgnlException { List<?> list = (List<?>) target; int index = (Integer) key; for (int i = list.size(); i <= index; i++) { list.add(null); } if (value instanceof String) { OgnlContext ctx = (OgnlContext) context; Type genericType = extractGenericType(ctx, target); Class type = getActualType(genericType); Converter<?> converter = converters.to(type); ResourceBundle bundle = (ResourceBundle) context.get(ResourceBundle.class); Object result = converter.convert((String) value, type, bundle); super.setProperty(context, target, key, result); return; } super.setProperty(context, target, key, value); } ListAccessor(Converters converters); }
ListAccessor extends ListPropertyAccessor { @Override @SuppressWarnings("unchecked") public void setProperty(Map context, Object target, Object key, Object value) throws OgnlException { List<?> list = (List<?>) target; int index = (Integer) key; for (int i = list.size(); i <= index; i++) { list.add(null); } if (value instanceof String) { OgnlContext ctx = (OgnlContext) context; Type genericType = extractGenericType(ctx, target); Class type = getActualType(genericType); Converter<?> converter = converters.to(type); ResourceBundle bundle = (ResourceBundle) context.get(ResourceBundle.class); Object result = converter.convert((String) value, type, bundle); super.setProperty(context, target, key, result); return; } super.setProperty(context, target, key, value); } ListAccessor(Converters converters); @Override Object getProperty(Map context, Object target, Object value); @Override @SuppressWarnings("unchecked") void setProperty(Map context, Object target, Object key, Object value); }
ListAccessor extends ListPropertyAccessor { @Override @SuppressWarnings("unchecked") public void setProperty(Map context, Object target, Object key, Object value) throws OgnlException { List<?> list = (List<?>) target; int index = (Integer) key; for (int i = list.size(); i <= index; i++) { list.add(null); } if (value instanceof String) { OgnlContext ctx = (OgnlContext) context; Type genericType = extractGenericType(ctx, target); Class type = getActualType(genericType); Converter<?> converter = converters.to(type); ResourceBundle bundle = (ResourceBundle) context.get(ResourceBundle.class); Object result = converter.convert((String) value, type, bundle); super.setProperty(context, target, key, result); return; } super.setProperty(context, target, key, value); } ListAccessor(Converters converters); @Override Object getProperty(Map context, Object target, Object value); @Override @SuppressWarnings("unchecked") void setProperty(Map context, Object target, Object key, Object value);  }