import org.opendaylight.mdsal.binding.model.api.Restrictions
import org.opendaylight.mdsal.binding.model.api.Type
import org.opendaylight.mdsal.binding.model.ri.TypeConstants
+import org.opendaylight.mdsal.binding.model.ri.Types
import org.opendaylight.mdsal.binding.spec.naming.BindingMapping
import org.opendaylight.yangtools.yang.common.Empty
@«OVERRIDE.importedName»
public final boolean equals(«OBJECT.importedName» obj) {
return this == obj || obj instanceof «type.name» other
- «FOR property : genTO.equalsIdentifiers»
- «val fieldName = property.fieldName»
- && «property.importedUtilClass».equals(«fieldName», other.«fieldName»)«
- »«ENDFOR»;
+ «FOR property : genTO.equalsIdentifiers»
+ «val fieldName = property.fieldName»
+ «val type = property.returnType»
+ «IF type.equals(Types.primitiveBooleanType)»
+ && «fieldName» == other.«fieldName»«
+ »«ELSE»
+ && «type.importedUtilClass».equals(«fieldName», other.«fieldName»)«
+ »«ENDIF»«
+ »«ENDFOR»;
}
«ENDIF»
'''
* @return Imported class name
*/
final String importedUtilClass(final GeneratedProperty property) {
- return importedName(property.getReturnType().getName().indexOf('[') != -1 ? JU_ARRAYS : JU_OBJECTS);
+ return importedUtilClass(property.getReturnType());
+ }
+
+ /**
+ * Return imported name of java.util class, whose hashCode/equals methods we want to invoke for a type. Returns
+ * {@link Arrays} if the type is an array, {@link Objects} otherwise.
+ *
+ * @param returnType A property return Type
+ * @return Imported class name
+ */
+ final String importedUtilClass(final Type returnType) {
+ return importedName(returnType.getName().indexOf('[') != -1 ? JU_ARRAYS : JU_OBJECTS);
}
final String generatedAnnotation() {