Flatten submodule hierarchy for YangModuleInfo 70/82470/4
authorAnna Bencurova <Anna.Bencurova@pantheon.tech>
Mon, 10 Jun 2019 12:55:49 +0000 (14:55 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 21 Jun 2019 17:28:47 +0000 (19:28 +0200)
commit4a8ae0d2fbffc56edc956cde9a9ecde28f3e9a34
tree9cea58deca8ddd0527c43d040a2cf5395945beb3
parent7c3dc881d9310565ecac3ffde5a874ebe1d0c9ee
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>
binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/YangModuleInfoTemplate.xtend