Separate out builder/impl copy generators 66/76866/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 10 Oct 2018 17:43:41 +0000 (19:43 +0200)
committerRobert Varga <nite@hq.sk>
Thu, 11 Oct 2018 10:43:50 +0000 (10:43 +0000)
commita143754a66741e6dc8ce0ab25d6479ed9e266db5
tree7c90828db00ac4786fc80f4ee817710b32f617cc
parenta1e19889a714901902548430031ab94be63ca655
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>
(cherry picked from commit 3a2c2590fe64953e59953c9a7dde5e97ecfe34ec)
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