Separate out builder/impl copy generators 29/76829/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 10 Oct 2018 17:43:41 +0000 (19:43 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 11 Oct 2018 00:20:35 +0000 (02:20 +0200)
commit3a2c2590fe64953e59953c9a7dde5e97ecfe34ec
tree0e1f3f560ad4286c610fa6592b2a027dfb8abe05
parentb03a5281a57304ec97234fb4243cee15728b1c33
Separate out builder/impl copy generators

Builders are taking an immutable implementation of target type,
hence for list entries they can rely on the key to be present and
do not have to check it. Implementations need to account
for the builder key being set to null, hence they need to
instantiate the key themselves.

This patch separates the two code paths, so both cases are properly
expressed in the object hierarchy. This allows us to simplify
the abstract template, removing weird boolean-based decisions.

We also promote implementation constructor to package-visible, which
allows javac to skip generation of synthetic accessor.

We further optimize the template output by capturing importedNames
when they are reused -- leading to xtend generating cleaner Java code.

JIRA: MDSAL-374
Change-Id: I3274e35780b8e6a56d470caf80459e9e115a5374
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/AbstractBuilderTemplate.xtend
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/BuilderImplTemplate.xtend
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/BuilderTemplate.xtend