From 04c19403438ee79168da22ed16e46bcfc4359540 Mon Sep 17 00:00:00 2001 From: Vivin Paliath Date: Tue, 16 Feb 2016 09:07:47 -0700 Subject: [PATCH] Fix for issue #2117 This change adds `this` to field names in `equals` within `pojo.mustache` so that an incorrect `equals` method is not generated in cases where a class has an internal field that is the same as the `classVarName` of the class. --- modules/swagger-codegen/src/main/resources/Java/pojo.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/Java/pojo.mustache b/modules/swagger-codegen/src/main/resources/Java/pojo.mustache index c8c6b885379..8bbb36a8014 100644 --- a/modules/swagger-codegen/src/main/resources/Java/pojo.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/pojo.mustache @@ -41,7 +41,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali } {{classname}} {{classVarName}} = ({{classname}}) o; - return true {{#hasVars}}&& {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} && + return true {{#hasVars}}&& {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && {{/hasMore}}{{/vars}}{{/hasVars}} {{#parent}}&& super.equals(o){{/parent}}; }