enum convertion added
This commit is contained in:
parent
786b297972
commit
46c0f736ac
|
|
@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonValue
|
|||
*/
|
||||
enum class {{ name }}(val code: {{ utils.formatEnumValueType(valuesTypes) }}) {
|
||||
|
||||
{%- include 'blocks/enum/cases.twig' with { values: values } %}
|
||||
{%- include 'blocks/enum/cases.twig' with { valuesTypes: valuesTypes, values: values } %}
|
||||
|
||||
@JsonValue
|
||||
fun toValue() = code
|
||||
|
|
|
|||
|
|
@ -6,5 +6,5 @@
|
|||
* {{ value.description }}
|
||||
*/
|
||||
{%- endif %}
|
||||
{{ value.nameUpperCaseWithUnderscope }}{%- if not (loop.last) %},{% else %};{% endif %}
|
||||
{{ value.nameUpperCaseWithUnderscope }}({{ utils.formatEnumValue(valuesTypes, value) }}){%- if not (loop.last) %},{% else %};{% endif %}
|
||||
{%- endfor -%}
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
|
||||
{%- if storable %}
|
||||
|
||||
@TypeConverter
|
||||
@Nullable
|
||||
public static String serialize(@Nullable final {{ name }} value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return value.name();
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
@Nullable
|
||||
public static {{ name }} deserialize(@Nullable final String value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return {{ name }}.valueOf(value);
|
||||
}
|
||||
|
||||
{%- endif -%}
|
||||
|
|
@ -33,4 +33,8 @@ List<{{ self.formatValueType(valueType.itemsType, true, true) }}>
|
|||
|
||||
{% macro formatEnumValueType(valuesTypes) %}
|
||||
{%- if valuesTypes == "STRING" -%}String{%- elseif valuesTypes == "INT" -%}Int{%- endif -%}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro formatEnumValue(valuesTypes, value) %}
|
||||
{%- if valuesTypes == "STRING" -%}"{{ value.value }}"{%- elseif valuesTypes == "INT" -%}{{ value.value }}{%- endif -%}
|
||||
{% endmacro %}
|
||||
Loading…
Reference in New Issue