All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.java.equals.mustache Maven / Gradle / Ivy

There is a newer version: 0.113
Show newest version
{{&indent}}    @Override
{{&indent}}    public boolean equals(Object cg_other) {
{{&indent}}        if (this == cg_other)
{{&indent}}            return true;
{{&indent}}        if (!(cg_other instanceof {{&className}}))
{{&indent}}            return false;
{{#hasBaseClassWithProperties}}{{&indent}}        if (!super.equals(cg_other))
{{&indent}}            return false;
{{/hasBaseClassWithProperties}}{{#nonBaseProperties}}{{#first}}{{&indent}}        {{&className}} cg_typedOther = ({{&className}})cg_other;
{{/first}}{{#last}}{{#isPrimitive}}{{&indent}}        return {{&javaName}} == cg_typedOther.{{&javaName}};
{{/isPrimitive}}{{^isPrimitive}}{{#isEnumClass}}{{&indent}}        return {{&javaName}} == cg_typedOther.{{&javaName}};
{{/isEnumClass}}{{^isEnumClass}}{{#nullable}}{{&indent}}        return {{&javaName}} == null ? cg_typedOther.{{&javaName}} == null : {{&javaName}}.equals(cg_typedOther.{{&javaName}});
{{/nullable}}{{^nullable}}{{&indent}}        return {{&javaName}}.equals(cg_typedOther.{{&javaName}});
{{/nullable}}{{/isEnumClass}}{{/isPrimitive}}{{/last}}{{^last}}{{#isPrimitive}}{{&indent}}        if ({{&javaName}} != cg_typedOther.{{&javaName}})
{{/isPrimitive}}{{^isPrimitive}}{{#isEnumClass}}{{&indent}}        if ({{&javaName}} != cg_typedOther.{{&javaName}})
{{/isEnumClass}}{{^isEnumClass}}{{#nullable}}{{&indent}}        if ({{&javaName}} == null ? cg_typedOther.{{&javaName}} != null : !{{&javaName}}.equals(cg_typedOther.{{&javaName}}))
{{/nullable}}{{^nullable}}{{&indent}}        if (!{{&javaName}}.equals(cg_typedOther.{{&javaName}}))
{{/nullable}}{{/isEnumClass}}{{/isPrimitive}}{{! TODO check if property is array (do we ever use array?) and if so emit "Arrays.equals"
}}{{&indent}}            return false;
{{/last}}{{/nonBaseProperties}}{{^nonBaseProperties}}{{&indent}}        return true;
{{/nonBaseProperties}}{{&indent}}    }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy