Setting Nested Map
This practice deals with manipulation
setInner
0. Class
It works even if key is map type or value is map type.
public class Generate {
Map<Map<String, String>, String> mapByString;
Map<String, Map<String, String>> stringByMap;
}
Setting nested map key
generateBuilder.setInner(
InnerSpec().property("mapByString", m -> m.key(k -> k.entry("key", "value")))
);
generateBuilder.setInner(
InnerSpec().property("mapByString") { m -> m.key { k -> k.entry("key", "value") } }
);
If setting value given key, check out entry
just as shown below
generateBuilder.setInner(
InnerSpec().property("mapByString", m -> m.entry(k -> k.entry("innerKey", "innerValue")), "value")
);
generateBuilder.setInner(
InnerSpec().property("mapByString") { m -> m.entry({ k -> k.entry("innerKey", "innerValue") }, "value") }
);
Setting nested map value
generateBuilder.setInner(
InnerSpec().property("stringByMap", m -> m.value(v -> v.entry("key", "value")))
);
generateBuilder.setInner(
InnerSpec().property("stringByMap") { m -> m.value { v -> v.entry("key", "value") } }
);
If setting key given value, check out entry
just as shown below
generateBuilder.setInner(
InnerSpec().property("stringByMap", m -> m.entry("key", v -> v.entry("innerKey", "innerValue")))
);
generateBuilder.setInner(
InnerSpec().property("stringByMap") { m -> m.entry("key") {v -> v.entry("innerKey", "innerValue")} }
);