Skip to content

Commit

Permalink
3.2.6
Browse files Browse the repository at this point in the history
Fix the Table Row Class Generate Source Code, to avoid non-null check in nullable declared field.

Signed-off-by: Sinri Edogawa <[email protected]>
  • Loading branch information
sinri committed May 6, 2024
1 parent 67a6b9b commit a3421ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

<groupId>io.github.sinri</groupId>
<artifactId>Keel</artifactId>
<version>3.2.6-SNAPSHOT</version>
<!-- <version>3.2.5</version>-->
<!-- <version>3.2.6-SNAPSHOT</version>-->
<version>3.2.6</version>

<name>Keel</name>
<description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,14 @@ public String build() {
}
code
.append("\tpublic ").append(looseEnum.looseEnumName()).append(" ").append(getter).append("() {\n")
.append("\t\treturn ").append(looseEnum.looseEnumName()).append(".valueOf(\n")
.append("\t\t\t")
.append(nullable ? "" : "Objects.requireNonNull(")
.append(readMethod).append("(\"").append(field).append("\")")
.append(nullable ? "" : ")").append("\n")
.append("\t\t);\n")
.append("\t\t@Nullable String enumExpression=").append(readMethod).append("(\"").append(field).append("\");\n");
if (nullable) {
code.append("\t\tif (enumExpression==null) return null;\n");
} else {
code.append("\t\tObjects.requireNonNull(enumExpression,\"The Enum Field `").append(field).append("` should not be null!\");\n");
}
code
.append("\t\treturn ").append(looseEnum.looseEnumName()).append(".valueOf(enumExpression);\n")
.append("\t}\n");
} else if (strictEnum != null) {
code.append("\t/*\n")
Expand All @@ -185,12 +187,14 @@ public String build() {
}
code
.append("\tpublic ").append(strictEnum.fullEnumRef()).append(" ").append(getter).append("() {\n")
.append("\t\treturn ").append(strictEnum.fullEnumRef()).append(".valueOf(\n")
.append("\t\t\t")
.append(nullable ? "" : "Objects.requireNonNull(")
.append(readMethod).append("(\"").append(field).append("\")")
.append(nullable ? "" : ")").append("\n")
.append("\t\t);\n")
.append("\t\t@Nullable String enumExpression=").append(readMethod).append("(\"").append(field).append("\");\n");
if (nullable) {
code.append("\t\tif (enumExpression==null) return null;\n");
} else {
code.append("\t\tObjects.requireNonNull(enumExpression,\"The Enum Field `").append(field).append("` should not be null!\");\n");
}
code
.append("\t\treturn ").append(strictEnum.fullEnumRef()).append(".valueOf(enumExpression);\n")
.append("\t}\n");
} else {
code.append("\t/*\n");
Expand Down

0 comments on commit a3421ac

Please sign in to comment.