Skip to content

Commit 343072a

Browse files
author
yevhenii-nadtochii
committed
Document overridden methods
1 parent 320f77f commit 343072a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

java/src/main/kotlin/io/spine/validation/java/setonce/SetOnceEnumField.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@ internal class SetOnceEnumField(
118118
asEnumConstant(fieldValue)
119119

120120
/**
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.
122127
*/
123128
override fun asString(fieldValue: Expression<Int>): Expression<String> =
124129
fieldTypeClass

java/src/main/kotlin/io/spine/validation/java/setonce/SetOnceStringField.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ internal class SetOnceStringField(
148148
fieldProcessing.addAfter(precondition, fieldProcessing.lBrace)
149149
}
150150

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+
*/
151159
override fun asString(fieldValue: Expression<StringOrByteString>): Expression<String> =
152160
MethodCall(fieldValue, "toString")
153161
}

0 commit comments

Comments
 (0)