parent
67b5fe0809
commit
d944d4d5ee
|
|
@ -37,3 +37,13 @@ import ObjectMapper
|
|||
}
|
||||
|
||||
}
|
||||
{% if not hasChilds %}
|
||||
extension {{ type.baseTypeName }}: Equatable {
|
||||
|
||||
static func ==(lhs: {{ classType }}, rhs: {{ classType }}) -> Bool {
|
||||
return {%- for field in allFieldsOrdered %} lhs.{{ field.name }} == rhs.{{ field.name }} {% if not (loop.last) -%} && {%- endif %}
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
}
|
||||
{% endif -%}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
{%- import '../../macroses/common.utils.twig' as utils -%}
|
||||
{%- macro hashOf(name, type, optional, nullable, ) -%}
|
||||
{%- if type.baseTypeName == "Array" -%}
|
||||
{#- implement hash for Array -#}
|
||||
{%- elseif type.baseTypeName == "Map" -%}
|
||||
{#- implement hash for Map -#}
|
||||
{%- else -%}
|
||||
{#- implement hash for regular value -#}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- for field in fields %}
|
||||
{#- FIXME: Value of type '[T]' has no member 'hashValue'} -#}
|
||||
{#- FIXME: The same for [TKey: TValue] -#}
|
||||
{%- if field.optional or field.nullable %}
|
||||
({{ field.name }}?.hashValue ?? 0)
|
||||
{%- else %}
|
||||
{{ field.name }}.hashValue
|
||||
{%- endif -%}
|
||||
{% if not (loop.last) %} ^ {%- endif %}
|
||||
{%- endfor -%}
|
||||
Loading…
Reference in New Issue