From eb17b1af631f837e5f02200a30074223950a2506 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Wed, 25 Mar 2026 15:29:55 +0000 Subject: [PATCH 1/6] Optimise imports --- .../kotlin/io/spine/validation/given/ExceptionFactoryStubs.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/jvm-runtime/src/test/kotlin/io/spine/validation/given/ExceptionFactoryStubs.kt b/jvm-runtime/src/test/kotlin/io/spine/validation/given/ExceptionFactoryStubs.kt index a4696afdda..49b881a515 100644 --- a/jvm-runtime/src/test/kotlin/io/spine/validation/given/ExceptionFactoryStubs.kt +++ b/jvm-runtime/src/test/kotlin/io/spine/validation/given/ExceptionFactoryStubs.kt @@ -26,7 +26,6 @@ package io.spine.validation.given -import com.google.protobuf.Message import com.google.protobuf.NullValue import com.google.protobuf.Timestamp import com.google.protobuf.Value From 955fd39b66a1f4e18008bfca72c4a16dbfd9cfca Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Wed, 25 Mar 2026 15:30:10 +0000 Subject: [PATCH 2/6] Bump version -> `2.0.0-SNAPSHOT.408` --- version.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.gradle.kts b/version.gradle.kts index 2109cde54e..7f4b258cc1 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -29,4 +29,4 @@ * * For Spine-based dependencies please see [io.spine.dependency.local.Spine]. */ -val validationVersion by extra("2.0.0-SNAPSHOT.407") +val validationVersion by extra("2.0.0-SNAPSHOT.408") From 2ee2dec194963e944818c97a42d70ea5939ab749 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Wed, 25 Mar 2026 15:37:54 +0000 Subject: [PATCH 3/6] Bump Validation -> `2.0.0-SNAPSHOT.408` --- .../src/main/kotlin/io/spine/dependency/local/Validation.kt | 2 +- docs/_examples | 2 +- .../docs/validation/01-getting-started/adding-to-build.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 e10eea540f..ae0ea41f5f 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.406" + const val version = "2.0.0-SNAPSHOT.407" /** * The last version of Validation compatible with ProtoData. diff --git a/docs/_examples b/docs/_examples index 7be713d773..4c1c5a231c 160000 --- a/docs/_examples +++ b/docs/_examples @@ -1 +1 @@ -Subproject commit 7be713d773d490f15d5549f49f86d0f1c4e952ce +Subproject commit 4c1c5a231cc7beb19a5ff9a335ad8175d9a45285 diff --git a/docs/content/docs/validation/01-getting-started/adding-to-build.md b/docs/content/docs/validation/01-getting-started/adding-to-build.md index ae92990d25..c5d793bb99 100644 --- a/docs/content/docs/validation/01-getting-started/adding-to-build.md +++ b/docs/content/docs/validation/01-getting-started/adding-to-build.md @@ -90,7 +90,7 @@ Add the Validation plugin to the build. ```kotlin plugins { module - id("io.spine.validation") version "2.0.0-SNAPSHOT.407" + id("io.spine.validation") version "2.0.0-SNAPSHOT.408" } ``` From a0e09c20c3c0f9b266a31e323c06b77622b7aa4c Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Wed, 25 Mar 2026 15:40:39 +0000 Subject: [PATCH 4/6] Update dependency reports --- dependencies.md | 60 ++++++++++++++++++++++++------------------------- pom.xml | 6 ++--- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/dependencies.md b/dependencies.md index 63e6983e1a..3cce82fe0e 100644 --- a/dependencies.md +++ b/dependencies.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine.tools:validation-context:2.0.0-SNAPSHOT.407` +# Dependencies of `io.spine.tools:validation-context:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -1147,14 +1147,14 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:23 WET 2026** using +This report was generated on **Wed Mar 25 15:38:29 WET 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.407` +# Dependencies of `io.spine.tools:validation-context-tests:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -1751,28 +1751,28 @@ This report was generated on **Wed Mar 25 14:25:23 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:23 WET 2026** using +This report was generated on **Wed Mar 25 15:38:29 WET 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.407` +# Dependencies of `io.spine.tools:validation-docs:2.0.0-SNAPSHOT.408` ## Runtime ## Compile, tests, and tooling The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue Mar 24 18:44:03 WET 2026** using +This report was generated on **Wed Mar 25 15:38:27 WET 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.407` +# Dependencies of `io.spine.tools:validation-gradle-plugin:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -2889,14 +2889,14 @@ This report was generated on **Tue Mar 24 18:44:03 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:23 WET 2026** using +This report was generated on **Wed Mar 25 15:38:29 WET 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.407` +# Dependencies of `io.spine.tools:validation-java:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -3975,14 +3975,14 @@ This report was generated on **Wed Mar 25 14:25:23 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:23 WET 2026** using +This report was generated on **Wed Mar 25 15:38:29 WET 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.407` +# Dependencies of `io.spine.tools:validation-java-bundle:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : org.jetbrains. **Name** : annotations. **Version** : 13.0. @@ -4029,14 +4029,14 @@ This report was generated on **Wed Mar 25 14:25:23 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:22 WET 2026** using +This report was generated on **Wed Mar 25 15:38:28 WET 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:validation-jvm-runtime:2.0.0-SNAPSHOT.407` +# Dependencies of `io.spine:validation-jvm-runtime:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -4869,14 +4869,14 @@ This report was generated on **Wed Mar 25 14:25:22 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:23 WET 2026** using +This report was generated on **Wed Mar 25 15:38:29 WET 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.407` +# Dependencies of `io.spine.tools:validation-consumer:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -5463,14 +5463,14 @@ This report was generated on **Wed Mar 25 14:25:23 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:22 WET 2026** using +This report was generated on **Wed Mar 25 15:38:28 WET 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.407` +# Dependencies of `io.spine.tools:validation-consumer-dependency:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -5989,14 +5989,14 @@ This report was generated on **Wed Mar 25 14:25:22 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:23 WET 2026** using +This report was generated on **Wed Mar 25 15:38:29 WET 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.407` +# Dependencies of `io.spine.tools:validation-extensions:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -6684,14 +6684,14 @@ This report was generated on **Wed Mar 25 14:25:23 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:23 WET 2026** using +This report was generated on **Wed Mar 25 15:38:29 WET 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.407` +# Dependencies of `io.spine.tools:validation-runtime:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -7325,14 +7325,14 @@ This report was generated on **Wed Mar 25 14:25:23 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:23 WET 2026** using +This report was generated on **Wed Mar 25 15:38:29 WET 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.407` +# Dependencies of `io.spine.tools:validation-validating:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -8005,14 +8005,14 @@ This report was generated on **Wed Mar 25 14:25:23 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:23 WET 2026** using +This report was generated on **Wed Mar 25 15:38:29 WET 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.407` +# Dependencies of `io.spine.tools:validation-validator:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.20.0. @@ -8799,14 +8799,14 @@ This report was generated on **Wed Mar 25 14:25:23 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:23 WET 2026** using +This report was generated on **Wed Mar 25 15:38:29 WET 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.407` +# Dependencies of `io.spine.tools:validation-validator-dependency:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -9080,14 +9080,14 @@ This report was generated on **Wed Mar 25 14:25:23 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:23 WET 2026** using +This report was generated on **Wed Mar 25 15:38:29 WET 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.407` +# Dependencies of `io.spine.tools:validation-vanilla:2.0.0-SNAPSHOT.408` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -9434,6 +9434,6 @@ This report was generated on **Wed Mar 25 14:25:23 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 14:25:22 WET 2026** using +This report was generated on **Wed Mar 25 15:38:28 WET 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/pom.xml b/pom.xml index 7788f02608..021f2e8709 100644 --- a/pom.xml +++ b/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.407 +2.0.0-SNAPSHOT.408 2015 @@ -62,7 +62,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-validation-jvm-runtime - 2.0.0-SNAPSHOT.406 + 2.0.0-SNAPSHOT.407 compile @@ -289,7 +289,7 @@ all modules and does not describe the project structure per-subproject. io.spine.tools validation-java-bundle - 2.0.0-SNAPSHOT.406 + 2.0.0-SNAPSHOT.407 net.sourceforge.pmd From c90010d5bfe5068a865e1a4fed726b318eb9b47e Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Wed, 25 Mar 2026 15:51:22 +0000 Subject: [PATCH 5/6] Remove deprecated types --- .../validation/option/AlwaysRequired.java | 59 -------- .../option/FieldValidatingOption.java | 115 ---------------- .../io/spine/validation/option/Required.java | 128 ------------------ .../validation/option/ValidatingOption.java | 53 -------- 4 files changed, 355 deletions(-) delete mode 100644 jvm-runtime/src/main/java/io/spine/validation/option/AlwaysRequired.java delete mode 100644 jvm-runtime/src/main/java/io/spine/validation/option/FieldValidatingOption.java delete mode 100644 jvm-runtime/src/main/java/io/spine/validation/option/Required.java delete mode 100644 jvm-runtime/src/main/java/io/spine/validation/option/ValidatingOption.java diff --git a/jvm-runtime/src/main/java/io/spine/validation/option/AlwaysRequired.java b/jvm-runtime/src/main/java/io/spine/validation/option/AlwaysRequired.java deleted file mode 100644 index 8034d28279..0000000000 --- a/jvm-runtime/src/main/java/io/spine/validation/option/AlwaysRequired.java +++ /dev/null @@ -1,59 +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.validation.option; - -import com.google.errorprone.annotations.Immutable; -import io.spine.code.proto.FieldContext; - -/** - * A special case of {@code Required} option that assumes that the option is present regardless - * of the actual field declaration. - * - * @deprecated Please use generated validation code. - */ -@Immutable -@Deprecated(forRemoval = true) -final class AlwaysRequired extends Required { - - /** - * Creates a new instance of this option. - */ - AlwaysRequired() { - super(); - } - - /** - * {@inheritDoc} - * - *

