51 lines
1.8 KiB
Twig
51 lines
1.8 KiB
Twig
{%- import 'macroses/common.utils.twig' as utils -%}
|
|
{%- import 'macroses/class.utils.twig' as classUtils -%}
|
|
|
|
{%- set hasParent = parent is not null -%}
|
|
{%- set classType = classUtils.classType(type) -%}
|
|
{%- set parentClassType = classUtils.parentClassType(parent, type.parentTypeParameters) -%}
|
|
|
|
import ObjectMapper
|
|
|
|
{%- include 'blocks/class/date-transformers.twig' with { fields: fields } %}
|
|
|
|
/// {{ description }}
|
|
{% if (not hasChilds) -%}final {% endif %}class {{ classType }}: {{ parentClassType }} {
|
|
|
|
{% include 'blocks/class/fields.twig' with { fields: fields } %}
|
|
// MARK: - Initializers
|
|
|
|
{% if (hasParent and (fields is empty)) %} override {% endif %}init({%- include 'blocks/class/init-parameters-fields.twig' with { fields: allFieldsOrdered } -%}) {
|
|
{%- include 'blocks/class/fields-initialization.twig' with { fields: fields } -%}
|
|
{% if hasParent %}
|
|
super.init({%- include 'blocks/class/fields-super-initialization.twig' with { fields: superclassesFields } -%})
|
|
{%- endif %}
|
|
}
|
|
|
|
required init(map: Map) throws {
|
|
{%- include 'blocks/class/fields-mapping-from-map.twig' with { fields: fields } -%}
|
|
{% if hasParent %}
|
|
try super.init(map: map)
|
|
{%- endif %}
|
|
}
|
|
|
|
{% if hasParent %} override {% endif %}func mapping(map: Map) {
|
|
{%- include 'blocks/class/fields-mapping-to-map.twig' with { fields: fields } -%}
|
|
{% if hasParent %}
|
|
super.mapping(map: map)
|
|
{%- endif %}
|
|
}
|
|
|
|
}
|
|
{#
|
|
{% 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 -%}
|
|
#} |