From 404f9741c8ce51abd75494c2bd3f9e4008d9a063 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Wed, 26 Aug 2020 17:25:15 +0300 Subject: [PATCH 1/7] Fix an error in the doc --- .../java/io/spine/validate/option/FieldValidatingOption.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/src/main/java/io/spine/validate/option/FieldValidatingOption.java b/base/src/main/java/io/spine/validate/option/FieldValidatingOption.java index e007cb46d5..c5725a90c7 100644 --- a/base/src/main/java/io/spine/validate/option/FieldValidatingOption.java +++ b/base/src/main/java/io/spine/validate/option/FieldValidatingOption.java @@ -96,7 +96,7 @@ private IllegalStateException couldNotGetOptionValueFrom(String fieldName, * @apiNote Use this in favour of {@link * FieldOption#optionsFrom(com.google.protobuf.Descriptors.FieldDescriptor) * optionsFrom(FieldDescriptor)} when {@code FieldContext} matters, e.g. when handling - * {@code (validation_for)} options. + * {@code (constraint_for)} options. */ public Optional valueFrom(FieldContext context) { Optional externalConstraint = From b0871427e63b3770d18180b5a9dd582bc0cb6067 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Wed, 26 Aug 2020 18:14:03 +0300 Subject: [PATCH 2/7] Remove stdout output --- .../java/io/spine/tools/gradle/compiler/ColumnGenAction.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/ColumnGenAction.java b/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/ColumnGenAction.java index 2c29454828..aad37d2b15 100644 --- a/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/ColumnGenAction.java +++ b/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/ColumnGenAction.java @@ -67,9 +67,7 @@ final class ColumnGenAction extends CodeGenerationAction { @Override public void execute(Task task) { - System.out.println(String.format("Is tests? %s", isTests)); FileSet initialFileSet = protoFiles().get(); - System.out.println(String.format("File set: %s", initialFileSet)); Predicate belongsToModule = new SourceProtoBelongsToModule(protoSrcDir()).forDescriptor(); FileSet fileSet = initialFileSet.filter(belongsToModule); From 166afe1c6968bc203f399c2bad2ed30929730b3c Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Wed, 26 Aug 2020 18:14:15 +0300 Subject: [PATCH 3/7] Add a missing null check --- base/src/main/java/io/spine/validate/ComparableNumber.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/base/src/main/java/io/spine/validate/ComparableNumber.java b/base/src/main/java/io/spine/validate/ComparableNumber.java index 7badc1c11b..a90ac53908 100644 --- a/base/src/main/java/io/spine/validate/ComparableNumber.java +++ b/base/src/main/java/io/spine/validate/ComparableNumber.java @@ -23,6 +23,8 @@ import com.google.common.base.Objects; import com.google.errorprone.annotations.Immutable; +import static com.google.common.base.Preconditions.checkNotNull; + /** * A number that can be compared to another number. * @@ -41,7 +43,7 @@ public final class ComparableNumber extends Number implements Comparable /** Creates a new instance from the specified number. */ public ComparableNumber(Number value) { super(); - this.value = value; + this.value = checkNotNull(value); } /** Converts this number to its textual representation. */ From ad7ec7b4c3147081fe52dd219bd4a2439e5cb139 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Wed, 26 Aug 2020 18:18:51 +0300 Subject: [PATCH 4/7] Remove debugging code --- .../io/spine/tools/gradle/compiler/ColumnGenAction.java | 6 +----- .../io/spine/tools/gradle/compiler/ColumnGenPlugin.java | 9 ++++----- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/ColumnGenAction.java b/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/ColumnGenAction.java index aad37d2b15..3d385b457c 100644 --- a/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/ColumnGenAction.java +++ b/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/ColumnGenAction.java @@ -54,15 +54,11 @@ */ final class ColumnGenAction extends CodeGenerationAction { - private final boolean isTests; - ColumnGenAction(Project project, Supplier files, Supplier targetDirPath, - Supplier protoSrcDirPath, - boolean isTests) { + Supplier protoSrcDirPath) { super(project, files, targetDirPath, protoSrcDirPath); - this.isTests = isTests; } @Override diff --git a/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/ColumnGenPlugin.java b/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/ColumnGenPlugin.java index 01ee0d98aa..c297a77339 100644 --- a/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/ColumnGenPlugin.java +++ b/tools/model-compiler/src/main/java/io/spine/tools/gradle/compiler/ColumnGenPlugin.java @@ -58,8 +58,8 @@ public void apply(Project project) { new ColumnGenAction(project, mainProtoFiles(project), () -> getTargetGenColumnsRootDir(project), - () -> getMainProtoSrcDir(project), - true); + () -> getMainProtoSrcDir(project) + ); ProtoModule module = new ProtoModule(project); GradleTask mainTask = newTask(generateColumnInterfaces, mainScopeAction) @@ -72,9 +72,8 @@ public void apply(Project project) { new ColumnGenAction(project, testProtoFiles(project), () -> getTargetTestGenColumnsRootDir(project), - () -> getTestProtoSrcDir(project), - false); - + () -> getTestProtoSrcDir(project) + ); GradleTask testTask = newTask(generateTestColumnInterfaces, testScopeAction) .insertAfterTask(mergeTestDescriptorSet) From 7a64edfc2f4046efb2ced45231afd2fae917c24f Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Wed, 26 Aug 2020 18:40:36 +0300 Subject: [PATCH 5/7] Bump version to 1.5.28 --- license-report.md | 60 +++++++++++++++++++++++----------------------- pom.xml | 4 ++-- version.gradle.kts | 2 +- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/license-report.md b/license-report.md index cc10127b63..b99bd5b235 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-base:1.5.27` +# Dependencies of `io.spine:spine-base:1.5.28` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -329,12 +329,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:28 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:37 EEST 2020** 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:spine-errorprone-checks:1.5.27` +# Dependencies of `io.spine.tools:spine-errorprone-checks:1.5.28` ## Runtime 1. **Group:** com.github.ben-manes.caffeine **Name:** caffeine **Version:** 2.7.0 @@ -785,12 +785,12 @@ This report was generated on **Wed Aug 26 14:44:28 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:29 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:37 EEST 2020** 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:spine-javadoc-filter:1.5.27` +# Dependencies of `io.spine.tools:spine-javadoc-filter:1.5.28` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1169,12 +1169,12 @@ This report was generated on **Wed Aug 26 14:44:29 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:29 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:38 EEST 2020** 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:spine-javadoc-prettifier:1.5.27` +# Dependencies of `io.spine.tools:spine-javadoc-prettifier:1.5.28` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -1545,12 +1545,12 @@ This report was generated on **Wed Aug 26 14:44:29 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:29 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:38 EEST 2020** 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:spine-model-compiler:1.5.27` +# Dependencies of `io.spine.tools:spine-model-compiler:1.5.28` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -1937,12 +1937,12 @@ This report was generated on **Wed Aug 26 14:44:29 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:30 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:38 EEST 2020** 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:spine-mute-logging:1.5.27` +# Dependencies of `io.spine.tools:spine-mute-logging:1.5.28` ## Runtime 1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.6.3 @@ -2317,12 +2317,12 @@ This report was generated on **Wed Aug 26 14:44:30 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:30 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:39 EEST 2020** 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:spine-plugin-base:1.5.27` +# Dependencies of `io.spine.tools:spine-plugin-base:1.5.28` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -2693,12 +2693,12 @@ This report was generated on **Wed Aug 26 14:44:30 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:30 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:39 EEST 2020** 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:spine-plugin-testlib:1.5.27` +# Dependencies of `io.spine.tools:spine-plugin-testlib:1.5.28` ## Runtime 1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.6.3 @@ -3123,12 +3123,12 @@ This report was generated on **Wed Aug 26 14:44:30 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:31 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:39 EEST 2020** 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:spine-proto-dart-plugin:1.5.27` +# Dependencies of `io.spine.tools:spine-proto-dart-plugin:1.5.28` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -3499,12 +3499,12 @@ This report was generated on **Wed Aug 26 14:44:31 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:31 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:40 EEST 2020** 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:spine-proto-js-plugin:1.5.27` +# Dependencies of `io.spine.tools:spine-proto-js-plugin:1.5.28` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -3875,12 +3875,12 @@ This report was generated on **Wed Aug 26 14:44:31 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:31 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:40 EEST 2020** 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:spine-protoc-api:1.5.27` +# Dependencies of `io.spine.tools:spine-protoc-api:1.5.28` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -4201,12 +4201,12 @@ This report was generated on **Wed Aug 26 14:44:31 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:32 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:40 EEST 2020** 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:spine-protoc-plugin:1.5.27` +# Dependencies of `io.spine.tools:spine-protoc-plugin:1.5.28` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -4545,12 +4545,12 @@ This report was generated on **Wed Aug 26 14:44:32 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:32 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:41 EEST 2020** 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-testlib:1.5.27` +# Dependencies of `io.spine:spine-testlib:1.5.28` ## Runtime 1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.6.3 @@ -4925,12 +4925,12 @@ This report was generated on **Wed Aug 26 14:44:32 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:32 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:41 EEST 2020** 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:spine-tool-base:1.5.27` +# Dependencies of `io.spine.tools:spine-tool-base:1.5.28` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -5269,12 +5269,12 @@ This report was generated on **Wed Aug 26 14:44:32 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:33 EEST 2020** 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). +This report was generated on **Wed Aug 26 18:39:41 EEST 2020** 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:spine-validation-generator:1.5.27` +# Dependencies of `io.spine.tools:spine-validation-generator:1.5.28` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -5613,4 +5613,4 @@ This report was generated on **Wed Aug 26 14:44:33 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 14:44:33 EEST 2020** 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 +This report was generated on **Wed Aug 26 18:39:41 EEST 2020** 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 77249425d0..ed7b0b1098 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-base -1.5.27 +1.5.28 2015 @@ -154,7 +154,7 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-protoc-plugin - 1.5.27 + 1.5.28 test diff --git a/version.gradle.kts b/version.gradle.kts index 8609a1d222..34fa6ec0d4 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -25,7 +25,7 @@ * as we want to manage the versions in a single source. */ -val SPINE_VERSION = "1.5.27" +val SPINE_VERSION = "1.5.28" project.extra.apply { this["spineVersion"] = SPINE_VERSION From 35cb126119218513d833d68895f882f12f33074a Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Wed, 26 Aug 2020 19:05:08 +0300 Subject: [PATCH 6/7] Check that whole number bounds are whole numbers --- .../io/spine/validate/ComparableNumber.java | 9 ++++++ .../validate/option/RangedConstraint.java | 31 +++++++++++++++++++ .../spine/validate/ComparableNumberTest.java | 11 +++++++ .../io/spine/validate/NumberRangeTest.java | 18 +++++++++++ .../proto/spine/test/validate/messages.proto | 4 +++ 5 files changed, 73 insertions(+) diff --git a/base/src/main/java/io/spine/validate/ComparableNumber.java b/base/src/main/java/io/spine/validate/ComparableNumber.java index a90ac53908..6b54de2feb 100644 --- a/base/src/main/java/io/spine/validate/ComparableNumber.java +++ b/base/src/main/java/io/spine/validate/ComparableNumber.java @@ -58,6 +58,8 @@ public Number value() { @Override public int compareTo(Number anotherNumber) { + checkNotNull(anotherNumber); + long thisLong = longValue(); long thatLong = anotherNumber.longValue(); if (thisLong == thatLong) { @@ -86,6 +88,13 @@ public double doubleValue() { return value.doubleValue(); } + /** + * Checks if this number is a whole number, i.e. an {@code int} or a {@code long}. + */ + public boolean isInteger() { + return value instanceof Integer || value instanceof Long; + } + @Override public boolean equals(Object o) { if (this == o) { diff --git a/base/src/main/java/io/spine/validate/option/RangedConstraint.java b/base/src/main/java/io/spine/validate/option/RangedConstraint.java index db01c21520..69d8bcc87d 100644 --- a/base/src/main/java/io/spine/validate/option/RangedConstraint.java +++ b/base/src/main/java/io/spine/validate/option/RangedConstraint.java @@ -24,11 +24,14 @@ import com.google.common.collect.Range; import com.google.errorprone.annotations.Immutable; import com.google.errorprone.annotations.ImmutableTypeParameter; +import com.google.protobuf.Descriptors.FieldDescriptor.JavaType; import io.spine.code.proto.FieldContext; import io.spine.code.proto.FieldDeclaration; import io.spine.validate.ComparableNumber; +import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.BoundType.CLOSED; +import static io.spine.util.Exceptions.newIllegalArgumentException; /** * A constraint that puts a numeric field value into a range. @@ -47,9 +50,37 @@ public abstract class RangedConstraint<@ImmutableTypeParameter T> extends FieldC RangedConstraint(T optionValue, Range range, FieldDeclaration field) { super(optionValue, field); + verifyType(field, range); this.range = range; } + @SuppressWarnings("EnumSwitchStatementWhichMissesCases") + private static void verifyType(FieldDeclaration field, Range range) { + JavaType fieldType = field.javaType(); + switch (fieldType) { + case INT: // Fallthrough intended. + case LONG: { + if (range.hasLowerBound()) { + checkInteger(range.lowerEndpoint(), field); + } + if (range.hasUpperBound()) { + checkInteger(range.upperEndpoint(), field); + } + return; + } + case FLOAT: // Fallthrough intended. + case DOUBLE: + return; + default: + throw newIllegalArgumentException("Field `%s` cannot have a number bound.", field); + } + } + + private static void checkInteger(ComparableNumber number, FieldDeclaration field) { + checkState(number.isInteger(), + "An integer bound expected for field `%s`, but got `%s`.", field, number); + } + public final Range range() { return range; } diff --git a/base/src/test/java/io/spine/validate/ComparableNumberTest.java b/base/src/test/java/io/spine/validate/ComparableNumberTest.java index 72fa110684..3a8e7f0d9b 100644 --- a/base/src/test/java/io/spine/validate/ComparableNumberTest.java +++ b/base/src/test/java/io/spine/validate/ComparableNumberTest.java @@ -21,13 +21,24 @@ package io.spine.validate; import com.google.common.testing.EqualsTester; +import com.google.common.testing.NullPointerTester; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import static io.spine.testing.DisplayNames.NOT_ACCEPT_NULLS; + @DisplayName("Comparable number should") class ComparableNumberTest { + @Test + @DisplayName(NOT_ACCEPT_NULLS) + void notAcceptNulls() { + NullPointerTester tester = new NullPointerTester(); + tester.testAllPublicConstructors(ComparableNumber.class); + tester.testAllPublicInstanceMethods(new ComparableNumber(42)); + } + @Nested @DisplayName("have a consistent equality relationship") class EqualsTests { diff --git a/base/src/test/java/io/spine/validate/NumberRangeTest.java b/base/src/test/java/io/spine/validate/NumberRangeTest.java index 707c05ab23..b580728b6f 100644 --- a/base/src/test/java/io/spine/validate/NumberRangeTest.java +++ b/base/src/test/java/io/spine/validate/NumberRangeTest.java @@ -20,15 +20,19 @@ package io.spine.validate; +import com.google.common.truth.StringSubject; import com.google.protobuf.DoubleValue; import com.google.protobuf.Message; +import io.spine.test.validate.InvalidBound; import io.spine.test.validate.MaxExclusiveNumberFieldValue; import io.spine.test.validate.MaxInclusiveNumberFieldValue; import io.spine.test.validate.MinExclusiveNumberFieldValue; import io.spine.test.validate.MinInclusiveNumberFieldValue; +import io.spine.type.TypeName; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import static com.google.common.truth.Truth.assertThat; import static io.spine.validate.ValidationOfConstraintTest.VALIDATION_SHOULD; import static io.spine.validate.given.MessageValidatorTestEnv.EQUAL_MAX; import static io.spine.validate.given.MessageValidatorTestEnv.EQUAL_MIN; @@ -39,6 +43,7 @@ import static io.spine.validate.given.MessageValidatorTestEnv.LESS_THAN_MAX; import static io.spine.validate.given.MessageValidatorTestEnv.LESS_THAN_MIN; import static io.spine.validate.given.MessageValidatorTestEnv.VALUE; +import static org.junit.jupiter.api.Assertions.assertThrows; @DisplayName(VALIDATION_SHOULD + "analyze (min) and (max) options and") class NumberRangeTest extends ValidationOfConstraintTest { @@ -138,6 +143,19 @@ void provideOneValidViolationIfNumberIsGreaterThanDecimalMax() { assertSingleViolation(GREATER_MAX_MSG, VALUE); } + @Test + @DisplayName("not allow fraction boundaries for integer fields") + void fractionsBounds() { + IllegalStateException exception = + assertThrows(IllegalStateException.class, + () -> validate(InvalidBound.getDefaultInstance())); + StringSubject assertMessage = assertThat(exception).hasMessageThat(); + assertMessage + .contains("2.71"); + assertMessage + .contains(TypeName.of(InvalidBound.class).value()); + } + private void minNumberTest(double value, boolean inclusive, boolean valid) { Message msg = inclusive ? MinInclusiveNumberFieldValue diff --git a/base/src/test/proto/spine/test/validate/messages.proto b/base/src/test/proto/spine/test/validate/messages.proto index 9b28d0de4d..50e1698d5e 100644 --- a/base/src/test/proto/spine/test/validate/messages.proto +++ b/base/src/test/proto/spine/test/validate/messages.proto @@ -128,6 +128,10 @@ message MaxExclusiveNumberFieldValue { double value = 1 [(max).value = "64.5", (max).exclusive = true]; } +message InvalidBound { + int64 value = 1 [(min).value = "2.71"]; +} + // Messages for "valid" option tests. message EnclosedMessageFieldValue { From 504f6d369f266b7594e87660ad11b142eea9e5c2 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Thu, 27 Aug 2020 15:36:04 +0300 Subject: [PATCH 7/7] BUmp version --- license-report.md | 60 +++++++++++++++++++++++----------------------- pom.xml | 4 ++-- version.gradle.kts | 2 +- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/license-report.md b/license-report.md index b99bd5b235..34ad1aa14c 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-base:1.5.28` +# Dependencies of `io.spine:spine-base:1.5.29` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -329,12 +329,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:37 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:23 EEST 2020** 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:spine-errorprone-checks:1.5.28` +# Dependencies of `io.spine.tools:spine-errorprone-checks:1.5.29` ## Runtime 1. **Group:** com.github.ben-manes.caffeine **Name:** caffeine **Version:** 2.7.0 @@ -785,12 +785,12 @@ This report was generated on **Wed Aug 26 18:39:37 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:37 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:24 EEST 2020** 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:spine-javadoc-filter:1.5.28` +# Dependencies of `io.spine.tools:spine-javadoc-filter:1.5.29` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1169,12 +1169,12 @@ This report was generated on **Wed Aug 26 18:39:37 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:38 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:24 EEST 2020** 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:spine-javadoc-prettifier:1.5.28` +# Dependencies of `io.spine.tools:spine-javadoc-prettifier:1.5.29` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -1545,12 +1545,12 @@ This report was generated on **Wed Aug 26 18:39:38 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:38 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:25 EEST 2020** 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:spine-model-compiler:1.5.28` +# Dependencies of `io.spine.tools:spine-model-compiler:1.5.29` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -1937,12 +1937,12 @@ This report was generated on **Wed Aug 26 18:39:38 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:38 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:25 EEST 2020** 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:spine-mute-logging:1.5.28` +# Dependencies of `io.spine.tools:spine-mute-logging:1.5.29` ## Runtime 1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.6.3 @@ -2317,12 +2317,12 @@ This report was generated on **Wed Aug 26 18:39:38 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:39 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:25 EEST 2020** 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:spine-plugin-base:1.5.28` +# Dependencies of `io.spine.tools:spine-plugin-base:1.5.29` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -2693,12 +2693,12 @@ This report was generated on **Wed Aug 26 18:39:39 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:39 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:26 EEST 2020** 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:spine-plugin-testlib:1.5.28` +# Dependencies of `io.spine.tools:spine-plugin-testlib:1.5.29` ## Runtime 1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.6.3 @@ -3123,12 +3123,12 @@ This report was generated on **Wed Aug 26 18:39:39 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:39 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:26 EEST 2020** 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:spine-proto-dart-plugin:1.5.28` +# Dependencies of `io.spine.tools:spine-proto-dart-plugin:1.5.29` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -3499,12 +3499,12 @@ This report was generated on **Wed Aug 26 18:39:39 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:40 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:27 EEST 2020** 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:spine-proto-js-plugin:1.5.28` +# Dependencies of `io.spine.tools:spine-proto-js-plugin:1.5.29` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -3875,12 +3875,12 @@ This report was generated on **Wed Aug 26 18:39:40 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:40 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:27 EEST 2020** 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:spine-protoc-api:1.5.28` +# Dependencies of `io.spine.tools:spine-protoc-api:1.5.29` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -4201,12 +4201,12 @@ This report was generated on **Wed Aug 26 18:39:40 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:40 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:27 EEST 2020** 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:spine-protoc-plugin:1.5.28` +# Dependencies of `io.spine.tools:spine-protoc-plugin:1.5.29` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -4545,12 +4545,12 @@ This report was generated on **Wed Aug 26 18:39:40 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:41 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:27 EEST 2020** 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-testlib:1.5.28` +# Dependencies of `io.spine:spine-testlib:1.5.29` ## Runtime 1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.6.3 @@ -4925,12 +4925,12 @@ This report was generated on **Wed Aug 26 18:39:41 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:41 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:28 EEST 2020** 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:spine-tool-base:1.5.28` +# Dependencies of `io.spine.tools:spine-tool-base:1.5.29` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -5269,12 +5269,12 @@ This report was generated on **Wed Aug 26 18:39:41 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:41 EEST 2020** 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). +This report was generated on **Thu Aug 27 15:35:28 EEST 2020** 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:spine-validation-generator:1.5.28` +# Dependencies of `io.spine.tools:spine-validation-generator:1.5.29` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -5613,4 +5613,4 @@ This report was generated on **Wed Aug 26 18:39:41 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Wed Aug 26 18:39:41 EEST 2020** 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 +This report was generated on **Thu Aug 27 15:35:28 EEST 2020** 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 ed7b0b1098..ac16a5438d 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject. io.spine spine-base -1.5.28 +1.5.29 2015 @@ -154,7 +154,7 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-protoc-plugin - 1.5.28 + 1.5.29 test diff --git a/version.gradle.kts b/version.gradle.kts index d25806fc26..59670acc41 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -34,7 +34,7 @@ /** * The version of this library. */ -val base = "1.5.28" +val base = "1.5.29" project.extra.apply {