config
config copied to clipboard
Fix the Map spec implementation for ConfigObject.
According to the Map specification, methods keySet, values and entrySet are backed by the map, so changes to the map are reflected in the collection, and vice-versa. ConfigObject interface extends Map, so it must conform the specification. Also, ConfigObject declared as immutable, so keySet, values and entrySet must return immutable collections.
would it be simpler to wrap the value field in the constructor? though I suppose that uses memory more permanently so I don’t know.
I had no idea about this! surprising Java fact. Thanks!
would it be simpler to wrap the
valuefield in the constructor? though I suppose that uses memory more permanently so I don’t know.
value is passing to the SimpleConfigObject constructor from one of the inner methods. There no way to check value instanceof Collections.UnmodifiableMap (because UnmodifiableMap is private), so we could obtain a Map wrapped several times. Another solution is to reconstruct Map in constructor, but it too expensive.
Also, I think, keySet, entrySet and values are not often used method for ConfigObject.
We do not intend to extend the functionality of "Typesafe Config" further. See https://github.com/lightbend/config#maintained-by