Flatten submodule hierarchy for YangModuleInfo 70/82670/1
authorAnna Bencurova <Anna.Bencurova@pantheon.tech>
Mon, 10 Jun 2019 12:55:49 +0000 (14:55 +0200)
committerRobert Varga <nite@hq.sk>
Sun, 23 Jun 2019 19:20:48 +0000 (19:20 +0000)
commit8ec9ec39bf4d487a0f0c7a45c85d26ebddb3e1a5
treef4fe7fb0cef700bab7a7c55d2135f38de37f11c6
parentfb01cab21810bc20b598f4144452e67dece2da58
Flatten submodule hierarchy for YangModuleInfo

YANG inherently contains modules and submodules, where submodules
do not really have further submodules. While YANG 1.0 allowed
inclusion of submodules in other submodules, and that is modeled
in yang-model-api, this practice has been deprecated with YANG 1.1.

If we are faced with multiple such includes, for example both
module and submodule including a second submodule, we could end up
generating superfluous classes, just to represent the second
submodule twice (once for module's purposes and once for submodule's
purposes) -- hence when all of them are collected recursively, we
would end up with two distinct instances for the same source.

Since submodules are not directly visible outside of the main class,
this hierarchy is not public API and is a purely internal thing.

This patch re-organizes generation so that we present all submodules
as dependencies of the main module, which automatically solves the
problem, while also making for nicer class layout, as we do not get
multiply-nested classes.

JIRA: MDSAL-457
Change-Id: Ic78edaf852f3497f3c4c96fdca3a77de30b7f8c1
Signed-off-by: Anna Bencurova <Anna.Bencurova@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4a8ae0d2fbffc56edc956cde9a9ecde28f3e9a34)
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/YangModuleInfoTemplate.xtend