File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
java/src/main/kotlin/io/spine/validation/java/setonce Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,12 @@ internal class SetOnceEnumField(
118
118
asEnumConstant(fieldValue)
119
119
120
120
/* *
121
- * Returns a string representation of the corresponding Java enum constant.
121
+ * Converts the given [fieldValue] to string for a diagnostics message.
122
+ *
123
+ * We have to override this method because within the builder, an enum constant
124
+ * is stored as [Int], but the [field] type is enum. This confuses the default
125
+ * implementation of [asString], which yields an expression to convert to [String]
126
+ * depending on the [field] type.
122
127
*/
123
128
override fun asString (fieldValue : Expression <Int >): Expression <String > =
124
129
fieldTypeClass
Original file line number Diff line number Diff line change @@ -148,6 +148,14 @@ internal class SetOnceStringField(
148
148
fieldProcessing.addAfter(precondition, fieldProcessing.lBrace)
149
149
}
150
150
151
+ /* *
152
+ * Converts the given [fieldValue] to string for a diagnostics message.
153
+ *
154
+ * We have to override this method because within the builder, a string is stored
155
+ * as [StringOrByteString], but the [field] type is just [String]. This confuses
156
+ * the default implementation of [asString], which yields an expression to convert
157
+ * to [String] depending on the [field] type.
158
+ */
151
159
override fun asString (fieldValue : Expression <StringOrByteString >): Expression <String > =
152
160
MethodCall (fieldValue, " toString" )
153
161
}
You can’t perform that action at this time.
0 commit comments