api-generator-templates/Swift/blocks/class/fields-equal.twig

13 lines
632 B
Twig

{%- import '../../macroses/common.utils.twig' as utils -%}
{%- for field in fields -%}
{%- if (field.type.fields is not null) -%}
{%- if field.nullable or field.optional -%}
{{- field.name -}}?.isEqual(to: other.{{- field.name -}}) ?? (({{- field.name }} == nil) && (other.{{- field.name }} == nil))
{%- else -%}
{{- field.name -}}.isEqual(to: other.{{- field.name -}})
{%- endif -%}
{%- else -%}
{{- field.name }} == other.{{- field.name -}}
{%- endif -%}
{%- if not (loop.last) %} && {% endif -%}
{% endfor -%}