Yang code generator cleanup 70/25570/5
authorStephen Kitt <skitt@redhat.com>
Fri, 21 Aug 2015 11:26:10 +0000 (13:26 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 18 Sep 2015 09:27:08 +0000 (09:27 +0000)
commitdd65a7ecf4237d0e11e01f71d2184c2bc9de2895
treedfbb2ed0fa6c4f1bb7aad8eb3ffef66c2e210b43
parent5c900a0f949b20d13e91a5464ccc292415b90cc5
Yang code generator cleanup

Two axes:
* make the generated code slightly better
* make the generator code slightly better

Fixes in generator code:
* fields which can be local variables
* map overwrite detection using put()'s return value
* logging with exceptions
* using File's parent/child handling instead of concatenating strings
* if (condition) { return true; } else { return false; }
  simplification
* if (... == false) -> if (!...)
* interface method declarations are public by default
* Collections.singletonList() instead of Arrays.asList() for
  single-item collections
* StringBuilder instead of StringBuffer
* String concatenation instead of straight-forward StringBuilder
  (i.e. non-conditional append() calls)
* typos: hierarchchical -> hierarchical, intends -> indents
* drop unused parameter from
  AbstractAttributesProcessor::processAttributes()
* when processing only values in a map, use .values() rather than
  .entrySet()
* split StringBuilder::append(a + b) into two ::append() calls
* clean up the method parameter construction in MethodSerializer (to
  avoid deleting the ", " at the end)

Fixes in generated code:
* use { } as requested the Checkstyle rules
* handle empty service interface sets explicitly

It would be nice to use the <> operator without specifying the type
where possible, but the Eclipse AST parser used in the unit tests is
too old for this (so the generated code is correct and works
elsewhere, but fails the unit tests).

Change-Id: I725ce8d98f9ee389d394772733663ecacaccf8fa
Signed-off-by: Stephen Kitt <skitt@redhat.com>
15 files changed:
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGenerator.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/FtlTemplate.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/RuntimeRegistratorFtlTemplate.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/TemplateFactory.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/TypeHelper.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/ConstructorSerializer.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/FieldSerializer.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/HeaderSerializer.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/MethodSerializer.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/model/ModuleFieldSerializer.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsFactoryGeneratedObjectFactory.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsModuleGeneratedObjectFactory.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/ConcreteModuleGeneratedObjectFactory.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/java/GeneratedObjectBuilder.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/util/StringUtil.java

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.