Fields generation added
This commit is contained in:
parent
1cd0fe5317
commit
e94caa429e
|
|
@ -13,16 +13,14 @@ import ru.touchin.templates.logansquare.LoganSquareJsonModel;
|
|||
*/
|
||||
@JsonObject(serializeNullObjects = true)
|
||||
public class {% include 'blocks/class/classtype.twig' with { type: type } %} extends {% include 'blocks/class/supertype.twig' with { type: type, parent: parent } %} {
|
||||
|
||||
{% include 'blocks/class/fields.twig' with { fields: fields } %}
|
||||
public {{ type.baseTypeName }}() {
|
||||
super();
|
||||
}
|
||||
|
||||
{% if (fields is not empty) %}
|
||||
{% if (allFieldsOrdered is not empty) %}
|
||||
public {{ type.baseTypeName }}({%- include 'blocks/class/init-parameters-fields.twig' with { fields: allFieldsOrdered } -%}) {
|
||||
super();
|
||||
super({%- include 'blocks/class/fields-super-initialization.twig' with { fields: superclassesFields } -%});
|
||||
{%- include 'blocks/class/fields-initialization.twig' with { fields: fields } %}
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{%- import '../../utils.twig' as utils -%}
|
||||
{%- for field in fields %}
|
||||
{%- if field.type.type.baseTypeName == "List" %}
|
||||
this.{{ field.name }} = new ArrayList<>({{ field.name }});
|
||||
{%- elseif field.type.type.baseTypeName == "Map" %}
|
||||
this.{{ field.name }} = new HashMap<>({{ field.name }});
|
||||
{%- else %}
|
||||
//TODO NULLABLE COLLECTIONS
|
||||
this.{{ field.name }} = {{ field.name }};
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{%- if fields is not empty -%}
|
||||
{%- for field in fields -%}
|
||||
{{ field.name }} {%- if not (loop.last) %}, {% endif %}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{%- import '../../utils.twig' as utils -%}
|
||||
|
||||
{%- if fields is not empty -%}
|
||||
{% for field in fields %}
|
||||
/**
|
||||
* {{ field.description }}
|
||||
*/
|
||||
@JsonField(name = "{{ field.jsonName }}")
|
||||
{{ utils.writeNullCheckAnnotation(field.type.type.baseTypeName, field.nullable, field.optional) }}
|
||||
private {{ utils.formatValueType(field.type.type, field.nullable, field.optional) }} {{ field.name }};
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
|
|
@ -23,7 +23,7 @@ LoganSquareJsonModel
|
|||
@NonNull
|
||||
{%- elseif nullable -%}
|
||||
@Nullable
|
||||
{%- elseif not (baseTypeName == "Int" or baseTypeName == "Long" or baseTypeName == "Double" or baseTypeName == "Decimal" or baseTypeName == "Bool") -%}
|
||||
{%- elseif not (baseTypeName == "Int" or baseTypeName == "Long" or baseTypeName == "Double" or baseTypeName == "Bool") -%}
|
||||
@NonNull
|
||||
{%- endif -%}
|
||||
{% endmacro %}
|
||||
|
|
|
|||
Loading…
Reference in New Issue