@Test public void test9_propertiesIsNull() { NullValueForm9 form = new NullValueForm9(); NestedForm9 nestedForm = new NestedForm9(); form.setNestedForm2(nestedForm); Map<String, String> map = converter.convert(form); assertThat(map.size(), is(20)); assertThat(map, hasEntry("_string", "")); assertThat(map, hasEntry("_integer", "")); assertThat(map, hasEntry("_date", "")); assertThat(map, hasEntry("_jodaLocalDate", "")); assertThat(map, hasEntry("_customEnum", "")); assertThat(map, hasEntry("_list", "")); assertThat(map, hasEntry("_list2[0]", "")); assertThat(map, hasEntry("_map", "")); assertThat(map, hasEntry("_map2[key]", "")); assertThat(map, hasEntry("_array", "")); assertThat(map, hasEntry("_array2[0]", "")); assertThat(map, hasEntry("_nestedForm1", "")); assertThat(map, hasEntry("_nestedForm2.string", "")); assertThat(map, hasEntry("_nestedForm2.integer", "")); assertThat(map, hasEntry("_nestedForm2.list", "")); assertThat(map, hasEntry("_nestedForm2.list2[0]", "")); assertThat(map, hasEntry("_nestedForm2.map", "")); assertThat(map, hasEntry("_nestedForm2.map2[key]", "")); assertThat(map, hasEntry("_nestedForm2.array", "")); assertThat(map, hasEntry("_nestedForm2.array2[0]", "")); }
private Map<String, String> convert(String prefix, Map<?, ?> value) { Map<String, String> map = new LinkedHashMap<String, String>(); for (Map.Entry<?, ?> e : value.entrySet()) { if (StringUtils.isEmpty(prefix)) { map.putAll(this.convert(e.getKey().toString(), e.getValue())); } else { map.putAll(this.convert(prefix + "[" + e.getKey() + "]", e .getValue())); } } return map; }
ObjectToMapConverter { private Map<String, String> convert(String prefix, Map<?, ?> value) { Map<String, String> map = new LinkedHashMap<String, String>(); for (Map.Entry<?, ?> e : value.entrySet()) { if (StringUtils.isEmpty(prefix)) { map.putAll(this.convert(e.getKey().toString(), e.getValue())); } else { map.putAll(this.convert(prefix + "[" + e.getKey() + "]", e .getValue())); } } return map; } }
ObjectToMapConverter { private Map<String, String> convert(String prefix, Map<?, ?> value) { Map<String, String> map = new LinkedHashMap<String, String>(); for (Map.Entry<?, ?> e : value.entrySet()) { if (StringUtils.isEmpty(prefix)) { map.putAll(this.convert(e.getKey().toString(), e.getValue())); } else { map.putAll(this.convert(prefix + "[" + e.getKey() + "]", e .getValue())); } } return map; } ObjectToMapConverter(FormattingConversionService conversionService); }
ObjectToMapConverter { private Map<String, String> convert(String prefix, Map<?, ?> value) { Map<String, String> map = new LinkedHashMap<String, String>(); for (Map.Entry<?, ?> e : value.entrySet()) { if (StringUtils.isEmpty(prefix)) { map.putAll(this.convert(e.getKey().toString(), e.getValue())); } else { map.putAll(this.convert(prefix + "[" + e.getKey() + "]", e .getValue())); } } return map; } ObjectToMapConverter(FormattingConversionService conversionService); Map<String, String> convert(Object object); Map<String, String> convert(String prefix, Object object); }
ObjectToMapConverter { private Map<String, String> convert(String prefix, Map<?, ?> value) { Map<String, String> map = new LinkedHashMap<String, String>(); for (Map.Entry<?, ?> e : value.entrySet()) { if (StringUtils.isEmpty(prefix)) { map.putAll(this.convert(e.getKey().toString(), e.getValue())); } else { map.putAll(this.convert(prefix + "[" + e.getKey() + "]", e .getValue())); } } return map; } ObjectToMapConverter(FormattingConversionService conversionService); Map<String, String> convert(Object object); Map<String, String> convert(String prefix, Object object);  }