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 <robert.varga@pantheon.tech>
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»
'''