*/
package org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory;
+import static com.google.common.base.Preconditions.checkState;
import static java.lang.String.format;
import com.google.common.base.Joiner;
"}\n", moduleField.getName(), osgi);
} else {
str = format(
- "%1$sDependency = dependencyResolver.resolveInstance(%2$s.class, %1$s, %1$sJmxAttribute);",
+ "%1$sDependency = dependencyResolver.resolveInstance(%2$s.class, %1$s, %1$sJmxAttribute);\n",
moduleField.getName(), osgi);
}
resolveDependenciesMap.put(moduleField, str);
// wrap each field resolvation statement with if !=null when dependency is not mandatory
for (Map.Entry<ModuleField, String> entry : resolveDependenciesMap.entrySet()) {
if (entry.getKey().getDependency().isMandatory() == false) {
- result += format("if (%s!=null) {\n%s;\n}", entry.getKey().getName(), entry.getValue());
+ checkState(entry.getValue().endsWith(";\n"));
+ result += format("if (%s!=null) {\n%s}\n", entry.getKey().getName(), entry.getValue());
} else {
result += entry.getValue();
}
format("private final %s oldModule;\n", abstractFQN.getTypeName())+
format("private final %s oldInstance;\n", AutoCloseable.class.getCanonicalName())+
format("private %s instance;\n", AutoCloseable.class.getCanonicalName())+
- format("private final %s dependencyResolver;\n", DependencyResolver.class.getCanonicalName())+
+ format("protected final %s dependencyResolver;\n", DependencyResolver.class.getCanonicalName())+
format("private final %s identifier;\n", ModuleIdentifier.class.getCanonicalName())+
"@Override\n"+
format("public %s getIdentifier() {\n", ModuleIdentifier.class.getCanonicalName())+
parameters.put(ModuleIdentifier.class.getCanonicalName(), "identifier");
parameters.put(DependencyResolver.class.getCanonicalName(), "dependencyResolver");
- String setToNulls = "this.oldInstance=null;\n;" +
+ String setToNulls = "this.oldInstance=null;\n" +
"this.oldModule=null;\n";
return getConstructorStart(abstractFQN, parameters, setToNulls);
}