From: Robert Varga Date: Wed, 22 Feb 2023 19:03:31 +0000 (+0100) Subject: Reduce bindingEquals() verbosity X-Git-Tag: v11.0.7~5 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=76618bff5fe7d72e5dbcf7897e3054903d3960e0;p=mdsal.git Reduce bindingEquals() verbosity We are generating a cascade of checks, all of which must pass for us to return 'true'. Rather that generating a number of 'if/return' blocks, use a single expression to achieve the same result. Change-Id: I13c7abe4ef81d2a2822b6b4d0456f277dd5ce288 Signed-off-by: Robert Varga --- diff --git a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/InterfaceTemplate.xtend b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/InterfaceTemplate.xtend index 51ac7be063..e2b4215b4b 100644 --- a/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/InterfaceTemplate.xtend +++ b/binding/mdsal-binding-java-api-generator/src/main/java/org/opendaylight/mdsal/binding/java/api/generator/InterfaceTemplate.xtend @@ -331,16 +331,12 @@ class InterfaceTemplate extends BaseTemplate { if (thisObj == obj) { return true; } - final «type.fullyQualifiedName» other = «CODEHELPERS.importedName».checkCast(«type.fullyQualifiedName».class, obj); - if (other == null) { - return false; - } - «FOR property : ByTypeMemberComparator.sort(typeAnalysis.value)» - if (!«property.importedUtilClass».equals(thisObj.«property.getterName»(), other.«property.getterName»())) { - return false; - } - «ENDFOR» - return «IF augmentable»thisObj.augmentations().equals(other.augmentations())«ELSE»true«ENDIF»; + final var other = «CODEHELPERS.importedName».checkCast(«type.fullyQualifiedName».class, obj); + return other != null + «FOR property : ByTypeMemberComparator.sort(typeAnalysis.value)» + && «property.importedUtilClass».equals(thisObj.«property.getterName»(), other.«property.getterName»()) + «ENDFOR» + «IF augmentable»&& thisObj.augmentations().equals(other.augmentations())«ENDIF»; } «ENDIF» '''