Currently, the formatter will format Map.of() as either:
// Shorter list
Map<String, String> map1 = Map.of("key1", value1, "key2", value2, "key3", value3);
// Longer list
Map<String, String> map2 = Map.of(
"key1",
longerValue1,
"key2",
longerValue2,
"key3",
longerValue3,
"key4",
longerValue4,
"key5",
longerValue5,
"key6",
longerValue6);
These are not very readable, especially when the keys are not visually distinguishable from values.
It would be much more readable if it would format them like this instead:
// Shorter list
Map<String, String> map1 = Map.of(
"key1", value1,
"key2", value2,
"key3", value3);
// Longer list
Map<String, String> map2 = Map.of(
"key1", longerValue1,
"key2", longerValue2,
"key3", longerValue3,
"key4", longerValue4,
"key5", longerValue5,
"key6", longerValue6);
You may need to special case Map.of() and ImmutableMap.of(), as I don't think there is any more general rule.
Currently, the formatter will format Map.of() as either:
These are not very readable, especially when the keys are not visually distinguishable from values.
It would be much more readable if it would format them like this instead:
You may need to special case Map.of() and ImmutableMap.of(), as I don't think there is any more general rule.