For {@code AlwaysRequired}, validation happens every time. - */ - @Override - public boolean shouldValidate(FieldContext context) { - checkUsage(context.targetDeclaration()); - return true; - } -} diff --git a/jvm-runtime/src/main/java/io/spine/validation/option/FieldValidatingOption.java b/jvm-runtime/src/main/java/io/spine/validation/option/FieldValidatingOption.java deleted file mode 100644 index cb5d9b1acd..0000000000 --- a/jvm-runtime/src/main/java/io/spine/validation/option/FieldValidatingOption.java +++ /dev/null @@ -1,115 +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.validation.option; - -import com.google.errorprone.annotations.Immutable; -import com.google.errorprone.annotations.ImmutableTypeParameter; -import com.google.protobuf.DescriptorProtos.FieldOptions; -import com.google.protobuf.Descriptors.FieldDescriptor; -import com.google.protobuf.GeneratedMessage.GeneratedExtension; -import io.spine.code.proto.FieldContext; -import io.spine.code.proto.FieldOption; - -import java.util.Optional; - -import static java.lang.String.format; - -/** - * An option that validates a field. - * - *

Validating options impose constraint on fields that they are applied to. - * - * @param - * type of value held by this option - * @deprecated Please use generated validation code. - */ -@Immutable -@Deprecated(forRemoval = true) -public abstract class FieldValidatingOption<@ImmutableTypeParameter T> - extends FieldOption - implements ValidatingOption { - - /** Specifies the extension that corresponds to this option. */ - protected FieldValidatingOption(GeneratedExtension optionExtension) { - super(optionExtension); - } - - /** - * Returns a value of the option. - * - * @apiNote Should only be called by subclasses in circumstances that assume presence of - * the option. For all other cases please refer to - * {@link #valueFrom(FieldContext)}. - */ - protected T optionValue(FieldContext field) throws IllegalStateException { - var option = valueFrom(field); - return option.orElseThrow(() -> { - var fieldName = field.targetDeclaration() - .name() - .value(); - var containingTypeName = field.target() - .getContainingType() - .getName(); - return couldNotGetOptionValueFrom(fieldName, containingTypeName); - }); - } - - private IllegalStateException couldNotGetOptionValueFrom(String fieldName, - String containingTypeName) { - var optionName = extension().getDescriptor().getName(); - var message = format("Could not get value of option %s from field %s in message %s.", - optionName, - fieldName, - containingTypeName); - return new IllegalStateException(message); - } - - /** - * Takes the value of the option from the given descriptor, given the specified context. - * - * @param context - * context of the field - * @return an {@code Optional} with an option value if such exists, otherwise an empty - * {@code Optional} - * @apiNote Use this in favour of {@link - * FieldOption#optionsFrom(com.google.protobuf.Descriptors.FieldDescriptor) - * optionsFrom(FieldDescriptor)} when {@code FieldContext} matters. - */ - public Optional valueFrom(FieldContext context) { - return valueFrom(context.target()); - } - - /** - * Returns {@code true} if this option exists for the specified field, {@code false} otherwise. - * - * @param context - * the value to be validated - */ - public boolean shouldValidate(FieldContext context) { - return valueFrom(context).isPresent(); - } -} diff --git a/jvm-runtime/src/main/java/io/spine/validation/option/Required.java b/jvm-runtime/src/main/java/io/spine/validation/option/Required.java deleted file mode 100644 index 163f05a213..0000000000 --- a/jvm-runtime/src/main/java/io/spine/validation/option/Required.java +++ /dev/null @@ -1,128 +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.validation.option; - -import com.google.common.collect.ImmutableSet; -import com.google.errorprone.annotations.Immutable; -import com.google.protobuf.Descriptors.FieldDescriptor.JavaType; -import io.spine.base.CommandMessage; -import io.spine.base.EntityState; -import io.spine.code.proto.FieldContext; -import io.spine.code.proto.FieldDeclaration; -import io.spine.option.OptionsProto; - -import static com.google.protobuf.Descriptors.FieldDescriptor.JavaType.BYTE_STRING; -import static com.google.protobuf.Descriptors.FieldDescriptor.JavaType.ENUM; -import static com.google.protobuf.Descriptors.FieldDescriptor.JavaType.MESSAGE; -import static com.google.protobuf.Descriptors.FieldDescriptor.JavaType.STRING; - -/** - * An option that makes a field {@code required}. - * - *

If a {@code required} field is missing, an error is produced. - * - * @deprecated Please use generated validation code. - */ -@Immutable -@Deprecated(forRemoval = true) -public class Required extends FieldValidatingOption { - - static final ImmutableSet CAN_BE_REQUIRED = ImmutableSet.of( - MESSAGE, ENUM, STRING, BYTE_STRING - ); - - /** - * Creates a new instance of this option. - */ - Required() { - super(OptionsProto.required); - } - - /** - * Creates a new instance. - * - *

If the specified parameter is {@code true}, a returned option always assumes a field to - * be {@code required}, regardless of the field value. - * If the specified parameter is {@code false}, a returned option checks the actual value. - * - * @param strict - * specifies if a field is assumed to be a required one regardless of the actual - * Protobuf option value - * @return a new instance of the {@code Required} option - */ - public static Required create(boolean strict) { - return strict - ? new AlwaysRequired() - : new Required(); - } - - private boolean notAssumingRequired(FieldContext context) { - var defaultValue = context.targetDeclaration().isId(); - return valueFrom(context.target()) - .orElse(defaultValue); - } - - @Override - public boolean shouldValidate(FieldContext context) { - return notAssumingRequired(context); - } - - /** - * Produces warnings if the {@code required} option was applied incorrectly. - * - *

Examples of incorrect application include attempting to apply the option to a numeric - * field. - * - * @param field - * a value that the option is applied to - */ - @SuppressWarnings("UseOfSystemOutOrSystemErr") /* We're migrating off runtime validation - AND we do not want dependency of Validation Runtime on Spine Logging. - So we use `System.err` for the warnings. */ - void checkUsage(FieldDeclaration field) { - var type = field.javaType(); - if (!CAN_BE_REQUIRED.contains(type) && field.isNotCollection()) { - var isTheFirstField = field.descriptor().getIndex() == 0; - if (isTheFirstField) { - // The first field declared in a message type could be assumed as required - // because by convention it is an ID field of the message. - // If so, do not log the warning message for this field because ID fields - // could be of any reasonable type. - var messageClass = field.declaringType().javaClass(); - if (CommandMessage.class.isAssignableFrom(messageClass) - || EntityState.class.isAssignableFrom(messageClass)) { - return; - } - } - var typeName = field.descriptor().getType().name(); - System.err.printf( - "The field `%s.%s` has the type %s and" + - " should not be declared as `(required)`.%n", - field.declaringType().name(), field.name(), typeName); - } - } -} diff --git a/jvm-runtime/src/main/java/io/spine/validation/option/ValidatingOption.java b/jvm-runtime/src/main/java/io/spine/validation/option/ValidatingOption.java deleted file mode 100644 index e67cccedb0..0000000000 --- a/jvm-runtime/src/main/java/io/spine/validation/option/ValidatingOption.java +++ /dev/null @@ -1,53 +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.validation.option; - -import com.google.errorprone.annotations.Immutable; -import com.google.errorprone.annotations.ImmutableTypeParameter; -import com.google.protobuf.Descriptors.GenericDescriptor; -import io.spine.code.proto.Option; - -/** - * The interface common to all standard validation options. - * - * @param - * data type that this option holds, e.g., - * {@linkplain io.spine.option.OptionsProto#required required option} would - * hold a {@code Boolean} - * @param - * reflective container which describes the entity this option is applied to - * @param - * kind of entity that this option is applied to - * @deprecated Please use generated validation code. - */ -@Immutable -@Deprecated(forRemoval = true) -interface ValidatingOption<@ImmutableTypeParameter T, - @ImmutableTypeParameter C, - @ImmutableTypeParameter K extends GenericDescriptor> - extends Option { -} From e3d275cc8980b82d17c34e69172df7544cbc60a7 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Wed, 25 Mar 2026 15:51:27 +0000 Subject: [PATCH 6/6] Update build time --- dependencies.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/dependencies.md b/dependencies.md index 3cce82fe0e..4faffa4ce0 100644 --- a/dependencies.md +++ b/dependencies.md @@ -1147,7 +1147,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:29 WET 2026** using +This report was generated on **Wed Mar 25 15:40:53 WET 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). @@ -1751,7 +1751,7 @@ This report was generated on **Wed Mar 25 15:38:29 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:29 WET 2026** using +This report was generated on **Wed Mar 25 15:40:53 WET 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). @@ -2889,7 +2889,7 @@ This report was generated on **Wed Mar 25 15:38:27 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:29 WET 2026** using +This report was generated on **Wed Mar 25 15:40:53 WET 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). @@ -3975,7 +3975,7 @@ This report was generated on **Wed Mar 25 15:38:29 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:29 WET 2026** using +This report was generated on **Wed Mar 25 15:40:53 WET 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). @@ -4029,7 +4029,7 @@ This report was generated on **Wed Mar 25 15:38:29 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:28 WET 2026** using +This report was generated on **Wed Mar 25 15:40:52 WET 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). @@ -4869,7 +4869,7 @@ This report was generated on **Wed Mar 25 15:38:28 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:29 WET 2026** using +This report was generated on **Wed Mar 25 15:40:53 WET 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). @@ -5463,7 +5463,7 @@ This report was generated on **Wed Mar 25 15:38:29 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:28 WET 2026** using +This report was generated on **Wed Mar 25 15:40:52 WET 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). @@ -5989,7 +5989,7 @@ This report was generated on **Wed Mar 25 15:38:28 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:29 WET 2026** using +This report was generated on **Wed Mar 25 15:40:52 WET 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). @@ -6684,7 +6684,7 @@ This report was generated on **Wed Mar 25 15:38:29 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:29 WET 2026** using +This report was generated on **Wed Mar 25 15:40:53 WET 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). @@ -7325,7 +7325,7 @@ This report was generated on **Wed Mar 25 15:38:29 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:29 WET 2026** using +This report was generated on **Wed Mar 25 15:40:53 WET 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). @@ -8005,7 +8005,7 @@ This report was generated on **Wed Mar 25 15:38:29 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:29 WET 2026** using +This report was generated on **Wed Mar 25 15:40:53 WET 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). @@ -8799,7 +8799,7 @@ This report was generated on **Wed Mar 25 15:38:29 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:29 WET 2026** using +This report was generated on **Wed Mar 25 15:40:53 WET 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). @@ -9080,7 +9080,7 @@ This report was generated on **Wed Mar 25 15:38:29 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:29 WET 2026** using +This report was generated on **Wed Mar 25 15:40:52 WET 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). @@ -9434,6 +9434,6 @@ This report was generated on **Wed Mar 25 15:38:29 WET 2026** using The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Mar 25 15:38:28 WET 2026** using +This report was generated on **Wed Mar 25 15:40:52 WET 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