Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Generate comments for the default fields
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bluhm <bluhmdj@ornl.gov>
  • Loading branch information
dbluhm committed May 27, 2020
1 parent e2a3fb1 commit ea7f195
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Expand Up @@ -18,6 +18,7 @@ public class DefaultFields {
private static Field privateId = Field.builder()
.name("privateId")
.type(UUID.class)
.comment("The private UUID of this element. This field is left out of matches().")
.defaultValue(Field.raw("UUID.randomUUID()"))
.match(false)
.build();
Expand All @@ -28,6 +29,7 @@ public class DefaultFields {
private static Field id = Field.builder()
.name("id")
.type(long.class)
.comment("A unique identifier for this element.")
.defaultValue(0L)
.build();

Expand All @@ -37,6 +39,7 @@ public class DefaultFields {
private static Field name = Field.builder()
.name("name")
.type(String.class)
.comment("A simple name for the data.")
.defaultValue("name")
.build();

Expand All @@ -46,6 +49,7 @@ public class DefaultFields {
private static Field description = Field.builder()
.name("description")
.type(String.class)
.comment("A simple description of the data")
.defaultValue("description")
.build();

Expand All @@ -55,6 +59,7 @@ public class DefaultFields {
private static Field comment = Field.builder()
.name("comment")
.type(String.class)
.comment("A comment that annotates the data in a meaningful way.")
.defaultValue("no comment")
.build();

Expand All @@ -64,6 +69,7 @@ public class DefaultFields {
private static Field context = Field.builder()
.name("context")
.type(String.class)
.comment("The context (a tag) in which the data should be considered.")
.defaultValue("default")
.build();

Expand All @@ -73,6 +79,7 @@ public class DefaultFields {
private static Field required = Field.builder()
.name("required")
.type(boolean.class)
.comment("This value is true if the element should be regarded by the client as required.")
.defaultValue(false)
.build();

Expand All @@ -83,6 +90,7 @@ public class DefaultFields {
private static Field secret = Field.builder()
.name("secret")
.type(boolean.class)
.comment("This value is true if the element should be regarded as a secret by the client, such as for passwords.")
.defaultValue(false)
.build();

Expand All @@ -92,6 +100,7 @@ public class DefaultFields {
private static Field validator = Field.builder()
.name("validator")
.type(Field.raw("JavascriptValidator<$class>"))
.comment("The validator used to check the correctness of the data.")
.nullable(true)
.build();

Expand Down
Expand Up @@ -28,6 +28,11 @@ public class Field {
*/
String defaultValue;

/**
* Comment to add to the field declaration.
*/
String comment;

/**
* Whether or not this field can be null.
*
Expand Down
Expand Up @@ -34,6 +34,12 @@ public class ${class} implements ${interface}, Serializable, IDataElement {
private static final Logger logger = LoggerFactory.getLogger(${class}.class);

#foreach($field in $fields)

#if(${field.Comment})
/**
* ${field.Comment}
*/
#end
#if(!${field.Nullable} && !${field.Primitive}) @NonNull #else #{end}protected #evaluate(${field.Type}) ${field.Name}#if(${field.DefaultValue}) = #evaluate(${field.DefaultValue})#end;
#end

Expand Down

0 comments on commit ea7f195

Please sign in to comment.