I would like to be able to define custom anchors based on a map of
object->string in a subclass of `Serializer`. However `Serializer` is final
and `generateAnchor` is private. Also, there is no hook in `Yaml` to provide a
custom class for serializing.
*Approach A*
Please make `Serializer` non-final and `generateAnchor` protected, and provide
an optional ctor-set field in `Yaml` to pass in a subclass of `Serializer`.
Lastly, update `generateAnchor` to get a copy of the object represented by
`Node`.
I picture being able to write something like:
But I am unsure how to get at the original object represented by a node.
*Approach B*
Provide some kind of mapping in snakeyaml itself for object->alias, a hook for
defining custom text to use as anchors.
I figure approach B is about the same work as the approach A: still is needed
the machinery described above. Not sure what approach is most consistent with
current Yaml API.
Cheers,
--binkley
Original issue reported on code.google.com by b.k.ox...@gmail.com on 5 Jan 2015 at 1:57
@Override protected String generateAnchor(Object original) { if (this.myCustomAnchors.containsKey(original)) { return this.myCustomAnchors.get(original); } else { return super.generateAnchor(original); } }
Original issue reported on code.google.com by
b.k.ox...@gmail.com
on 5 Jan 2015 at 1:57