diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt
index 433c1bd959..4c0bcf02ef 100644
--- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt
+++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt
@@ -33,8 +33,8 @@ package io.spine.dependency.local
*/
@Suppress("ConstPropertyName", "unused")
object Base {
- const val version = "2.0.0-SNAPSHOT.421"
- const val versionForBuildScript = "2.0.0-SNAPSHOT.421"
+ const val version = "2.0.0-SNAPSHOT.423"
+ const val versionForBuildScript = "2.0.0-SNAPSHOT.423"
const val group = Spine.group
private const val prefix = "spine"
const val libModule = "$prefix-base"
diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt
index 8dbffcdc46..234247fbbf 100644
--- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt
+++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt
@@ -72,7 +72,7 @@ object Compiler : Dependency() {
* The version of the Compiler dependencies.
*/
override val version: String
- private const val fallbackVersion = "2.0.0-SNAPSHOT.059"
+ private const val fallbackVersion = "2.0.0-SNAPSHOT.060"
/**
* The distinct version of the Compiler used by other build tools.
@@ -81,7 +81,7 @@ object Compiler : Dependency() {
* transitive dependencies, this is the version used to build the project itself.
*/
val dogfoodingVersion: String
- private const val fallbackDfVersion = "2.0.0-SNAPSHOT.059"
+ private const val fallbackDfVersion = "2.0.0-SNAPSHOT.060"
/**
* The artifact for the Compiler Gradle plugin.
diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Logging.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Logging.kt
index e9f477ac3c..c79171f064 100644
--- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Logging.kt
+++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Logging.kt
@@ -33,7 +33,7 @@ package io.spine.dependency.local
*/
@Suppress("ConstPropertyName", "unused")
object Logging {
- const val version = "2.0.0-SNAPSHOT.419"
+ const val version = "2.0.0-SNAPSHOT.422"
const val group = Spine.group
const val loggingArtifact = "spine-logging"
diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Time.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Time.kt
index 3ff845647a..271fe49e33 100644
--- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Time.kt
+++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Time.kt
@@ -40,7 +40,7 @@ import io.spine.dependency.Dependency
)
object Time : Dependency() {
override val group = Spine.group
- override val version = "2.0.0-SNAPSHOT.242"
+ override val version = "2.0.0-SNAPSHOT.244"
private const val infix = "spine-time"
fun lib(version: String): String = "$group:$infix:$version"
diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt
index cd11577fbe..c0cbea3869 100644
--- a/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt
+++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt
@@ -34,8 +34,8 @@ package io.spine.dependency.local
@Suppress("ConstPropertyName", "unused")
object ToolBase {
const val group = Spine.toolsGroup
- const val version = "2.0.0-SNAPSHOT.402"
- const val dogfoodingVersion = "2.0.0-SNAPSHOT.402"
+ const val version = "2.0.0-SNAPSHOT.403"
+ const val dogfoodingVersion = "2.0.0-SNAPSHOT.403"
const val lib = "$group:tool-base:$version"
const val classicCodegen = "$group:classic-codegen:$version"
diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt
index 10f9f0dba1..942ccc8d7f 100644
--- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt
+++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt
@@ -36,7 +36,7 @@ object Validation {
/**
* The version of the Validation library artifacts.
*/
- const val version = "2.0.0-SNAPSHOT.446"
+ const val version = "2.0.0-SNAPSHOT.449"
const val group = Spine.toolsGroup
private const val prefix = "validation"
diff --git a/docs/dependencies/dependencies.md b/docs/dependencies/dependencies.md
index 79a667298e..2930500a40 100644
--- a/docs/dependencies/dependencies.md
+++ b/docs/dependencies/dependencies.md
@@ -1,6 +1,6 @@
-# Dependencies of `io.spine.tools:validation-context:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-context:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.22.0.
@@ -1106,14 +1106,14 @@
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:50 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-context-tests:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-context-tests:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.22.0.
@@ -1827,14 +1827,14 @@ This report was generated on **Mon Jul 06 21:17:50 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 23:00:19 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-docs:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-docs:2.0.0-SNAPSHOT.450`
## Runtime
## Compile, tests, and tooling
@@ -1844,14 +1844,14 @@ This report was generated on **Mon Jul 06 23:00:19 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:48 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:51 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-gradle-plugin:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-gradle-plugin:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.22.0.
@@ -2891,14 +2891,14 @@ This report was generated on **Mon Jul 06 21:17:48 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:50 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-java:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-java:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.22.0.
@@ -4004,14 +4004,14 @@ This report was generated on **Mon Jul 06 21:17:50 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:50 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-java-bundle:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-java-bundle:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : org.jetbrains. **Name** : annotations. **Version** : 13.0.
@@ -4061,14 +4061,14 @@ This report was generated on **Mon Jul 06 21:17:50 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:48 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:51 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-java-settings:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-java-settings:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
@@ -4868,14 +4868,14 @@ This report was generated on **Mon Jul 06 21:17:48 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:50 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine:spine-validation-jvm-runtime:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine:spine-validation-jvm-runtime:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
@@ -5695,14 +5695,14 @@ This report was generated on **Mon Jul 06 21:17:50 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:50 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-consumer:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-consumer:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.22.0.
@@ -6383,14 +6383,14 @@ This report was generated on **Mon Jul 06 21:17:50 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:51 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-consumer-dependency:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-consumer-dependency:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
@@ -6847,14 +6847,14 @@ This report was generated on **Mon Jul 06 21:17:51 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:49 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-extensions:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-extensions:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.22.0.
@@ -7468,14 +7468,14 @@ This report was generated on **Mon Jul 06 21:17:49 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:49 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-runtime:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-runtime:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
@@ -8035,14 +8035,14 @@ This report was generated on **Mon Jul 06 21:17:49 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:49 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-time:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-time:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
@@ -8467,14 +8467,14 @@ This report was generated on **Mon Jul 06 21:17:49 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:49 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-validating:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-validating:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
@@ -9081,14 +9081,14 @@ This report was generated on **Mon Jul 06 21:17:49 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:49 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-validator:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-validator:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.22.0.
@@ -9821,14 +9821,14 @@ This report was generated on **Mon Jul 06 21:17:49 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:49 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-validator-dependency:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-validator-dependency:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
@@ -10064,14 +10064,14 @@ This report was generated on **Mon Jul 06 21:17:49 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:48 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
-# Dependencies of `io.spine.tools:validation-vanilla:2.0.0-SNAPSHOT.449`
+# Dependencies of `io.spine.tools:validation-vanilla:2.0.0-SNAPSHOT.450`
## Runtime
1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2.
@@ -10417,6 +10417,6 @@ This report was generated on **Mon Jul 06 21:17:48 WEST 2026** using
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.
-This report was generated on **Mon Jul 06 21:17:49 WEST 2026** using
+This report was generated on **Tue Jul 07 17:33:52 WEST 2026** using
[Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under
[Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
\ No newline at end of file
diff --git a/docs/dependencies/pom.xml b/docs/dependencies/pom.xml
index c4417d6c7c..913c4e5db2 100644
--- a/docs/dependencies/pom.xml
+++ b/docs/dependencies/pom.xml
@@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject.
-->
io.spine.tools
validation
-2.0.0-SNAPSHOT.449
+2.0.0-SNAPSHOT.450
2015
@@ -50,73 +50,73 @@ all modules and does not describe the project structure per-subproject.
io.spine
spine-base
- 2.0.0-SNAPSHOT.421
+ 2.0.0-SNAPSHOT.423
compile
io.spine
spine-format
- 2.0.0-SNAPSHOT.421
+ 2.0.0-SNAPSHOT.423
compile
io.spine
spine-time
- 2.0.0-SNAPSHOT.242
+ 2.0.0-SNAPSHOT.244
compile
io.spine
spine-time-java
- 2.0.0-SNAPSHOT.242
+ 2.0.0-SNAPSHOT.244
compile
io.spine
spine-validation-jvm-runtime
- 2.0.0-SNAPSHOT.446
+ 2.0.0-SNAPSHOT.449
compile
io.spine.tools
compiler-api
- 2.0.0-SNAPSHOT.059
+ 2.0.0-SNAPSHOT.060
compile
io.spine.tools
compiler-backend
- 2.0.0-SNAPSHOT.059
+ 2.0.0-SNAPSHOT.060
compile
io.spine.tools
compiler-gradle-api
- 2.0.0-SNAPSHOT.059
+ 2.0.0-SNAPSHOT.060
compile
io.spine.tools
compiler-gradle-plugin
- 2.0.0-SNAPSHOT.059
+ 2.0.0-SNAPSHOT.060
compile
io.spine.tools
compiler-jvm
- 2.0.0-SNAPSHOT.059
+ 2.0.0-SNAPSHOT.060
compile
io.spine.tools
compiler-params
- 2.0.0-SNAPSHOT.059
+ 2.0.0-SNAPSHOT.060
compile
io.spine.tools
jvm-tools
- 2.0.0-SNAPSHOT.402
+ 2.0.0-SNAPSHOT.403
compile
@@ -188,7 +188,7 @@ all modules and does not describe the project structure per-subproject.
io.spine
spine-logging
- 2.0.0-SNAPSHOT.419
+ 2.0.0-SNAPSHOT.422
test
@@ -200,13 +200,13 @@ all modules and does not describe the project structure per-subproject.
io.spine.tools
compiler-testlib
- 2.0.0-SNAPSHOT.059
+ 2.0.0-SNAPSHOT.060
test
io.spine.tools
logging-testlib
- 2.0.0-SNAPSHOT.419
+ 2.0.0-SNAPSHOT.422
test
@@ -267,12 +267,12 @@ all modules and does not describe the project structure per-subproject.
io.spine.tools
compiler-cli-all
- 2.0.0-SNAPSHOT.059
+ 2.0.0-SNAPSHOT.060
io.spine.tools
compiler-protoc-plugin
- 2.0.0-SNAPSHOT.059
+ 2.0.0-SNAPSHOT.060
io.spine.tools
@@ -292,12 +292,12 @@ all modules and does not describe the project structure per-subproject.
io.spine.tools
time-validation
- 2.0.0-SNAPSHOT.242
+ 2.0.0-SNAPSHOT.244
io.spine.tools
validation-java-bundle
- 2.0.0-SNAPSHOT.446
+ 2.0.0-SNAPSHOT.449
net.sourceforge.pmd
diff --git a/java/src/main/kotlin/io/spine/tools/validation/java/generate/ValidatorGenerator.kt b/java/src/main/kotlin/io/spine/tools/validation/java/generate/ValidatorGenerator.kt
deleted file mode 100644
index 49fe678efe..0000000000
--- a/java/src/main/kotlin/io/spine/tools/validation/java/generate/ValidatorGenerator.kt
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright 2025, TeamDev. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Redistribution and use in source and/or binary forms, with or without
- * modification, must retain the above copyright notice and the following
- * disclaimer.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package io.spine.tools.validation.java.generate
-
-import com.google.protobuf.Message
-import io.spine.base.FieldPath
-import io.spine.string.simply
-import io.spine.string.ti
-import io.spine.tools.compiler.ast.Field
-import io.spine.tools.compiler.ast.MessageType
-import io.spine.tools.compiler.ast.extractMessageType
-import io.spine.tools.compiler.ast.isList
-import io.spine.tools.compiler.ast.isMap
-import io.spine.tools.compiler.ast.isSingular
-import io.spine.tools.compiler.ast.name
-import io.spine.tools.compiler.ast.refersToMessage
-import io.spine.tools.compiler.jvm.ClassName
-import io.spine.tools.compiler.jvm.CodeBlock
-import io.spine.tools.compiler.jvm.Expression
-import io.spine.tools.compiler.jvm.ReadVar
-import io.spine.tools.compiler.jvm.call
-import io.spine.tools.compiler.jvm.field
-import io.spine.tools.compiler.jvm.javaClassName
-import io.spine.tools.compiler.type.TypeSystem
-import io.spine.tools.validation.java.expression.constraintViolation
-import io.spine.tools.validation.java.expression.mergeFrom
-import io.spine.tools.validation.java.expression.orElse
-import io.spine.tools.validation.java.expression.resolve
-import io.spine.tools.validation.java.expression.stringify
-import io.spine.tools.validation.java.generate.MessageScope.message
-import io.spine.tools.validation.java.generate.ValidateScope.parentName
-import io.spine.tools.validation.java.generate.ValidateScope.parentPath
-import io.spine.tools.validation.java.generate.ValidateScope.violations
-import io.spine.validation.ConstraintViolation
-import io.spine.validation.DetectedViolation
-import io.spine.string.TemplateString
-
-/**
- * A fully qualified Java class name of a validator class.
- */
-internal typealias ValidatorClass = ClassName
-
-/**
- * A fully qualified Java class name of a Protobuf message class.
- */
-internal typealias MessageClass = ClassName
-
-/**
- * Generates code to apply validators to the message fields,
- * for which there is a validator assigned.
- *
- * Note that this generator is not
- * [OptionGenerator][io.spine.tools.validation.java.generate.OptionGenerator] intentionally.
- * This is a dedicated implementation, handling codegen for a specific use case not
- * related to the validation options.
- */
-internal class ValidatorGenerator(
- private val validators: Map,
- private val typeSystem: TypeSystem
-) {
-
- /**
- * Applies validators for the fields in the given message [type], for which
- * one is declared.
- *
- * The method inspects each field of the given [type], finding those that reference
- * message types with an available validator, and produces [CodeBlock]s that
- * invoke these validators.
- */
- fun codeFor(type: MessageType): List {
- val messageFields = type.fieldList.filter { it.type.refersToMessage() }
- .associateWith { it.type.extractMessageType(typeSystem)!! }
- val validatorsToApply = messageFields.mapNotNull { (field, type) ->
- val javaClass = type.javaClassName(typeSystem)
- validators[javaClass]?.let { field to it }
- }
- return validatorsToApply.map { (field, validator) ->
- ApplyValidator(field, validator).code()
- }
- }
-}
-
-/**
- * Applies the specified [validator] to the given [field].
- */
-private class ApplyValidator(
- private val field: Field,
- private val validator: ValidatorClass
-) {
- private val discovered = mangled("discovered")
- private val getter = message.field(field).getter()
- private val fieldType = field.type
-
- @Suppress("UNCHECKED_CAST") // The cast is guaranteed due to the field type checks.
- fun code(): CodeBlock = when {
- fieldType.isSingular -> validate(getter as Expression)
-
- fieldType.isList ->
- CodeBlock(
- """
- for (var element : $getter) {
- ${validate(ReadVar("element"))}
- }
- """.trimIndent()
- )
-
- fieldType.isMap ->
- CodeBlock(
- """
- for (var element : $getter.values()) {
- ${validate(ReadVar("element"))}
- }
- """.trimIndent()
- )
-
- else -> error(
- """
- The field type `${fieldType.name}` is not supported by `${simply()}`.
- This generator supports singular message fields, repeated and maps of messages.
- """.ti()
- )
- }
-
- /**
- * Yields an expression that invokes validator for the given [message] instance.
- *
- * The expression does the following:
- *
- * 1. Creates a new instance of [validator].
- * 2. Invokes [MessageValidator.validate][io.spine.validation.MessageValidator.validate]
- * passing the [message] instance.
- * 3. Converts each [DetectedViolation] to [ConstraintViolation].
- * 4. Puts all constraint violations to the list of discovered [violations].
- */
- private fun validate(message: Expression): CodeBlock {
- val vv = ReadVar("vv")
- val constraint = CodeBlock("""
- var $discovered = new $validator()
- .validate($message)
- .stream()
- .map($vv -> ${vv.toConstraintViolation()})
- .toList();
- $violations.addAll($discovered);
- """.trimIndent())
- return constraint
- }
-
- /**
- * Converts this [DetectedViolation] expression to the one
- * returning [ConstraintViolation].
- */
- private fun Expression.toConstraintViolation():
- Expression {
- val message = call("getMessage")
- val fieldValue = call("getFieldValue")
- val fieldPath = resolveFieldPath()
- val typeName = parentName.orElse(field.declaringType).stringify()
- return constraintViolation(message, typeName, fieldPath, fieldValue)
- }
-
- /**
- * Resolves a [FieldPath] from this [DetectedViolation] against the parent path.
- *
- * The resolved path contains the [parentPath] plus the name of the [field], for which
- * [ApplyValidator] is invoked.
- *
- * If the validator returns a non-nullable path, it is also appended to the resulting path.
- * Otherwise, just the one with the field name is returned.
- */
- @Suppress("UNCHECKED_CAST") // After the null-check, the cast is safe.
- private fun Expression.resolveFieldPath(): Expression {
- val validatorPath = call("getFieldPath")
- val resolved = parentPath.resolve(field.name)
- val merged = resolved.mergeFrom(validatorPath as Expression)
- return Expression("($validatorPath == null ? $resolved : $merged)")
- }
-}
diff --git a/version.gradle.kts b/version.gradle.kts
index 1814bd9665..bd8eb36782 100644
--- a/version.gradle.kts
+++ b/version.gradle.kts
@@ -27,4 +27,4 @@
/**
* The version of the Validation library to publish.
*/
-extra.set("validationVersion", "2.0.0-SNAPSHOT.449")
+extra.set("validationVersion", "2.0.0-SNAPSHOT.450")