Support SortedMap properties
The issue that has blocked this is setting the comparator; TreeMap's comparator is immutable, but we want to return an unmodifiable view from getMySortedMapProperty(). Options:
- Provide a custom SortedMap implementation in freebuilder.jar with a mutable comparator.
Disadvantage: we don't currently expect users to ship freebuilder.jar. - Write out a SortedMap proxy inner class.
Disadvantage: lots of code for a rarely-used feature. - Allow the comparator to be set only once, delaying TreeMap construction until then. The setter should probably be protected.
Disadvantages:- users that want a mutable comparator will have to write one from scratch;
- mergeFrom won't copy the comparator; and
- no obvious path to migrate to solutions 1/2 in future, as users may rely on the behaviour of mergeFrom.
It would be great to have this.
To me option 2 sounds the most reasonable. Can you elaborate on how much code "lots" actually is? :)
Thanks!
SortedMap defines 20 methods, including some returning views that require more inner classes to be defined, adding dozens more methods.
An update on this issue: We now have SortedSet support, using option 3 above (comparator must be set before any other operation is called). Unfortunately it still requires a SortedSet proxy inner class to implement the mutate method; SortedMap will too.