Equals and hashcode should evaluate just identifier. For change detection between commits, new method
isSame has been added. Fields that are arrays now use Arrays.equals instead of wrong equals.
Change-Id: I63cb29027c07b9737532d7faa75729ea026ffe20
Signed-off-by: Tomas Olvecky <tolvecky@cisco.com>
public String getDefinition() {
return definition;
}
+
+ public boolean isArray() {
+ return type.endsWith("[]");
+ }
}
dependencyResolver.validateDependency(${field.dependency.sie.fullyQualifiedName}.class, ${field.name}, ${field.name}JmxAttribute);
</#if>
</#list>
+ customValidation();
+ }
+
+ protected void customValidation(){
+
}
// caches of resolved dependencies
public boolean canReuseInstance(${typeDeclaration.name} oldModule){
// allow reusing of old instance if no parameters was changed
- return equals(oldModule);
+ return isSame(oldModule);
}
public ${instanceType} reuseInstance(${instanceType} oldInstance){
public abstract ${instanceType} createInstance();
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ${typeDeclaration.name} other = (${typeDeclaration.name}) obj;
-
-
+ public boolean isSame(${typeDeclaration.name} other) {
+ if (other == null) {
+ throw new IllegalArgumentException("Parameter 'other' is null");
+ }
<#list moduleFields as field>
<#if field.dependent==true>
if (${field.name}Dependency == null) {
if (other.${field.name}Dependency != null)
return false;
- } else if (!${field.name}Dependency.equals(other.${field.name}Dependency))
+ } else if (!${field.name}Dependency.equals(other.${field.name}Dependency)) {
return false;
+ }
<#else>
if (${field.name} == null) {
- if (other.${field.name} != null)
+ if (other.${field.name} != null) {
return false;
- } else if (!${field.name}.equals(other.${field.name}))
+ }
+ } else if
+ <#if field.array == false>
+ (${field.name}.equals(other.${field.name}) == false)
+ <#else>
+ (java.util.Arrays.equals(${field.name},other.${field.name}) == false)
+ </#if>
+ {
return false;
+ }
</#if>
</#list>
return true;
}
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ${typeDeclaration.name} that = (${typeDeclaration.name}) o;
+
+ return identifier.equals(that.identifier);
+ }
+
+ @Override
+ public int hashCode() {
+ return identifier.hashCode();
+ }
}
package ${packageName};
<@javadocD object=javadoc/>
-<@typeDeclarationD object=typeDeclaration/>
-{
+<@typeDeclarationD object=typeDeclaration/> {
public ${typeDeclaration.name}(${moduleNameType} identifier, ${dependencyResolverType} dependencyResolver) {
super(identifier, dependencyResolver);
}
- public ${typeDeclaration.name}(${moduleNameType} identifier, ${dependencyResolverType} dependencyResolver, ${typeDeclaration.name} oldModule, ${instanceType} oldInstance) {
+ public ${typeDeclaration.name}(${moduleNameType} identifier, ${dependencyResolverType} dependencyResolver,
+ ${typeDeclaration.name} oldModule, ${instanceType} oldInstance) {
+
super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
- public void validate(){
- super.validate();
+ protected void customValidation(){
// Add custom validation for module attributes here.
}
assertContains(reqIfc, PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX
+ ".threads.ThreadFactoryServiceInterface");
- assertEquals("Incorrenct number of generated methods", 24,
+ assertEquals("Incorrenct number of generated methods", 27,
visitor.methods.size());
assertEquals("Incorrenct number of generated method descriptions", 3,
visitor.methodDescriptions.size());
-/**
- * Generated file
-
- * Generated from: yang module name: config-test-impl yang module local name: impl-dep
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Fri Sep 27 13:02:28 CEST 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
package org.opendaylight.controller.config.yang.test.impl;
-
/**
*
*/
-public final class DepTestImplModule
- extends
- org.opendaylight.controller.config.yang.test.impl.AbstractDepTestImplModule {
+public final class DepTestImplModule extends org.opendaylight.controller.config.yang.test.impl.AbstractDepTestImplModule
+ {
- public DepTestImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(name, dependencyResolver);
+ public DepTestImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
}
- public DepTestImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ public DepTestImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
DepTestImplModule oldModule, java.lang.AutoCloseable oldInstance) {
- super(name, dependencyResolver, oldModule, oldInstance);
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
- public void validate() {
- super.validate();
+ protected void customValidation(){
// Add custom validation for module attributes here.
}
}
};
}
-
}
-/**
- * Generated file
-
- * Generated from: yang module name: config-test-impl yang module local name: impl-dep
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Fri Sep 27 13:02:28 CEST 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
package org.opendaylight.controller.config.yang.test.impl;
/**
*
*/
-public class DepTestImplModuleFactory
- extends
- org.opendaylight.controller.config.yang.test.impl.AbstractDepTestImplModuleFactory {
+public class DepTestImplModuleFactory extends org.opendaylight.controller.config.yang.test.impl.AbstractDepTestImplModuleFactory
+{
+
}
--- /dev/null
+ return new AutoCloseable() {
+ @Override
+ public void close() throws Exception {
+ }
+ };
-/**
- * Generated file
-
- * Generated from: yang module name: config-test-impl yang module local name: impl-netconf
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Fri Sep 27 13:02:28 CEST 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
package org.opendaylight.controller.config.yang.test.impl;
-
-import com.google.common.collect.Lists;
-
-import java.util.List;
-
/**
*
*/
-public final class NetconfTestImplModule
- extends
- org.opendaylight.controller.config.yang.test.impl.AbstractNetconfTestImplModule {
+public final class NetconfTestImplModule extends org.opendaylight.controller.config.yang.test.impl.AbstractNetconfTestImplModule
+ {
- public NetconfTestImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(name, dependencyResolver);
+ public NetconfTestImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
}
- public NetconfTestImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ public NetconfTestImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
NetconfTestImplModule oldModule, java.lang.AutoCloseable oldInstance) {
- super(name, dependencyResolver, oldModule, oldInstance);
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
- public void validate() {
- super.validate();
+ protected void customValidation(){
// Add custom validation for module attributes here.
}
@Override
public java.lang.AutoCloseable createInstance() {
- return registerRuntimeBeans();
+ return NetconfTestImplModuleUtil.registerRuntimeBeans(this);
}
-
- private NetconfTestImplRuntimeRegistration registerRuntimeBeans() {
- NetconfTestImplRuntimeRegistration reg = getRootRuntimeBeanRegistratorWrapper().register(new NetconfTestImplRuntimeMXBean() {
-
- @Override
- public Long getCreatedSessions() {
- return getSimpleLong();
- }
-
- @Override
- public Asdf getAsdf() {
- final Asdf asdf = new Asdf();
- asdf.setSimpleString("asdf");
- return asdf;
- }
-
- @Override
- public String noArg(final String arg1) {
- return arg1.toUpperCase();
- }
-
- });
-
- for (int i = 0; i < getSimpleShort(); i++) {
- final int finalI = i;
-
- reg.register(new InnerRunningDataAdditionalRuntimeMXBean() {
- @Override
- public Integer getSimpleInt3() {
- return getSimpleTest();
- }
-
- @Override
- public Deep4 getDeep4() {
- final Deep4 d = new Deep4();
- d.setBoool(false);
- return d;
- }
-
- @Override
- public String getSimpleString() {
- return Integer.toString(finalI);
- }
-
- @Override
- public void noArgInner() {
- }
- });
-
- InnerRunningDataRuntimeRegistration innerReg = reg.register(new InnerRunningDataRuntimeMXBean() {
- @Override
- public Integer getSimpleInt3() {
- return finalI;
- }
-
- @Override
- public Deep2 getDeep2() {
- return new Deep2();
- }
- });
-
- for (int j = 0; j < getSimpleShort(); j++) {
- final int finalJ = j;
- innerReg.register(new InnerInnerRunningDataRuntimeMXBean() {
- @Override
- public List<NotStateBean> getNotStateBean() {
- NotStateBean b1 = new NotStateBean();
- b1.setElement("not state");
- return Lists.newArrayList(b1);
- }
-
- @Override
- public Integer getSimpleInt3() {
- return finalJ;
- }
-
- @Override
- public Deep3 getDeep3() {
- return new Deep3();
- }
-
- @Override
- public List<String> getListOfStrings() {
- return Lists.newArrayList("l1", "l2");
- }
-
- @Override
- public List<RetValList> listOutput() {
- return Lists.newArrayList(new RetValList());
- }
-
- @Override
- public Boolean noArgInnerInner(Integer integer, Boolean aBoolean) {
- return aBoolean;
- }
-
- @Override
- public RetValContainer containerOutput() {
- return new RetValContainer();
- }
-
- @Override
- public List<String> leafListOutput() {
- return Lists.newArrayList("1", "2");
- }
- });
- }
- }
-
- return reg;
- }
-
}
-/**
- * Generated file
-
- * Generated from: yang module name: config-test-impl yang module local name: impl-netconf
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Fri Sep 27 13:02:28 CEST 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
package org.opendaylight.controller.config.yang.test.impl;
/**
*
*/
-public class NetconfTestImplModuleFactory
- extends
- org.opendaylight.controller.config.yang.test.impl.AbstractNetconfTestImplModuleFactory {
+public class NetconfTestImplModuleFactory extends org.opendaylight.controller.config.yang.test.impl.AbstractNetconfTestImplModuleFactory
+{
+
}
--- /dev/null
+return NetconfTestImplModuleUtil.registerRuntimeBeans(this);
--- /dev/null
+/**
+ * @author Tomas Olvecky
+ *
+ * 11 2013
+ *
+ * Copyright (c) 2013 by Cisco Systems, Inc.
+ * All rights reserved.
+ */
+package org.opendaylight.controller.config.yang.test.impl;
+
+import com.google.common.collect.Lists;
+
+import java.util.List;
+
+public class NetconfTestImplModuleUtil {
+ static NetconfTestImplRuntimeRegistration registerRuntimeBeans(final NetconfTestImplModule module) {
+ NetconfTestImplRuntimeRegistration reg = module.getRootRuntimeBeanRegistratorWrapper().register(new NetconfTestImplRuntimeMXBean() {
+
+ @Override
+ public Long getCreatedSessions() {
+ return module.getSimpleLong();
+ }
+
+ @Override
+ public Asdf getAsdf() {
+ final Asdf asdf = new Asdf();
+ asdf.setSimpleString("asdf");
+ return asdf;
+ }
+
+ @Override
+ public String noArg(final String arg1) {
+ return arg1.toUpperCase();
+ }
+
+ });
+
+ for (int i = 0; i < module.getSimpleShort(); i++) {
+ final int finalI = i;
+
+ reg.register(new InnerRunningDataAdditionalRuntimeMXBean() {
+ @Override
+ public Integer getSimpleInt3() {
+ return module.getSimpleTest();
+ }
+
+ @Override
+ public Deep4 getDeep4() {
+ final Deep4 d = new Deep4();
+ d.setBoool(false);
+ return d;
+ }
+
+ @Override
+ public String getSimpleString() {
+ return Integer.toString(finalI);
+ }
+
+ @Override
+ public void noArgInner() {
+ }
+ });
+
+ InnerRunningDataRuntimeRegistration innerReg = reg.register(new InnerRunningDataRuntimeMXBean() {
+ @Override
+ public Integer getSimpleInt3() {
+ return finalI;
+ }
+
+ @Override
+ public Deep2 getDeep2() {
+ return new Deep2();
+ }
+ });
+
+ for (int j = 0; j < module.getSimpleShort(); j++) {
+ final int finalJ = j;
+ innerReg.register(new InnerInnerRunningDataRuntimeMXBean() {
+ @Override
+ public List<NotStateBean> getNotStateBean() {
+ NotStateBean b1 = new NotStateBean();
+ b1.setElement("not state");
+ return Lists.newArrayList(b1);
+ }
+
+ @Override
+ public Integer getSimpleInt3() {
+ return finalJ;
+ }
+
+ @Override
+ public Deep3 getDeep3() {
+ return new Deep3();
+ }
+
+ @Override
+ public List<String> getListOfStrings() {
+ return Lists.newArrayList("l1", "l2");
+ }
+
+ @Override
+ public List<RetValList> listOutput() {
+ return Lists.newArrayList(new RetValList());
+ }
+
+ @Override
+ public Boolean noArgInnerInner(Integer integer, Boolean aBoolean) {
+ return aBoolean;
+ }
+
+ @Override
+ public RetValContainer containerOutput() {
+ return new RetValContainer();
+ }
+
+ @Override
+ public List<String> leafListOutput() {
+ return Lists.newArrayList("1", "2");
+ }
+ });
+ }
+ }
+
+ return reg;
+ }
+}
-/**
- * Generated file
-
- * Generated from: yang module name: config-test-impl yang module local name: impl
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Fri Sep 27 13:02:28 CEST 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
package org.opendaylight.controller.config.yang.test.impl;
-
/**
*
*/
-public final class TestImplModule
- extends
- org.opendaylight.controller.config.yang.test.impl.AbstractTestImplModule {
+public final class TestImplModule extends org.opendaylight.controller.config.yang.test.impl.AbstractTestImplModule
+ {
- public TestImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(name, dependencyResolver);
+ public TestImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
}
- public TestImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ public TestImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
TestImplModule oldModule, java.lang.AutoCloseable oldInstance) {
- super(name, dependencyResolver, oldModule, oldInstance);
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
- public void validate() {
- super.validate();
+ protected void customValidation(){
// Add custom validation for module attributes here.
}
}
};
}
-
}
-/**
- * Generated file
-
- * Generated from: yang module name: config-test-impl yang module local name: impl
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Fri Sep 27 13:02:28 CEST 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
package org.opendaylight.controller.config.yang.test.impl;
/**
*
*/
-public class TestImplModuleFactory
- extends
- org.opendaylight.controller.config.yang.test.impl.AbstractTestImplModuleFactory {
+public class TestImplModuleFactory extends org.opendaylight.controller.config.yang.test.impl.AbstractTestImplModuleFactory
+{
+
}
--- /dev/null
+ return new AutoCloseable() {
+ @Override
+ public void close() throws Exception {
+ }
+ };