Hi Andrey,
While this proposal could be subdivided into a few smaller changes, it
is one cohesive proposal, which is why I submitted it this way. For
example, it is possible to refactor just Representer or just
Constructor, but without refactoring both, the benefits are lost.
You are correct that the public-API change could be removed to a later
revision, assuming that the existing Yaml, JavaBeanLoader and
JavaBeanDumper objects were updated to use config objects.
I disagree that the YAML 1.2 specification is necessarily a needed or
wanted feature. As I understand it, this specification is still
incomplete. While it is possible to implement it while it is still a
draft, I don't see that the 1.2 specification brings any major changes
to improve the language or make users' lives easier.
I will expand on proposals 3 and 4 below:
Proposal 3:
Currently, the Constructor object contains both the current "state" of
construction, as well as a "configuration" of how Construction should
proceed. The state is held in many of the fields in BaseConstructor,
SafeConstructor and Constructor, and is specific to a single document.
Additionally, these objects contain collections of Construct instances
that describe a way of transforming the composed tree into Java
objects. Much of SnakeYaml's existing configurability comes from
extending Constructor to modify the contents of those collections (see
ClassConstructor, among many other examples in tests).
The proposal here is to separate these two halves. The configuration
(Construct instances and the getConstructor implementation) can be
separated from the objects representing the state of I/O. A new
object, "ConstructorRegistry" or "ConstructorManager" or whatever,
provides the getConstructor implementation.
The proposal also applies to BaseRepresenter, SafeRepresenter,
Representer, and Represent instances. The parallel is obvious.
The advantage is that once these objects are separated, it becomes
much easier to (de)serialize the configuration objects. Additionally,
once a configuration is created, it may be re-used over and over, in
many threads. This may reduce the amount of code required to configure
SnakeYaml (I have seen that this happens in the tests, though the real
world may vary).
Proposal 4:
By removing the distinction between BaseConstructor, SafeConstructor
and Constructor, the flow of control when objects are constructed
becomes simpler to deal with. The choice of Base / Safe / Standard
Constructor is instead handled by configuration objects. After
removing the Construct instances particular to each configuration, the
three classes very similar and offer no real distinction.
I will create a clone to make these changes as neatly as possible
soon. I will probably not have time until after the weekend, at the
earliest.
Thank you for taking the time to read and respond,
/Jordan