Skip to content

Commit 41282ce

Browse files
committed
feat: add java enum
1 parent 0f60155 commit 41282ce

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

templates/cli/lib/type-generation/languages/dart.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import '<%- attribute.relatedCollection.toLowerCase() %>.dart';
5252
<% if (attribute.format === 'enum') { -%>
5353
enum <%- toPascalCase(attribute.key) %> {
5454
<% for (const element of attribute.elements) { -%>
55-
<%- toPascalCase(element) %>,
55+
<%- element %>,
5656
<% } -%>
5757
}
5858

templates/cli/lib/type-generation/languages/java.js.twig

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ class Java extends LanguageMeta {
99
case AttributeType.STRING:
1010
case AttributeType.EMAIL:
1111
case AttributeType.DATETIME:
12-
case AttributeType.ENUM:
1312
type = "String";
13+
if (attribute.format === AttributeType.ENUM) {
14+
type = LanguageMeta.toPascalCase(attribute.key);
15+
}
1416
break;
1517
case AttributeType.INTEGER:
1618
type = "int";
@@ -47,6 +49,17 @@ import <%- toPascalCase(attribute.relatedCollection) %>;
4749
<% } -%>
4850
<% } -%>
4951
public class <%- toPascalCase(collection.name) %> {
52+
<% for (const attribute of collection.attributes) { -%>
53+
<% if (attribute.format === 'enum') { -%>
54+
55+
public enum <%- toPascalCase(attribute.key) %> {
56+
<% for (const [index, element] of Object.entries(attribute.elements)) { -%>
57+
<%- element %><%- index < attribute.elements.length - 1 ? ',' : ';' %>
58+
<% } -%>
59+
}
60+
61+
<% } -%>
62+
<% } -%>
5063
<% for (const attribute of collection.attributes) { -%>
5164
private <%- getType(attribute) %> <%= toCamelCase(attribute.key) %>;
5265
<% } -%>

0 commit comments

Comments
 (0)