OLD | NEW |
1 {%- macro enum_value(enum, field, index) -%} | 1 {%- macro enum_value(enum, field, index) -%} |
2 {%- if field.value -%} | 2 {%- if field.value -%} |
3 (int) ({{field.value|expression_to_text('i32')}}) | 3 (int) ({{field.value|expression_to_text('i32')}}) |
4 {%- elif index == 0 -%} | 4 {%- elif index == 0 -%} |
5 0 | 5 0 |
6 {%- else -%} | 6 {%- else -%} |
7 {{enum.fields[index - 1].name}} + 1 | 7 {{enum.fields[index - 1]|name}} + 1 |
8 {%- endif -%} | 8 {%- endif -%} |
9 {%- endmacro -%} | 9 {%- endmacro -%} |
10 | 10 |
11 {%- macro enum_def(enum, top_level) -%} | 11 {%- macro enum_def(enum, top_level) -%} |
12 public {{ 'static ' if not top_level }}final class {{enum|name}} { | 12 public {{ 'static ' if not top_level }}final class {{enum|name}} { |
13 | 13 |
14 {% for field in enum.fields %} | 14 {% for field in enum.fields %} |
15 public static final int {{field.name}} = {{enum_value(enum, field, loop.inde
x0)}}; | 15 public static final int {{field|name}} = {{enum_value(enum, field, loop.inde
x0)}}; |
16 {% endfor %} | 16 {% endfor %} |
17 | 17 |
18 private {{enum|name}}() {} | 18 private {{enum|name}}() {} |
19 | 19 |
20 } | 20 } |
21 {%- endmacro -%} | 21 {%- endmacro -%} |
OLD | NEW |