From 4394135e9239c727fa5c3d458e6c527b1c0371e2 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Thu, 2 Apr 2020 13:24:10 +0300 Subject: [PATCH 01/14] Update config --- .idea/inspectionProfiles/Project_Default.xml | 1 + config | 2 +- license-report.md | 30 ++++++++++---------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index ce632a0789..03926c8cc3 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -825,6 +825,7 @@ + diff --git a/config b/config index 63701feb02..08fefceea8 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit 63701feb02a70c6af1e50aa2f0ca812bdab3c233 +Subproject commit 08fefceea80948d89b05d3f8ad58c7fe8cbe57c6 diff --git a/license-report.md b/license-report.md index 45f7a4cd61..5ca255042f 100644 --- a/license-report.md +++ b/license-report.md @@ -330,7 +330,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:23 EET 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 Apr 02 13:23:04 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). @@ -777,7 +777,7 @@ This report was generated on **Thu Mar 26 14:09:23 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:24 EET 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 Apr 02 13:23:05 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). @@ -1170,7 +1170,7 @@ This report was generated on **Thu Mar 26 14:09:24 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:25 EET 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 Apr 02 13:23:06 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). @@ -1537,7 +1537,7 @@ This report was generated on **Thu Mar 26 14:09:25 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:25 EET 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 Apr 02 13:23:06 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). @@ -1920,7 +1920,7 @@ This report was generated on **Thu Mar 26 14:09:25 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:26 EET 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 Apr 02 13:23:07 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). @@ -2305,7 +2305,7 @@ This report was generated on **Thu Mar 26 14:09:26 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:27 EET 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 Apr 02 13:23:08 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). @@ -2672,7 +2672,7 @@ This report was generated on **Thu Mar 26 14:09:27 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:27 EET 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 Apr 02 13:23:08 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). @@ -3097,7 +3097,7 @@ This report was generated on **Thu Mar 26 14:09:27 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:28 EET 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 Apr 02 13:23:09 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). @@ -3464,7 +3464,7 @@ This report was generated on **Thu Mar 26 14:09:28 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:28 EET 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 Apr 02 13:23:09 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). @@ -3831,7 +3831,7 @@ This report was generated on **Thu Mar 26 14:09:28 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:29 EET 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 Apr 02 13:23:10 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). @@ -4158,7 +4158,7 @@ This report was generated on **Thu Mar 26 14:09:29 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:29 EET 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 Apr 02 13:23:10 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). @@ -4493,7 +4493,7 @@ This report was generated on **Thu Mar 26 14:09:29 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:30 EET 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 Apr 02 13:23:10 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). @@ -4878,7 +4878,7 @@ This report was generated on **Thu Mar 26 14:09:30 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:30 EET 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 Apr 02 13:23:11 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). @@ -5213,7 +5213,7 @@ This report was generated on **Thu Mar 26 14:09:30 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:30 EET 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 Apr 02 13:23:11 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). @@ -5548,4 +5548,4 @@ This report was generated on **Thu Mar 26 14:09:30 EET 2020** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Mar 26 14:09:31 EET 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 Apr 02 13:23:12 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 From d5e40131af37383e728c2d220e4fd16bc1576706 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Thu, 2 Apr 2020 13:44:58 +0300 Subject: [PATCH 02/14] Add a new option and update doc --- base/src/main/proto/spine/options.proto | 16 +++++++++++-- license-report.md | 30 ++++++++++++------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/base/src/main/proto/spine/options.proto b/base/src/main/proto/spine/options.proto index 4324ed9127..7146feef37 100644 --- a/base/src/main/proto/spine/options.proto +++ b/base/src/main/proto/spine/options.proto @@ -261,11 +261,23 @@ extend google.protobuf.FieldOptions { // bool column = 73854; - // Reserved 73855 to 73899 for future options. + // Reserved 73855 to 73890 for future options. // Reserved 73900 for removed `by` option. } +extend google.protobuf.OneofOptions { + + // Marks a `oneof` group, in which one field *must* be set. + // + // Alternative to `(required_field)` with all the field in the group joined with the OR + // operator. + // + bool required_fields = 73891; + + // Reserved 73892 to 73899 for future options. +} + extend google.protobuf.MessageOptions { // Validation Constraints @@ -282,7 +294,7 @@ extend google.protobuf.MessageOptions { // // Unlike the `required` field constraint which always require corresponding field, // this message option allows to require alternative fields or a combination of them as - // an alternative. + // an alternative. Field names and `oneof` group names are acceptable. // // Field names are separated using the pipe (`|`) symbol. The combination of fields is defined // using the ampersand (`&`) symbol. diff --git a/license-report.md b/license-report.md index 5ca255042f..1a7365bb12 100644 --- a/license-report.md +++ b/license-report.md @@ -330,7 +330,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:04 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 Apr 02 13:38:22 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). @@ -777,7 +777,7 @@ This report was generated on **Thu Apr 02 13:23:04 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:05 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 Apr 02 13:38:22 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). @@ -1170,7 +1170,7 @@ This report was generated on **Thu Apr 02 13:23:05 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:06 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 Apr 02 13:38: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). @@ -1537,7 +1537,7 @@ This report was generated on **Thu Apr 02 13:23:06 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:06 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 Apr 02 13:38: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). @@ -1920,7 +1920,7 @@ This report was generated on **Thu Apr 02 13:23:06 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:07 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 Apr 02 13:38: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). @@ -2305,7 +2305,7 @@ This report was generated on **Thu Apr 02 13:23:07 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:08 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 Apr 02 13:38: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). @@ -2672,7 +2672,7 @@ This report was generated on **Thu Apr 02 13:23:08 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:08 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 Apr 02 13:38: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). @@ -3097,7 +3097,7 @@ This report was generated on **Thu Apr 02 13:23:08 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:09 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 Apr 02 13:38: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). @@ -3464,7 +3464,7 @@ This report was generated on **Thu Apr 02 13:23:09 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:09 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 Apr 02 13:38: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). @@ -3831,7 +3831,7 @@ This report was generated on **Thu Apr 02 13:23:09 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:10 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 Apr 02 13:38: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). @@ -4158,7 +4158,7 @@ This report was generated on **Thu Apr 02 13:23:10 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:10 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 Apr 02 13:38: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). @@ -4493,7 +4493,7 @@ This report was generated on **Thu Apr 02 13:23:10 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:10 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 Apr 02 13:38: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). @@ -4878,7 +4878,7 @@ This report was generated on **Thu Apr 02 13:23:10 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:11 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 Apr 02 13:38: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). @@ -5213,7 +5213,7 @@ This report was generated on **Thu Apr 02 13:23:11 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:11 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 Apr 02 13:38: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). @@ -5548,4 +5548,4 @@ This report was generated on **Thu Apr 02 13:23:11 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:23:12 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 Apr 02 13:38: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). \ No newline at end of file From daaa0e0db2fde8886623c36012599b1b819130d6 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Thu, 2 Apr 2020 15:59:36 +0300 Subject: [PATCH 03/14] Fix alignment --- .../option/RequiredFieldConstraint.java | 2 +- license-report.md | 30 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/base/src/main/java/io/spine/validate/option/RequiredFieldConstraint.java b/base/src/main/java/io/spine/validate/option/RequiredFieldConstraint.java index 7f6b9637d3..e9be027693 100644 --- a/base/src/main/java/io/spine/validate/option/RequiredFieldConstraint.java +++ b/base/src/main/java/io/spine/validate/option/RequiredFieldConstraint.java @@ -68,7 +68,7 @@ public String optionValue() { return optionValue; } - public ImmutableSet alternatives() { + public ImmutableSet alternatives() { return alternatives; } } diff --git a/license-report.md b/license-report.md index 1a7365bb12..af6b19beba 100644 --- a/license-report.md +++ b/license-report.md @@ -330,7 +330,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:38:22 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 Apr 02 15:38: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). @@ -777,7 +777,7 @@ This report was generated on **Thu Apr 02 13:38:22 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:38:22 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 Apr 02 15:38: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). @@ -1170,7 +1170,7 @@ This report was generated on **Thu Apr 02 13:38:22 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:38: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). +This report was generated on **Thu Apr 02 15:38: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). @@ -1537,7 +1537,7 @@ This report was generated on **Thu Apr 02 13:38:23 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:38: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). +This report was generated on **Thu Apr 02 15:38: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). @@ -1920,7 +1920,7 @@ This report was generated on **Thu Apr 02 13:38:24 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:38: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). +This report was generated on **Thu Apr 02 15:38: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). @@ -2305,7 +2305,7 @@ This report was generated on **Thu Apr 02 13:38:24 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:38: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). +This report was generated on **Thu Apr 02 15:38: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). @@ -2672,7 +2672,7 @@ This report was generated on **Thu Apr 02 13:38:25 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:38: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). +This report was generated on **Thu Apr 02 15:38: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). @@ -3097,7 +3097,7 @@ This report was generated on **Thu Apr 02 13:38:25 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:38: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). +This report was generated on **Thu Apr 02 15:38: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). @@ -3464,7 +3464,7 @@ This report was generated on **Thu Apr 02 13:38:26 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:38: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). +This report was generated on **Thu Apr 02 15:38: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). @@ -3831,7 +3831,7 @@ This report was generated on **Thu Apr 02 13:38:26 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:38: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). +This report was generated on **Thu Apr 02 15:38: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). @@ -4158,7 +4158,7 @@ This report was generated on **Thu Apr 02 13:38:27 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:38: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). +This report was generated on **Thu Apr 02 15:38: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). @@ -4493,7 +4493,7 @@ This report was generated on **Thu Apr 02 13:38:27 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 13:38: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 **Thu Apr 02 15:38: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). @@ -4878,7 +4878,7 @@ This report was generated on **Thu Apr 02 13:38: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 **Thu Apr 02 13:38: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 **Thu Apr 02 15:38: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). @@ -5213,7 +5213,7 @@ This report was generated on **Thu Apr 02 13:38: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 **Thu Apr 02 13:38: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 **Thu Apr 02 15:38: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). @@ -5548,4 +5548,4 @@ This report was generated on **Thu Apr 02 13:38: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 **Thu Apr 02 13:38: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). \ No newline at end of file +This report was generated on **Thu Apr 02 15:38: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). \ No newline at end of file From 87b28fc384160ee58fc67928cb2d388d3917a4bb Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 3 Apr 2020 10:51:44 +0300 Subject: [PATCH 04/14] Define required oneof constraint --- .../java/io/spine/type}/OneofDeclaration.java | 37 +++++------ .../spine/validate/ConstraintTranslator.java | 9 +++ .../io/spine/validate/MessageValidator.java | 19 ++++++ .../spine/validate/option/RequiredFields.java | 46 +++++++++++++ .../option/RequiredFieldsConstraint.java | 64 +++++++++++++++++++ .../io/spine/type}/OneofDeclarationTest.java | 5 +- .../test/type}/oneof_declaration_test.proto | 2 +- .../validate/ValidationCodeGenerator.java | 6 ++ 8 files changed, 162 insertions(+), 26 deletions(-) rename {tools/tool-base/src/main/java/io/spine/code/gen/java => base/src/main/java/io/spine/type}/OneofDeclaration.java (68%) create mode 100644 base/src/main/java/io/spine/validate/option/RequiredFields.java create mode 100644 base/src/main/java/io/spine/validate/option/RequiredFieldsConstraint.java rename {tools/tool-base/src/test/java/io/spine/code/gen/java => base/src/test/java/io/spine/type}/OneofDeclarationTest.java (95%) rename {tools/tool-base/src/test/proto/spine/test/code/generate => base/src/test/proto/spine/test/type}/oneof_declaration_test.proto (96%) diff --git a/tools/tool-base/src/main/java/io/spine/code/gen/java/OneofDeclaration.java b/base/src/main/java/io/spine/type/OneofDeclaration.java similarity index 68% rename from tools/tool-base/src/main/java/io/spine/code/gen/java/OneofDeclaration.java rename to base/src/main/java/io/spine/type/OneofDeclaration.java index 464bda6ed4..9429570f28 100644 --- a/tools/tool-base/src/main/java/io/spine/code/gen/java/OneofDeclaration.java +++ b/base/src/main/java/io/spine/type/OneofDeclaration.java @@ -18,22 +18,23 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.code.gen.java; +package io.spine.type; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import com.google.errorprone.annotations.Immutable; import com.google.protobuf.Descriptors.OneofDescriptor; -import io.spine.code.java.ClassName; -import io.spine.code.java.SimpleClassName; +import io.spine.code.proto.FieldDeclaration; import io.spine.code.proto.FieldName; -import io.spine.type.MessageType; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableSet.toImmutableSet; -import static java.lang.String.format; /** * A declaration of a {@code oneof} field. */ +@Immutable public final class OneofDeclaration { private final OneofDescriptor oneof; @@ -62,22 +63,14 @@ public FieldName name() { return FieldName.of(oneof.getName()); } - /** - * Obtains the name of an enum which represents cases of the {@code oneof} field. - * - *

Such an enum should be nested in the declaring message class. - * - *

If the declaring message class name is {@code com.acme.cms.Customer} and the {@code oneof} - * name is {@code auth_provider}, the resulting class name would be - * {@code com.acme.cms.Customer$AuthProviderCase}. - * - * @return the case enum FQN - */ - public ClassName javaCaseEnum() { - ClassName declaringClassName = declaringType.javaClassName(); - io.spine.code.gen.java.FieldName oneofName = - io.spine.code.gen.java.FieldName.from(name()); - SimpleClassName enumName = SimpleClassName.create(format("%sCase", oneofName.capitalize())); - return declaringClassName.withNested(enumName); + public MessageType declaringType() { + return declaringType; + } + + public ImmutableList fields() { + return oneof.getFields() + .stream() + .map(field -> new FieldDeclaration(field, declaringType)) + .collect(toImmutableList()); } } diff --git a/base/src/main/java/io/spine/validate/ConstraintTranslator.java b/base/src/main/java/io/spine/validate/ConstraintTranslator.java index 063b50d15d..68b3cfc95e 100644 --- a/base/src/main/java/io/spine/validate/ConstraintTranslator.java +++ b/base/src/main/java/io/spine/validate/ConstraintTranslator.java @@ -26,6 +26,7 @@ import io.spine.validate.option.RangedConstraint; import io.spine.validate.option.RequiredConstraint; import io.spine.validate.option.RequiredFieldConstraint; +import io.spine.validate.option.RequiredFieldsConstraint; import io.spine.validate.option.ValidateConstraint; /** @@ -101,6 +102,14 @@ public interface ConstraintTranslator { */ void visitRequiredField(RequiredFieldConstraint constraint); + /** + * Translates the given {@link RequiredFieldsConstraint}. + * + * @param constraint + * the constraint of a oneof group + */ + void visitRequiredOneof(RequiredFieldsConstraint constraint); + /** * Translates the given {@link CustomConstraint}. * diff --git a/base/src/main/java/io/spine/validate/MessageValidator.java b/base/src/main/java/io/spine/validate/MessageValidator.java index 9454aa8de5..288179d90c 100644 --- a/base/src/main/java/io/spine/validate/MessageValidator.java +++ b/base/src/main/java/io/spine/validate/MessageValidator.java @@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Range; import com.google.protobuf.Message; +import io.spine.base.Field; import io.spine.base.FieldPath; import io.spine.code.proto.FieldContext; import io.spine.code.proto.FieldDeclaration; @@ -36,6 +37,7 @@ import io.spine.validate.option.RangedConstraint; import io.spine.validate.option.RequiredConstraint; import io.spine.validate.option.RequiredFieldConstraint; +import io.spine.validate.option.RequiredFieldsConstraint; import io.spine.validate.option.ValidateConstraint; import org.checkerframework.checker.nullness.qual.Nullable; @@ -190,6 +192,23 @@ public void visitRequiredField(RequiredFieldConstraint constraint) { violation.ifPresent(violations::add); } + @Override + public void visitRequiredOneof(RequiredFieldsConstraint constraint) { + ImmutableList fields = constraint.fields(); + boolean noneSet = fields.stream() + .allMatch(this::fieldValueNotSet); + if (noneSet) { + MessageType targetType = constraint.targetType(); + ConstraintViolation violation = ConstraintViolation + .newBuilder() + .setMsgFormat(constraint.errorMessage(message.context())) + .setFieldPath(Field.named(constraint.oneofName().value()).path()) + .setTypeName(targetType.name().value()) + .build(); + violations.add(violation); + } + } + @Override public void visitCustom(CustomConstraint constraint) { ImmutableList violations = constraint.validate(message); diff --git a/base/src/main/java/io/spine/validate/option/RequiredFields.java b/base/src/main/java/io/spine/validate/option/RequiredFields.java new file mode 100644 index 0000000000..31dcb86281 --- /dev/null +++ b/base/src/main/java/io/spine/validate/option/RequiredFields.java @@ -0,0 +1,46 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * 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.validate.option; + +import com.google.errorprone.annotations.Immutable; +import com.google.protobuf.Descriptors.OneofDescriptor; +import io.spine.type.OneofDeclaration; +import io.spine.validate.Constraint; + +import java.util.Optional; + +import static io.spine.option.OptionsProto.requiredFields; + +@Immutable +public class RequiredFields implements ValidatingOption { + + @Override + public Constraint constraintFor(OneofDeclaration field) { + return new RequiredFieldsConstraint(field); + } + + @Override + public Optional valueFrom(OneofDescriptor descriptor) { + boolean value = descriptor.getOptions() + .getExtension(requiredFields); + return value ? Optional.of(true) : Optional.empty(); + } +} diff --git a/base/src/main/java/io/spine/validate/option/RequiredFieldsConstraint.java b/base/src/main/java/io/spine/validate/option/RequiredFieldsConstraint.java new file mode 100644 index 0000000000..1cc5858a00 --- /dev/null +++ b/base/src/main/java/io/spine/validate/option/RequiredFieldsConstraint.java @@ -0,0 +1,64 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * 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.validate.option; + +import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.Immutable; +import io.spine.code.proto.FieldContext; +import io.spine.code.proto.FieldDeclaration; +import io.spine.code.proto.FieldName; +import io.spine.type.MessageType; +import io.spine.type.OneofDeclaration; +import io.spine.validate.Constraint; +import io.spine.validate.ConstraintTranslator; + +@Immutable +public final class RequiredFieldsConstraint implements Constraint { + + private final OneofDeclaration declaration; + + RequiredFieldsConstraint(OneofDeclaration declaration) { + this.declaration = declaration; + } + + @Override + public MessageType targetType() { + return declaration.declaringType(); + } + + @Override + public String errorMessage(FieldContext field) { + return String.format("One of fields in group `%s` must be set.", declaration.name()); + } + + @Override + public void accept(ConstraintTranslator visitor) { + visitor.visitRequiredOneof(this); + } + + public FieldName oneofName() { + return declaration.name(); + } + + public ImmutableList fields() { + return declaration.fields(); + } +} diff --git a/tools/tool-base/src/test/java/io/spine/code/gen/java/OneofDeclarationTest.java b/base/src/test/java/io/spine/type/OneofDeclarationTest.java similarity index 95% rename from tools/tool-base/src/test/java/io/spine/code/gen/java/OneofDeclarationTest.java rename to base/src/test/java/io/spine/type/OneofDeclarationTest.java index aa2b026601..23670526fe 100644 --- a/tools/tool-base/src/test/java/io/spine/code/gen/java/OneofDeclarationTest.java +++ b/base/src/test/java/io/spine/type/OneofDeclarationTest.java @@ -18,14 +18,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.code.gen.java; +package io.spine.type; import com.google.common.testing.NullPointerTester; import com.google.protobuf.Descriptors; import com.google.protobuf.Empty; import io.spine.code.proto.FieldName; -import io.spine.test.code.generate.Transmission; -import io.spine.type.MessageType; +import io.spine.test.type.Transmission; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/tools/tool-base/src/test/proto/spine/test/code/generate/oneof_declaration_test.proto b/base/src/test/proto/spine/test/type/oneof_declaration_test.proto similarity index 96% rename from tools/tool-base/src/test/proto/spine/test/code/generate/oneof_declaration_test.proto rename to base/src/test/proto/spine/test/type/oneof_declaration_test.proto index ecde505d39..ad0395396a 100644 --- a/tools/tool-base/src/test/proto/spine/test/code/generate/oneof_declaration_test.proto +++ b/base/src/test/proto/spine/test/type/oneof_declaration_test.proto @@ -25,7 +25,7 @@ package spine.test.code.generate; import "spine/options.proto"; option (type_url_prefix) = "type.spine.io"; -option java_package = "io.spine.test.code.generate"; +option java_package = "io.spine.test.type"; option java_outer_classname = "OneofDeclarationTestProto"; option java_multiple_files = true; diff --git a/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java b/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java index fba1158406..3b5b586332 100644 --- a/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java +++ b/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java @@ -54,6 +54,7 @@ import io.spine.validate.option.RangedConstraint; import io.spine.validate.option.RequiredConstraint; import io.spine.validate.option.RequiredFieldConstraint; +import io.spine.validate.option.RequiredFieldsConstraint; import io.spine.validate.option.ValidateConstraint; import java.lang.reflect.Type; @@ -333,6 +334,11 @@ public void visitRequiredField(RequiredFieldConstraint constraint) { compiledConstraints.add(check); } + @Override + public void visitRequiredOneof(RequiredFieldsConstraint constraint) { + // TODO:2020-04-03:dmytro.dashenkov: Implement. + } + @Override public void visitCustom(CustomConstraint constraint) { throw unsupported( From 2637cf86a23f0f5368ad76b8e2a4cdf65adfae6d Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 3 Apr 2020 12:33:59 +0300 Subject: [PATCH 05/14] Implement `required_fields` support for generated validation --- license-report.md | 30 +++++++++---------- .../validate/ValidationCodeGenerator.java | 20 ++++++++++++- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/license-report.md b/license-report.md index af6b19beba..78c7d938b1 100644 --- a/license-report.md +++ b/license-report.md @@ -330,7 +330,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 15:38: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). +This report was generated on **Fri Apr 03 12:29: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). @@ -777,7 +777,7 @@ This report was generated on **Thu Apr 02 15:38:23 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 15:38: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). +This report was generated on **Fri Apr 03 12:29: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). @@ -1170,7 +1170,7 @@ This report was generated on **Thu Apr 02 15:38:23 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 15:38: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). +This report was generated on **Fri Apr 03 12:29: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). @@ -1537,7 +1537,7 @@ This report was generated on **Thu Apr 02 15:38:24 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 15:38: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). +This report was generated on **Fri Apr 03 12:29: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). @@ -1920,7 +1920,7 @@ This report was generated on **Thu Apr 02 15:38:24 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 15:38: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). +This report was generated on **Fri Apr 03 12:29: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). @@ -2305,7 +2305,7 @@ This report was generated on **Thu Apr 02 15:38:25 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 15:38: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). +This report was generated on **Fri Apr 03 12:29: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). @@ -2672,7 +2672,7 @@ This report was generated on **Thu Apr 02 15:38:26 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 15:38: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). +This report was generated on **Fri Apr 03 12:29: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). @@ -3097,7 +3097,7 @@ This report was generated on **Thu Apr 02 15:38:26 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 15:38: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). +This report was generated on **Fri Apr 03 12:29: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). @@ -3464,7 +3464,7 @@ This report was generated on **Thu Apr 02 15:38:27 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 15:38: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). +This report was generated on **Fri Apr 03 12:29: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). @@ -3831,7 +3831,7 @@ This report was generated on **Thu Apr 02 15:38:27 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 15:38: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). +This report was generated on **Fri Apr 03 12:29: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). @@ -4158,7 +4158,7 @@ This report was generated on **Thu Apr 02 15:38:27 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Thu Apr 02 15:38: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 **Fri Apr 03 12:29: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). @@ -4493,7 +4493,7 @@ This report was generated on **Thu Apr 02 15:38: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 **Thu Apr 02 15:38: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 **Fri Apr 03 12:29: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). @@ -4878,7 +4878,7 @@ This report was generated on **Thu Apr 02 15:38: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 **Thu Apr 02 15:38: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 **Fri Apr 03 12:29: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). @@ -5213,7 +5213,7 @@ This report was generated on **Thu Apr 02 15:38: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 **Thu Apr 02 15:38: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 **Fri Apr 03 12:29: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). @@ -5548,4 +5548,4 @@ This report was generated on **Thu Apr 02 15:38: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 **Thu Apr 02 15:38: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). \ No newline at end of file +This report was generated on **Fri Apr 03 12:29:34 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/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java b/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java index 3b5b586332..1e87828719 100644 --- a/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java +++ b/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java @@ -336,7 +336,25 @@ public void visitRequiredField(RequiredFieldConstraint constraint) { @Override public void visitRequiredOneof(RequiredFieldsConstraint constraint) { - // TODO:2020-04-03:dmytro.dashenkov: Implement. + ImmutableList fields = constraint.fields(); + BooleanExpression fieldsAreSet = fields + .stream() + .map(field -> new IsSet(field).valueIsNotSet(messageAccess.get(field))) + .reduce(BooleanExpression::or) + .orElseThrow(() -> new IllegalStateException( + "An empty `oneof` group cannot be required." + )); + BooleanExpression condition = fieldsAreSet.negate(); + Expression violation = NewViolation + .forMessage(fieldContext, type) + .setMessage(constraint.errorMessage(fieldContext)) + .setField(fieldContext.fieldPath()) + .build(); + CodeBlock check = condition.ifTrue(violationAccumulator + .apply(violation) + .toCode()) + .toCode(); + compiledConstraints.add(check); } @Override From 99ec7af73cc1d16bdb54f1ed825c9fc71269b252 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 3 Apr 2020 13:35:43 +0300 Subject: [PATCH 06/14] Rename `required_fields` to `is_required` --- .../spine/validate/ConstraintTranslator.java | 6 ++-- .../io/spine/validate/MessageValidator.java | 4 +-- .../{RequiredFields.java => IsRequired.java} | 8 ++--- ...straint.java => IsRequiredConstraint.java} | 4 +-- base/src/main/proto/spine/options.proto | 2 +- .../test/validate/required_fields_test.proto | 12 ++++++++ license-report.md | 30 +++++++++---------- .../validate/ValidationCodeGenerator.java | 4 +-- 8 files changed, 41 insertions(+), 29 deletions(-) rename base/src/main/java/io/spine/validate/option/{RequiredFields.java => IsRequired.java} (84%) rename base/src/main/java/io/spine/validate/option/{RequiredFieldsConstraint.java => IsRequiredConstraint.java} (94%) create mode 100644 base/src/test/proto/spine/test/validate/required_fields_test.proto diff --git a/base/src/main/java/io/spine/validate/ConstraintTranslator.java b/base/src/main/java/io/spine/validate/ConstraintTranslator.java index 68b3cfc95e..26616f39d0 100644 --- a/base/src/main/java/io/spine/validate/ConstraintTranslator.java +++ b/base/src/main/java/io/spine/validate/ConstraintTranslator.java @@ -22,11 +22,11 @@ import io.spine.validate.option.DistinctConstraint; import io.spine.validate.option.GoesConstraint; +import io.spine.validate.option.IsRequiredConstraint; import io.spine.validate.option.PatternConstraint; import io.spine.validate.option.RangedConstraint; import io.spine.validate.option.RequiredConstraint; import io.spine.validate.option.RequiredFieldConstraint; -import io.spine.validate.option.RequiredFieldsConstraint; import io.spine.validate.option.ValidateConstraint; /** @@ -103,12 +103,12 @@ public interface ConstraintTranslator { void visitRequiredField(RequiredFieldConstraint constraint); /** - * Translates the given {@link RequiredFieldsConstraint}. + * Translates the given {@link IsRequiredConstraint}. * * @param constraint * the constraint of a oneof group */ - void visitRequiredOneof(RequiredFieldsConstraint constraint); + void visitRequiredOneof(IsRequiredConstraint constraint); /** * Translates the given {@link CustomConstraint}. diff --git a/base/src/main/java/io/spine/validate/MessageValidator.java b/base/src/main/java/io/spine/validate/MessageValidator.java index 288179d90c..bd88a8d28d 100644 --- a/base/src/main/java/io/spine/validate/MessageValidator.java +++ b/base/src/main/java/io/spine/validate/MessageValidator.java @@ -33,11 +33,11 @@ import io.spine.type.TypeName; import io.spine.validate.option.DistinctConstraint; import io.spine.validate.option.GoesConstraint; +import io.spine.validate.option.IsRequiredConstraint; import io.spine.validate.option.PatternConstraint; import io.spine.validate.option.RangedConstraint; import io.spine.validate.option.RequiredConstraint; import io.spine.validate.option.RequiredFieldConstraint; -import io.spine.validate.option.RequiredFieldsConstraint; import io.spine.validate.option.ValidateConstraint; import org.checkerframework.checker.nullness.qual.Nullable; @@ -193,7 +193,7 @@ public void visitRequiredField(RequiredFieldConstraint constraint) { } @Override - public void visitRequiredOneof(RequiredFieldsConstraint constraint) { + public void visitRequiredOneof(IsRequiredConstraint constraint) { ImmutableList fields = constraint.fields(); boolean noneSet = fields.stream() .allMatch(this::fieldValueNotSet); diff --git a/base/src/main/java/io/spine/validate/option/RequiredFields.java b/base/src/main/java/io/spine/validate/option/IsRequired.java similarity index 84% rename from base/src/main/java/io/spine/validate/option/RequiredFields.java rename to base/src/main/java/io/spine/validate/option/IsRequired.java index 31dcb86281..282dd103f4 100644 --- a/base/src/main/java/io/spine/validate/option/RequiredFields.java +++ b/base/src/main/java/io/spine/validate/option/IsRequired.java @@ -27,20 +27,20 @@ import java.util.Optional; -import static io.spine.option.OptionsProto.requiredFields; +import static io.spine.option.OptionsProto.isRequired; @Immutable -public class RequiredFields implements ValidatingOption { +public class IsRequired implements ValidatingOption { @Override public Constraint constraintFor(OneofDeclaration field) { - return new RequiredFieldsConstraint(field); + return new IsRequiredConstraint(field); } @Override public Optional valueFrom(OneofDescriptor descriptor) { boolean value = descriptor.getOptions() - .getExtension(requiredFields); + .getExtension(isRequired); return value ? Optional.of(true) : Optional.empty(); } } diff --git a/base/src/main/java/io/spine/validate/option/RequiredFieldsConstraint.java b/base/src/main/java/io/spine/validate/option/IsRequiredConstraint.java similarity index 94% rename from base/src/main/java/io/spine/validate/option/RequiredFieldsConstraint.java rename to base/src/main/java/io/spine/validate/option/IsRequiredConstraint.java index 1cc5858a00..ace345f3cf 100644 --- a/base/src/main/java/io/spine/validate/option/RequiredFieldsConstraint.java +++ b/base/src/main/java/io/spine/validate/option/IsRequiredConstraint.java @@ -31,11 +31,11 @@ import io.spine.validate.ConstraintTranslator; @Immutable -public final class RequiredFieldsConstraint implements Constraint { +public final class IsRequiredConstraint implements Constraint { private final OneofDeclaration declaration; - RequiredFieldsConstraint(OneofDeclaration declaration) { + IsRequiredConstraint(OneofDeclaration declaration) { this.declaration = declaration; } diff --git a/base/src/main/proto/spine/options.proto b/base/src/main/proto/spine/options.proto index 7146feef37..4b29b3466f 100644 --- a/base/src/main/proto/spine/options.proto +++ b/base/src/main/proto/spine/options.proto @@ -273,7 +273,7 @@ extend google.protobuf.OneofOptions { // Alternative to `(required_field)` with all the field in the group joined with the OR // operator. // - bool required_fields = 73891; + bool is_required = 73891; // Reserved 73892 to 73899 for future options. } diff --git a/base/src/test/proto/spine/test/validate/required_fields_test.proto b/base/src/test/proto/spine/test/validate/required_fields_test.proto new file mode 100644 index 0000000000..29a29c5348 --- /dev/null +++ b/base/src/test/proto/spine/test/validate/required_fields_test.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package spine.test.validate; + +import "spine/options.proto"; + +option (type_url_prefix) = "type.spine.io"; +option java_package = "io.spine.test.validate"; +option java_outer_classname = "RequiredFieldsTestProto"; +option java_multiple_files = true; + + diff --git a/license-report.md b/license-report.md index 78c7d938b1..f974a83152 100644 --- a/license-report.md +++ b/license-report.md @@ -330,7 +330,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 12:29: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). +This report was generated on **Fri Apr 03 13:34:34 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). @@ -777,7 +777,7 @@ This report was generated on **Fri Apr 03 12:29:26 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 12:29: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). +This report was generated on **Fri Apr 03 13:34:35 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). @@ -1170,7 +1170,7 @@ This report was generated on **Fri Apr 03 12:29:26 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 12:29: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). +This report was generated on **Fri Apr 03 13:34:36 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). @@ -1537,7 +1537,7 @@ This report was generated on **Fri Apr 03 12:29:27 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 12:29: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 **Fri Apr 03 13:34:36 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). @@ -1920,7 +1920,7 @@ This report was generated on **Fri Apr 03 12:29: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 **Fri Apr 03 12:29: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 **Fri Apr 03 13:34: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). @@ -2305,7 +2305,7 @@ This report was generated on **Fri Apr 03 12:29: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 **Fri Apr 03 12:29: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 **Fri Apr 03 13:34: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). @@ -2672,7 +2672,7 @@ This report was generated on **Fri Apr 03 12:29: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 **Fri Apr 03 12:29: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 **Fri Apr 03 13:34: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). @@ -3097,7 +3097,7 @@ This report was generated on **Fri Apr 03 12:29: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 **Fri Apr 03 12:29: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 **Fri Apr 03 13:34: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). @@ -3464,7 +3464,7 @@ This report was generated on **Fri Apr 03 12:29: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 **Fri Apr 03 12:29: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 **Fri Apr 03 13:34: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). @@ -3831,7 +3831,7 @@ This report was generated on **Fri Apr 03 12:29: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 **Fri Apr 03 12:29: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 **Fri Apr 03 13:34: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). @@ -4158,7 +4158,7 @@ This report was generated on **Fri Apr 03 12:29: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 **Fri Apr 03 12:29: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 **Fri Apr 03 13:34: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). @@ -4493,7 +4493,7 @@ This report was generated on **Fri Apr 03 12:29: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 **Fri Apr 03 12:29: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 **Fri Apr 03 13:34: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). @@ -4878,7 +4878,7 @@ This report was generated on **Fri Apr 03 12:29: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 **Fri Apr 03 12:29: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 **Fri Apr 03 13:34: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). @@ -5213,7 +5213,7 @@ This report was generated on **Fri Apr 03 12:29: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 **Fri Apr 03 12:29: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 **Fri Apr 03 13:34:42 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). @@ -5548,4 +5548,4 @@ This report was generated on **Fri Apr 03 12:29: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 **Fri Apr 03 12:29:34 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 **Fri Apr 03 13:34:42 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/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java b/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java index 1e87828719..f429b2b7fe 100644 --- a/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java +++ b/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java @@ -50,11 +50,11 @@ import io.spine.validate.option.DistinctConstraint; import io.spine.validate.option.GoesConstraint; import io.spine.validate.option.IfInvalid; +import io.spine.validate.option.IsRequiredConstraint; import io.spine.validate.option.PatternConstraint; import io.spine.validate.option.RangedConstraint; import io.spine.validate.option.RequiredConstraint; import io.spine.validate.option.RequiredFieldConstraint; -import io.spine.validate.option.RequiredFieldsConstraint; import io.spine.validate.option.ValidateConstraint; import java.lang.reflect.Type; @@ -335,7 +335,7 @@ public void visitRequiredField(RequiredFieldConstraint constraint) { } @Override - public void visitRequiredOneof(RequiredFieldsConstraint constraint) { + public void visitRequiredOneof(IsRequiredConstraint constraint) { ImmutableList fields = constraint.fields(); BooleanExpression fieldsAreSet = fields .stream() From 429d17ae9b89d62bd4ce4db9a479e38f88f225da Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 3 Apr 2020 16:10:13 +0300 Subject: [PATCH 07/14] Scan for `is_required` option --- .../java/io/spine/validate/Constraints.java | 15 ++++++++++ license-report.md | 30 +++++++++---------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/base/src/main/java/io/spine/validate/Constraints.java b/base/src/main/java/io/spine/validate/Constraints.java index d854e46a54..5243350f9b 100644 --- a/base/src/main/java/io/spine/validate/Constraints.java +++ b/base/src/main/java/io/spine/validate/Constraints.java @@ -24,6 +24,8 @@ import com.google.errorprone.annotations.Immutable; import io.spine.code.proto.FieldContext; import io.spine.type.MessageType; +import io.spine.type.OneofDeclaration; +import io.spine.validate.option.IsRequired; import io.spine.validate.option.RequiredField; import static com.google.common.base.Preconditions.checkNotNull; @@ -77,6 +79,7 @@ static Constraints loadFor(MessageType type, FieldContext context) { .flatMap(FieldConstraints::of) .forEach(constraintBuilder::add); addRequiredField(type, constraintBuilder); + scanIsRequired(type, constraintBuilder); return new Constraints(constraintBuilder.build()); } @@ -89,6 +92,18 @@ private static void addRequiredField(MessageType type, } } + private static void scanIsRequired(MessageType type, + ImmutableList.Builder builder) { + IsRequired option = new IsRequired(); + type.descriptor() + .getOneofs() + .stream() + .filter(option::valuePresent) + .map(descriptor -> new OneofDeclaration(descriptor, type)) + .map(option::constraintFor) + .forEach(builder::add); + } + /** * Assembles non-standard constraints from the given message type in the given field context. */ diff --git a/license-report.md b/license-report.md index f974a83152..0b45247b04 100644 --- a/license-report.md +++ b/license-report.md @@ -330,7 +330,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 13:34:34 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 **Fri Apr 03 16:03:00 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). @@ -777,7 +777,7 @@ This report was generated on **Fri Apr 03 13:34:34 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 13:34:35 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 **Fri Apr 03 16:03:01 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). @@ -1170,7 +1170,7 @@ This report was generated on **Fri Apr 03 13:34:35 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 13:34:36 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 **Fri Apr 03 16:03:02 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). @@ -1537,7 +1537,7 @@ This report was generated on **Fri Apr 03 13:34:36 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 13:34:36 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 **Fri Apr 03 16:03:03 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). @@ -1920,7 +1920,7 @@ This report was generated on **Fri Apr 03 13:34:36 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 13:34: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 **Fri Apr 03 16:03:03 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). @@ -2305,7 +2305,7 @@ This report was generated on **Fri Apr 03 13:34: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 **Fri Apr 03 13:34: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 **Fri Apr 03 16:03:04 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). @@ -2672,7 +2672,7 @@ This report was generated on **Fri Apr 03 13:34: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 **Fri Apr 03 13:34: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 **Fri Apr 03 16:03:04 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). @@ -3097,7 +3097,7 @@ This report was generated on **Fri Apr 03 13:34: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 **Fri Apr 03 13:34: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 **Fri Apr 03 16:03:05 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). @@ -3464,7 +3464,7 @@ This report was generated on **Fri Apr 03 13:34: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 **Fri Apr 03 13:34: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 **Fri Apr 03 16:03:06 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). @@ -3831,7 +3831,7 @@ This report was generated on **Fri Apr 03 13:34: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 **Fri Apr 03 13:34: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 **Fri Apr 03 16:03:06 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). @@ -4158,7 +4158,7 @@ This report was generated on **Fri Apr 03 13:34: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 **Fri Apr 03 13:34: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 **Fri Apr 03 16:03:06 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). @@ -4493,7 +4493,7 @@ This report was generated on **Fri Apr 03 13:34: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 **Fri Apr 03 13:34: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 **Fri Apr 03 16:03:07 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). @@ -4878,7 +4878,7 @@ This report was generated on **Fri Apr 03 13:34: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 **Fri Apr 03 13:34: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 **Fri Apr 03 16:03:07 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). @@ -5213,7 +5213,7 @@ This report was generated on **Fri Apr 03 13:34: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 **Fri Apr 03 13:34:42 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 **Fri Apr 03 16:03:08 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). @@ -5548,4 +5548,4 @@ This report was generated on **Fri Apr 03 13:34:42 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 13:34:42 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 **Fri Apr 03 16:03:08 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 From 15d2ad20d52ea5d5a620cc18eab57e07a88421a8 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 3 Apr 2020 16:10:24 +0300 Subject: [PATCH 08/14] Add tests for runtime validation --- .../spine/validate/builders/package-info.java | 31 -------- .../spine/validate/option/IsRequiredTest.java | 77 +++++++++++++++++++ .../test/validate/is_required_test.proto | 44 +++++++++++ .../test/validate/required_fields_test.proto | 12 --- 4 files changed, 121 insertions(+), 43 deletions(-) delete mode 100644 base/src/test/java/io/spine/validate/builders/package-info.java create mode 100644 base/src/test/java/io/spine/validate/option/IsRequiredTest.java create mode 100644 base/src/test/proto/spine/test/validate/is_required_test.proto delete mode 100644 base/src/test/proto/spine/test/validate/required_fields_test.proto diff --git a/base/src/test/java/io/spine/validate/builders/package-info.java b/base/src/test/java/io/spine/validate/builders/package-info.java deleted file mode 100644 index 3163420de0..0000000000 --- a/base/src/test/java/io/spine/validate/builders/package-info.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2020, TeamDev. All rights reserved. - * - * 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. - */ - -/** - * Tests of validating builders are placed into this package - * to simulate usage of the public API. - */ -@CheckReturnValue -@ParametersAreNonnullByDefault -package io.spine.validate.builders; - -import com.google.errorprone.annotations.CheckReturnValue; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/base/src/test/java/io/spine/validate/option/IsRequiredTest.java b/base/src/test/java/io/spine/validate/option/IsRequiredTest.java new file mode 100644 index 0000000000..50fcd2c17a --- /dev/null +++ b/base/src/test/java/io/spine/validate/option/IsRequiredTest.java @@ -0,0 +1,77 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * 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.validate.option; + +import io.spine.test.validate.Fish; +import io.spine.test.validate.Meal; +import io.spine.test.validate.Sauce; +import io.spine.validate.ValidationOfConstraintTest; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static com.google.common.truth.Truth.assertThat; +import static io.spine.base.Identifier.newUuid; +import static io.spine.validate.ValidationOfConstraintTest.VALIDATION_SHOULD; + +@DisplayName(VALIDATION_SHOULD + "analyze (is_required) oneof option and") +class IsRequiredTest extends ValidationOfConstraintTest { + + @Test + @DisplayName("throw if required field group is not set") + void required() { + Meal message = Meal + .newBuilder() + .setCheese(Sauce.getDefaultInstance()) + .buildPartial(); + validate(message); + assertThat(firstViolation().getFieldPath().getFieldName(0)) + .isEqualTo("choice"); + } + + @Test + @DisplayName("not throw if required field group is set") + void requiredSet() { + Fish fish = Fish + .newBuilder() + .setDescription(newUuid()) + .build(); + Meal message = Meal + .newBuilder() + .setCheese(Sauce.getDefaultInstance()) + .setFish(fish) + .buildPartial(); + assertValid(message); + } + + @Test + @DisplayName("ignore non-required field groups") + void notRequired() { + Fish fish = Fish + .newBuilder() + .setDescription(newUuid()) + .build(); + Meal message = Meal + .newBuilder() + .setFish(fish) + .buildPartial(); + assertValid(message); + } +} diff --git a/base/src/test/proto/spine/test/validate/is_required_test.proto b/base/src/test/proto/spine/test/validate/is_required_test.proto new file mode 100644 index 0000000000..9599f0341e --- /dev/null +++ b/base/src/test/proto/spine/test/validate/is_required_test.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; + +package spine.test.validate; + +import "spine/options.proto"; + +option (type_url_prefix) = "type.spine.io"; +option java_package = "io.spine.test.validate"; +option java_outer_classname = "RequiredFieldsTestProto"; +option java_multiple_files = true; + +message Meal { + + oneof choice { + option (is_required) = true; + + Fish fish = 1; + Meat meat = 2; + Vegetables veggies = 3; + } + + oneof sauce { + option (is_required) = false; + + Sauce ketchup = 4; + Sauce cheese = 5; + } +} + +message Fish { + string description = 1; +} + +message Meat { + string description = 1; +} + +message Vegetables { + string description = 1; +} + +message Sauce { + string description = 1; +} diff --git a/base/src/test/proto/spine/test/validate/required_fields_test.proto b/base/src/test/proto/spine/test/validate/required_fields_test.proto deleted file mode 100644 index 29a29c5348..0000000000 --- a/base/src/test/proto/spine/test/validate/required_fields_test.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; - -package spine.test.validate; - -import "spine/options.proto"; - -option (type_url_prefix) = "type.spine.io"; -option java_package = "io.spine.test.validate"; -option java_outer_classname = "RequiredFieldsTestProto"; -option java_multiple_files = true; - - From 9cbc06db85e7b821b4a84d2845cf254e95764bc6 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 3 Apr 2020 16:50:52 +0300 Subject: [PATCH 09/14] Add tests for generated validation --- license-report.md | 30 +++---- .../test/tools/validate/IsRequiredTest.java | 84 +++++++++++++++++++ .../test/tools/validate/is_required.proto | 44 ++++++++++ .../validate/ValidationCodeGenerator.java | 7 +- 4 files changed, 146 insertions(+), 19 deletions(-) create mode 100644 tools/smoke-tests/generated-validation-tests/src/test/java/io/spine/test/tools/validate/IsRequiredTest.java create mode 100644 tools/smoke-tests/generated-validation-tests/src/test/proto/spine/test/tools/validate/is_required.proto diff --git a/license-report.md b/license-report.md index 0b45247b04..ea1dbd0a82 100644 --- a/license-report.md +++ b/license-report.md @@ -330,7 +330,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:00 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 **Fri Apr 03 16:47:21 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). @@ -777,7 +777,7 @@ This report was generated on **Fri Apr 03 16:03:00 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:01 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 **Fri Apr 03 16:47:22 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). @@ -1170,7 +1170,7 @@ This report was generated on **Fri Apr 03 16:03:01 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:02 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 **Fri Apr 03 16:47: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). @@ -1537,7 +1537,7 @@ This report was generated on **Fri Apr 03 16:03:02 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:03 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 **Fri Apr 03 16:47: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). @@ -1920,7 +1920,7 @@ This report was generated on **Fri Apr 03 16:03:03 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:03 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 **Fri Apr 03 16:47: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). @@ -2305,7 +2305,7 @@ This report was generated on **Fri Apr 03 16:03:03 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:04 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 **Fri Apr 03 16:47: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). @@ -2672,7 +2672,7 @@ This report was generated on **Fri Apr 03 16:03:04 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:04 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 **Fri Apr 03 16:47: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). @@ -3097,7 +3097,7 @@ This report was generated on **Fri Apr 03 16:03:04 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:05 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 **Fri Apr 03 16:47: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). @@ -3464,7 +3464,7 @@ This report was generated on **Fri Apr 03 16:03:05 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:06 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 **Fri Apr 03 16:47: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). @@ -3831,7 +3831,7 @@ This report was generated on **Fri Apr 03 16:03:06 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:06 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 **Fri Apr 03 16:47: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). @@ -4158,7 +4158,7 @@ This report was generated on **Fri Apr 03 16:03:06 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:06 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 **Fri Apr 03 16:47: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). @@ -4493,7 +4493,7 @@ This report was generated on **Fri Apr 03 16:03:06 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:07 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 **Fri Apr 03 16:47: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). @@ -4878,7 +4878,7 @@ This report was generated on **Fri Apr 03 16:03:07 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:07 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 **Fri Apr 03 16:47: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). @@ -5213,7 +5213,7 @@ This report was generated on **Fri Apr 03 16:03:07 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:08 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 **Fri Apr 03 16:47: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). @@ -5548,4 +5548,4 @@ This report was generated on **Fri Apr 03 16:03:08 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:03:08 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 **Fri Apr 03 16:47: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/tools/smoke-tests/generated-validation-tests/src/test/java/io/spine/test/tools/validate/IsRequiredTest.java b/tools/smoke-tests/generated-validation-tests/src/test/java/io/spine/test/tools/validate/IsRequiredTest.java new file mode 100644 index 0000000000..d8c3c1bd61 --- /dev/null +++ b/tools/smoke-tests/generated-validation-tests/src/test/java/io/spine/test/tools/validate/IsRequiredTest.java @@ -0,0 +1,84 @@ +/* + * Copyright 2020, TeamDev. All rights reserved. + * + * 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.test.tools.validate; + +import com.google.protobuf.Message; +import io.spine.validate.ConstraintViolation; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static com.google.common.truth.Truth.assertThat; +import static io.spine.base.Identifier.newUuid; +import static io.spine.validate.Validate.violationsOf; + +@DisplayName("`(is_required)` constraint should be compiled so that") +class IsRequiredTest { + + @Test + @DisplayName("throw if required field group is not set") + void required() { + Meal message = Meal + .newBuilder() + .setCheese(Sauce.getDefaultInstance()) + .buildPartial(); + List violations = violationsOf(message); + assertThat(violations) + .hasSize(1); + assertThat(violations.get(0).getMsgFormat()) + .contains("choice"); + } + + @Test + @DisplayName("not throw if required field group is set") + void requiredSet() { + Fish fish = Fish + .newBuilder() + .setDescription(newUuid()) + .build(); + Meal message = Meal + .newBuilder() + .setCheese(Sauce.getDefaultInstance()) + .setFish(fish) + .buildPartial(); + assertValid(message); + } + + @Test + @DisplayName("ignore non-required field groups") + void notRequired() { + Fish fish = Fish + .newBuilder() + .setDescription(newUuid()) + .build(); + Meal message = Meal + .newBuilder() + .setFish(fish) + .buildPartial(); + assertValid(message); + } + + private static void assertValid(Message message) { + assertThat(violationsOf(message)) + .isEmpty(); + } +} diff --git a/tools/smoke-tests/generated-validation-tests/src/test/proto/spine/test/tools/validate/is_required.proto b/tools/smoke-tests/generated-validation-tests/src/test/proto/spine/test/tools/validate/is_required.proto new file mode 100644 index 0000000000..a9ead48b44 --- /dev/null +++ b/tools/smoke-tests/generated-validation-tests/src/test/proto/spine/test/tools/validate/is_required.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; + +package spine.test.tools.validate; + +import "spine/options.proto"; + +option (type_url_prefix) = "type.spine.io"; +option java_package = "io.spine.test.tools.validate"; +option java_outer_classname = "RequiredFieldsProto"; +option java_multiple_files = true; + +message Meal { + + oneof choice { + option (is_required) = true; + + Fish fish = 1; + Meat meat = 2; + Vegetables veggies = 3; + } + + oneof sauce { + option (is_required) = false; + + Sauce ketchup = 4; + Sauce cheese = 5; + } +} + +message Fish { + string description = 1; +} + +message Meat { + string description = 1; +} + +message Vegetables { + string description = 1; +} + +message Sauce { + string description = 1; +} diff --git a/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java b/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java index f429b2b7fe..c9e370cc5f 100644 --- a/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java +++ b/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java @@ -337,15 +337,14 @@ public void visitRequiredField(RequiredFieldConstraint constraint) { @Override public void visitRequiredOneof(IsRequiredConstraint constraint) { ImmutableList fields = constraint.fields(); - BooleanExpression fieldsAreSet = fields + BooleanExpression condition = fields .stream() .map(field -> new IsSet(field).valueIsNotSet(messageAccess.get(field))) - .reduce(BooleanExpression::or) + .reduce(BooleanExpression::and) .orElseThrow(() -> new IllegalStateException( "An empty `oneof` group cannot be required." )); - BooleanExpression condition = fieldsAreSet.negate(); - Expression violation = NewViolation + Expression violation = NewViolation .forMessage(fieldContext, type) .setMessage(constraint.errorMessage(fieldContext)) .setField(fieldContext.fieldPath()) From ddc9130bf3ccbe4c10040df23de3295849bec6ea Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 3 Apr 2020 17:13:01 +0300 Subject: [PATCH 10/14] Update version --- .idea/misc.xml | 15 ++---------- license-report.md | 60 +++++++++++++++++++++++------------------------ pom.xml | 4 ++-- version.gradle | 2 +- 4 files changed, 35 insertions(+), 46 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 034cdfdf80..deb97c8116 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,17 +1,12 @@ - - - - diff --git a/license-report.md b/license-report.md index ea1dbd0a82..02d145ca42 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine:spine-base:1.5.2` +# Dependencies of `io.spine:spine-base:1.5.4` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -330,12 +330,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47:21 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 **Fri Apr 03 16:59:44 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.2` +# Dependencies of `io.spine.tools:spine-errorprone-checks:1.5.4` ## Runtime 1. **Group:** com.github.ben-manes.caffeine **Name:** caffeine **Version:** 2.7.0 @@ -777,12 +777,12 @@ This report was generated on **Fri Apr 03 16:47:21 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47:22 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 **Fri Apr 03 16:59:45 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.2` +# Dependencies of `io.spine.tools:spine-javadoc-filter:1.5.4` ## Runtime 1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4 @@ -1170,12 +1170,12 @@ This report was generated on **Fri Apr 03 16:47:22 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47: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). +This report was generated on **Fri Apr 03 16:59:45 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.2` +# Dependencies of `io.spine.tools:spine-javadoc-prettifier:1.5.4` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -1537,12 +1537,12 @@ This report was generated on **Fri Apr 03 16:47:23 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47: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). +This report was generated on **Fri Apr 03 16:59:46 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.2` +# Dependencies of `io.spine.tools:spine-model-compiler:1.5.4` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -1920,12 +1920,12 @@ This report was generated on **Fri Apr 03 16:47:23 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47: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). +This report was generated on **Fri Apr 03 16:59:46 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.2` +# Dependencies of `io.spine.tools:spine-mute-logging:1.5.4` ## Runtime 1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.6.3 @@ -2305,12 +2305,12 @@ This report was generated on **Fri Apr 03 16:47:24 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47: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). +This report was generated on **Fri Apr 03 16:59:47 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.2` +# Dependencies of `io.spine.tools:spine-plugin-base:1.5.4` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -2672,12 +2672,12 @@ This report was generated on **Fri Apr 03 16:47:24 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47: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). +This report was generated on **Fri Apr 03 16:59:47 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.2` +# Dependencies of `io.spine.tools:spine-plugin-testlib:1.5.4` ## Runtime 1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.6.3 @@ -3097,12 +3097,12 @@ This report was generated on **Fri Apr 03 16:47:25 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47: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). +This report was generated on **Fri Apr 03 16:59:48 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.2` +# Dependencies of `io.spine.tools:spine-proto-dart-plugin:1.5.4` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -3464,12 +3464,12 @@ This report was generated on **Fri Apr 03 16:47:25 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47: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). +This report was generated on **Fri Apr 03 16:59:48 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.2` +# Dependencies of `io.spine.tools:spine-proto-js-plugin:1.5.4` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -3831,12 +3831,12 @@ This report was generated on **Fri Apr 03 16:47:25 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47: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). +This report was generated on **Fri Apr 03 16:59:49 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.2` +# Dependencies of `io.spine.tools:spine-protoc-api:1.5.4` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -4158,12 +4158,12 @@ This report was generated on **Fri Apr 03 16:47:26 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47: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). +This report was generated on **Fri Apr 03 16:59:49 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.2` +# Dependencies of `io.spine.tools:spine-protoc-plugin:1.5.4` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -4493,12 +4493,12 @@ This report was generated on **Fri Apr 03 16:47:26 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47: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). +This report was generated on **Fri Apr 03 16:59:49 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.2` +# Dependencies of `io.spine:spine-testlib:1.5.4` ## Runtime 1. **Group:** com.google.auto.value **Name:** auto-value-annotations **Version:** 1.6.3 @@ -4878,12 +4878,12 @@ This report was generated on **Fri Apr 03 16:47:27 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47: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). +This report was generated on **Fri Apr 03 16:59:50 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.2` +# Dependencies of `io.spine.tools:spine-tool-base:1.5.4` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -5213,12 +5213,12 @@ This report was generated on **Fri Apr 03 16:47:27 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47: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). +This report was generated on **Fri Apr 03 16:59:50 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.2` +# Dependencies of `io.spine.tools:spine-validation-generator:1.5.4` ## Runtime 1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2 @@ -5548,4 +5548,4 @@ This report was generated on **Fri Apr 03 16:47:27 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:47: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 +This report was generated on **Fri Apr 03 16:59:50 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 77b0fb3b1d..a53084ee50 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.3 +1.5.4 2015 @@ -154,7 +154,7 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-protoc-plugin - 1.5.3 + 1.5.4 test diff --git a/version.gradle b/version.gradle index 803e8d3b1a..8d3d59d0b5 100644 --- a/version.gradle +++ b/version.gradle @@ -25,7 +25,7 @@ * as we want to manage the versions in a single source. */ -final def SPINE_VERSION = '1.5.3' +final def SPINE_VERSION = '1.5.4' ext { spineVersion = SPINE_VERSION From f455547e6db848dc210ae5f0c51d40297b5bf26d Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 3 Apr 2020 18:46:23 +0300 Subject: [PATCH 11/14] Optimize condition checks and add doc --- .../java/io/spine/type/OneofDeclaration.java | 30 +++++-------------- .../io/spine/validate/MessageValidator.java | 5 ++-- .../java/io/spine/validate/MessageValue.java | 20 +++++++++++-- .../validate/option/IsRequiredConstraint.java | 15 +++++++--- .../option/RequiredFieldConstraint.java | 8 +++++ license-report.md | 30 +++++++++---------- .../spine/tools/validate/MessageAccess.java | 8 +++++ .../validate/ValidationCodeGenerator.java | 12 +++----- 8 files changed, 72 insertions(+), 56 deletions(-) diff --git a/base/src/main/java/io/spine/type/OneofDeclaration.java b/base/src/main/java/io/spine/type/OneofDeclaration.java index 9429570f28..f4c583b701 100644 --- a/base/src/main/java/io/spine/type/OneofDeclaration.java +++ b/base/src/main/java/io/spine/type/OneofDeclaration.java @@ -20,16 +20,11 @@ package io.spine.type; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; import com.google.errorprone.annotations.Immutable; import com.google.protobuf.Descriptors.OneofDescriptor; -import io.spine.code.proto.FieldDeclaration; import io.spine.code.proto.FieldName; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.ImmutableList.toImmutableList; -import static com.google.common.collect.ImmutableSet.toImmutableSet; /** * A declaration of a {@code oneof} field. @@ -45,17 +40,6 @@ public OneofDeclaration(OneofDescriptor oneof, MessageType type) { this.declaringType = checkNotNull(type); } - public static ImmutableSet allFromType(MessageType declaringType) { - checkNotNull(declaringType); - ImmutableSet result = - declaringType.descriptor() - .getOneofs() - .stream() - .map(oneof -> new OneofDeclaration(oneof, declaringType)) - .collect(toImmutableSet()); - return result; - } - /** * Obtains the name of the {@code oneof} field. */ @@ -63,14 +47,14 @@ public FieldName name() { return FieldName.of(oneof.getName()); } - public MessageType declaringType() { - return declaringType; + /** + * Obtains the {@code oneof} descriptor. + */ + public OneofDescriptor descriptor() { + return oneof; } - public ImmutableList fields() { - return oneof.getFields() - .stream() - .map(field -> new FieldDeclaration(field, declaringType)) - .collect(toImmutableList()); + public MessageType declaringType() { + return declaringType; } } diff --git a/base/src/main/java/io/spine/validate/MessageValidator.java b/base/src/main/java/io/spine/validate/MessageValidator.java index bd88a8d28d..1e2d163847 100644 --- a/base/src/main/java/io/spine/validate/MessageValidator.java +++ b/base/src/main/java/io/spine/validate/MessageValidator.java @@ -194,9 +194,8 @@ public void visitRequiredField(RequiredFieldConstraint constraint) { @Override public void visitRequiredOneof(IsRequiredConstraint constraint) { - ImmutableList fields = constraint.fields(); - boolean noneSet = fields.stream() - .allMatch(this::fieldValueNotSet); + Optional fieldValue = message.valueOf(constraint.declaration()); + boolean noneSet = !fieldValue.isPresent(); if (noneSet) { MessageType targetType = constraint.targetType(); ConstraintViolation violation = ConstraintViolation diff --git a/base/src/main/java/io/spine/validate/MessageValue.java b/base/src/main/java/io/spine/validate/MessageValue.java index 5dda308d6a..9648dc9df7 100644 --- a/base/src/main/java/io/spine/validate/MessageValue.java +++ b/base/src/main/java/io/spine/validate/MessageValue.java @@ -28,6 +28,7 @@ import io.spine.code.proto.FieldContext; import io.spine.code.proto.FieldDeclaration; import io.spine.type.MessageType; +import io.spine.type.OneofDeclaration; import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Optional; @@ -147,10 +148,10 @@ public FieldValue valueOf(FieldDeclaration field) { } /** - * Obtains the value of a populated {@code Oneof} field. + * Obtains the value of a populated {@code oneof} field. * * @param oneof - * the {@code Oneof} descriptor + * the {@code oneof} descriptor * @return a value of the populated field * or {@code Optional.empty()} if the field was not populated * @throws IllegalArgumentException @@ -163,6 +164,20 @@ public Optional valueOf(OneofDescriptor oneof) { return valueOfNullable(field); } + /** + * Obtains the value of a populated {@code oneof} field. + * + * @param oneof + * the {@code oneof} declaration + * @return a value of the populated field + * or {@code Optional.empty()} if the field was not populated + * @throws IllegalArgumentException + * if the if the message doesn't declare this oneof + */ + public Optional valueOf(OneofDeclaration oneof) { + return valueOf(oneof.descriptor()); + } + /** Returns the context of the message. */ @SuppressWarnings("unused") FieldContext context() { @@ -188,5 +203,4 @@ private FieldValue valueOfField(FieldDescriptor field) { private Object readValue(FieldDescriptor field) { return asFieldAware == null ? message.getField(field) : asFieldAware.readValue(field); } - } diff --git a/base/src/main/java/io/spine/validate/option/IsRequiredConstraint.java b/base/src/main/java/io/spine/validate/option/IsRequiredConstraint.java index ace345f3cf..3e5afbf30e 100644 --- a/base/src/main/java/io/spine/validate/option/IsRequiredConstraint.java +++ b/base/src/main/java/io/spine/validate/option/IsRequiredConstraint.java @@ -20,16 +20,17 @@ package io.spine.validate.option; -import com.google.common.collect.ImmutableList; import com.google.errorprone.annotations.Immutable; import io.spine.code.proto.FieldContext; -import io.spine.code.proto.FieldDeclaration; import io.spine.code.proto.FieldName; import io.spine.type.MessageType; import io.spine.type.OneofDeclaration; import io.spine.validate.Constraint; import io.spine.validate.ConstraintTranslator; +/** + * A {@code oneof} group constraint which signifies that one of the fields must be set. + */ @Immutable public final class IsRequiredConstraint implements Constraint { @@ -54,11 +55,17 @@ public void accept(ConstraintTranslator visitor) { visitor.visitRequiredOneof(this); } + /** + * Obtains the name of the {@code oneof} group. + */ public FieldName oneofName() { return declaration.name(); } - public ImmutableList fields() { - return declaration.fields(); + /** + * Obtains the {@code oneof} declaration. + */ + public OneofDeclaration declaration() { + return declaration; } } diff --git a/base/src/main/java/io/spine/validate/option/RequiredFieldConstraint.java b/base/src/main/java/io/spine/validate/option/RequiredFieldConstraint.java index e9be027693..a6509d7b0c 100644 --- a/base/src/main/java/io/spine/validate/option/RequiredFieldConstraint.java +++ b/base/src/main/java/io/spine/validate/option/RequiredFieldConstraint.java @@ -64,10 +64,18 @@ public void accept(ConstraintTranslator visitor) { visitor.visitRequiredField(this); } + /** + * Obtains the raw option value. + */ public String optionValue() { return optionValue; } + /** + * Obtains the set of alternative conjunctive field expressions. + * + * @see Alternative + */ public ImmutableSet alternatives() { return alternatives; } diff --git a/license-report.md b/license-report.md index 02d145ca42..181e1be912 100644 --- a/license-report.md +++ b/license-report.md @@ -330,7 +330,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:44 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 **Fri Apr 03 18:42:58 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). @@ -777,7 +777,7 @@ This report was generated on **Fri Apr 03 16:59:44 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:45 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 **Fri Apr 03 18:42:58 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). @@ -1170,7 +1170,7 @@ This report was generated on **Fri Apr 03 16:59:45 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:45 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 **Fri Apr 03 18:42:59 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). @@ -1537,7 +1537,7 @@ This report was generated on **Fri Apr 03 16:59:45 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:46 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 **Fri Apr 03 18:42:59 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). @@ -1920,7 +1920,7 @@ This report was generated on **Fri Apr 03 16:59:46 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:46 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 **Fri Apr 03 18:43:00 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). @@ -2305,7 +2305,7 @@ This report was generated on **Fri Apr 03 16:59:46 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:47 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 **Fri Apr 03 18:43:00 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). @@ -2672,7 +2672,7 @@ This report was generated on **Fri Apr 03 16:59:47 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:47 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 **Fri Apr 03 18:43:01 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). @@ -3097,7 +3097,7 @@ This report was generated on **Fri Apr 03 16:59:47 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:48 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 **Fri Apr 03 18:43:01 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). @@ -3464,7 +3464,7 @@ This report was generated on **Fri Apr 03 16:59:48 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:48 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 **Fri Apr 03 18:43:02 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). @@ -3831,7 +3831,7 @@ This report was generated on **Fri Apr 03 16:59:48 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:49 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 **Fri Apr 03 18:43:02 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). @@ -4158,7 +4158,7 @@ This report was generated on **Fri Apr 03 16:59:49 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:49 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 **Fri Apr 03 18:43:03 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). @@ -4493,7 +4493,7 @@ This report was generated on **Fri Apr 03 16:59:49 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:49 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 **Fri Apr 03 18:43:03 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). @@ -4878,7 +4878,7 @@ This report was generated on **Fri Apr 03 16:59:49 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:50 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 **Fri Apr 03 18:43:04 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). @@ -5213,7 +5213,7 @@ This report was generated on **Fri Apr 03 16:59:50 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:50 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 **Fri Apr 03 18:43:04 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). @@ -5548,4 +5548,4 @@ This report was generated on **Fri Apr 03 16:59:50 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 16:59:50 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 **Fri Apr 03 18:43:05 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/tools/validation-generator/src/main/java/io/spine/tools/validate/MessageAccess.java b/tools/validation-generator/src/main/java/io/spine/tools/validate/MessageAccess.java index 68b81581a7..1fc7f42e80 100644 --- a/tools/validation-generator/src/main/java/io/spine/tools/validate/MessageAccess.java +++ b/tools/validation-generator/src/main/java/io/spine/tools/validate/MessageAccess.java @@ -21,11 +21,15 @@ package io.spine.tools.validate; import com.google.protobuf.Message; +import com.google.protobuf.ProtocolMessageEnum; import io.spine.code.proto.FieldDeclaration; import io.spine.tools.validate.code.CodeExpression; +import io.spine.tools.validate.code.Expression; +import io.spine.type.OneofDeclaration; import static com.google.common.base.Preconditions.checkNotNull; import static io.spine.tools.validate.FieldAccess.fieldOfMessage; +import static io.spine.tools.validate.code.Expression.formatted; /** * An expression which yields a message. @@ -49,4 +53,8 @@ public static MessageAccess of(String value) { public FieldAccess get(FieldDeclaration field) { return fieldOfMessage(this, field); } + + public Expression oneofCase(OneofDeclaration declaration) { + return formatted("%s.get%sCase()", this, declaration.name().toCamelCase()); + } } diff --git a/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java b/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java index c9e370cc5f..9b425383a5 100644 --- a/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java +++ b/tools/validation-generator/src/main/java/io/spine/tools/validate/ValidationCodeGenerator.java @@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Range; import com.google.common.reflect.TypeToken; +import com.google.protobuf.ProtocolMessageEnum; import com.squareup.javapoet.ClassName; import com.squareup.javapoet.CodeBlock; import io.spine.code.proto.FieldContext; @@ -336,14 +337,9 @@ public void visitRequiredField(RequiredFieldConstraint constraint) { @Override public void visitRequiredOneof(IsRequiredConstraint constraint) { - ImmutableList fields = constraint.fields(); - BooleanExpression condition = fields - .stream() - .map(field -> new IsSet(field).valueIsNotSet(messageAccess.get(field))) - .reduce(BooleanExpression::and) - .orElseThrow(() -> new IllegalStateException( - "An empty `oneof` group cannot be required." - )); + Expression caseValue = + messageAccess.oneofCase(constraint.declaration()); + BooleanExpression condition = fromCode("$L.getNumber() == $L", caseValue, 0); Expression violation = NewViolation .forMessage(fieldContext, type) .setMessage(constraint.errorMessage(fieldContext)) From 29dea246004f7068b2f87cca14ddb8e3f28e5044 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 3 Apr 2020 18:52:15 +0300 Subject: [PATCH 12/14] Add doc --- base/src/main/java/io/spine/type/OneofDeclaration.java | 5 ++++- base/src/main/java/io/spine/validate/option/IsRequired.java | 5 +++++ .../src/main/java/io/spine/tools/validate/MessageAccess.java | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/base/src/main/java/io/spine/type/OneofDeclaration.java b/base/src/main/java/io/spine/type/OneofDeclaration.java index f4c583b701..f68b9246d1 100644 --- a/base/src/main/java/io/spine/type/OneofDeclaration.java +++ b/base/src/main/java/io/spine/type/OneofDeclaration.java @@ -27,7 +27,7 @@ import static com.google.common.base.Preconditions.checkNotNull; /** - * A declaration of a {@code oneof} field. + * A declaration of a {@code oneof} field group. */ @Immutable public final class OneofDeclaration { @@ -54,6 +54,9 @@ public OneofDescriptor descriptor() { return oneof; } + /** + * Obtains the type containing this group. + */ public MessageType declaringType() { return declaringType; } diff --git a/base/src/main/java/io/spine/validate/option/IsRequired.java b/base/src/main/java/io/spine/validate/option/IsRequired.java index 282dd103f4..2dee94ed99 100644 --- a/base/src/main/java/io/spine/validate/option/IsRequired.java +++ b/base/src/main/java/io/spine/validate/option/IsRequired.java @@ -29,6 +29,11 @@ import static io.spine.option.OptionsProto.isRequired; +/** + * A {@code oneof} validation option which constrains the target {@code oneof} group to be set. + * + *

If the value of the option is {@code true}, one of the fields in the group must be set. + */ @Immutable public class IsRequired implements ValidatingOption { diff --git a/tools/validation-generator/src/main/java/io/spine/tools/validate/MessageAccess.java b/tools/validation-generator/src/main/java/io/spine/tools/validate/MessageAccess.java index 1fc7f42e80..0ab206f853 100644 --- a/tools/validation-generator/src/main/java/io/spine/tools/validate/MessageAccess.java +++ b/tools/validation-generator/src/main/java/io/spine/tools/validate/MessageAccess.java @@ -54,6 +54,11 @@ public FieldAccess get(FieldDeclaration field) { return fieldOfMessage(this, field); } + /** + * Builds an expression which yields the {@code oneof} case for the given {@code oneof}. + * + *

The case is represented by an enum value. See the Protobuf doc for more info on the enum. + */ public Expression oneofCase(OneofDeclaration declaration) { return formatted("%s.get%sCase()", this, declaration.name().toCamelCase()); } From 3a647d6bd2d4e4160e51bcd3d07009b2b0a1f622 Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Fri, 3 Apr 2020 19:17:56 +0300 Subject: [PATCH 13/14] Extend model to cover new validation with traceable tests --- license-report.md | 30 +++++++++---------- .../spine/test/validate/avocado_farm.proto | 17 +++++++++++ 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/license-report.md b/license-report.md index 181e1be912..33d9ce7247 100644 --- a/license-report.md +++ b/license-report.md @@ -330,7 +330,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:42:58 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 **Fri Apr 03 19:14:47 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). @@ -777,7 +777,7 @@ This report was generated on **Fri Apr 03 18:42:58 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:42:58 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 **Fri Apr 03 19:14:47 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). @@ -1170,7 +1170,7 @@ This report was generated on **Fri Apr 03 18:42:58 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:42:59 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 **Fri Apr 03 19:14:48 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). @@ -1537,7 +1537,7 @@ This report was generated on **Fri Apr 03 18:42:59 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:42:59 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 **Fri Apr 03 19:14:49 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). @@ -1920,7 +1920,7 @@ This report was generated on **Fri Apr 03 18:42:59 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:43:00 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 **Fri Apr 03 19:14:49 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). @@ -2305,7 +2305,7 @@ This report was generated on **Fri Apr 03 18:43:00 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:43:00 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 **Fri Apr 03 19:14:50 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). @@ -2672,7 +2672,7 @@ This report was generated on **Fri Apr 03 18:43:00 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:43:01 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 **Fri Apr 03 19:14:50 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). @@ -3097,7 +3097,7 @@ This report was generated on **Fri Apr 03 18:43:01 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:43:01 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 **Fri Apr 03 19:14:51 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). @@ -3464,7 +3464,7 @@ This report was generated on **Fri Apr 03 18:43:01 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:43:02 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 **Fri Apr 03 19:14:51 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). @@ -3831,7 +3831,7 @@ This report was generated on **Fri Apr 03 18:43:02 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:43:02 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 **Fri Apr 03 19:14:52 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). @@ -4158,7 +4158,7 @@ This report was generated on **Fri Apr 03 18:43:02 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:43:03 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 **Fri Apr 03 19:14:52 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). @@ -4493,7 +4493,7 @@ This report was generated on **Fri Apr 03 18:43:03 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:43:03 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 **Fri Apr 03 19:14:53 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). @@ -4878,7 +4878,7 @@ This report was generated on **Fri Apr 03 18:43:03 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:43:04 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 **Fri Apr 03 19:14:53 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). @@ -5213,7 +5213,7 @@ This report was generated on **Fri Apr 03 18:43:04 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:43:04 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 **Fri Apr 03 19:14:53 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). @@ -5548,4 +5548,4 @@ This report was generated on **Fri Apr 03 18:43:04 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 18:43:05 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 **Fri Apr 03 19:14:54 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/tools/validation-generator/src/test/proto/spine/test/validate/avocado_farm.proto b/tools/validation-generator/src/test/proto/spine/test/validate/avocado_farm.proto index b51313b968..b9b3b4756f 100644 --- a/tools/validation-generator/src/test/proto/spine/test/validate/avocado_farm.proto +++ b/tools/validation-generator/src/test/proto/spine/test/validate/avocado_farm.proto @@ -27,6 +27,14 @@ message Greenhouse { HumidityRange humidity = 5 [(required) = true, (.validate) = true]; repeated Sort sort = 6 [(required) = false, (distinct) = true]; + + oneof lighting { + option (is_required) = true; + + LightBulb incandescent = 7 [deprecated = true]; + + UvLightStrip uv = 8; + } } message Sort { @@ -56,3 +64,12 @@ message HumidityRange { Humidity highest_allowed = 2 [(required) = true, (.validate) = true]; } + +message LightBulb { + uint32 wattage = 1 [(min).value = "1"]; +} + +message UvLightStrip { + float min_wave_length = 1; + float max_wave_length = 2; +} From 1d45767407e9968483302e827451dc4d08f592ed Mon Sep 17 00:00:00 2001 From: Dmytro Dashenkov Date: Mon, 6 Apr 2020 12:06:00 +0300 Subject: [PATCH 14/14] Move `OneofDeclaration` to `io.spine.code.proto` --- .../proto}/OneofDeclaration.java | 4 +-- .../java/io/spine/validate/Constraints.java | 2 +- .../java/io/spine/validate/MessageValue.java | 2 +- .../io/spine/validate/option/IsRequired.java | 2 +- .../validate/option/IsRequiredConstraint.java | 2 +- .../proto}/OneofDeclarationTest.java | 6 ++-- license-report.md | 30 +++++++++---------- .../spine/tools/validate/MessageAccess.java | 2 +- 8 files changed, 24 insertions(+), 26 deletions(-) rename base/src/main/java/io/spine/{type => code/proto}/OneofDeclaration.java (96%) rename base/src/test/java/io/spine/{type => code/proto}/OneofDeclarationTest.java (93%) diff --git a/base/src/main/java/io/spine/type/OneofDeclaration.java b/base/src/main/java/io/spine/code/proto/OneofDeclaration.java similarity index 96% rename from base/src/main/java/io/spine/type/OneofDeclaration.java rename to base/src/main/java/io/spine/code/proto/OneofDeclaration.java index f68b9246d1..c695b7d626 100644 --- a/base/src/main/java/io/spine/type/OneofDeclaration.java +++ b/base/src/main/java/io/spine/code/proto/OneofDeclaration.java @@ -18,11 +18,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.type; +package io.spine.code.proto; import com.google.errorprone.annotations.Immutable; import com.google.protobuf.Descriptors.OneofDescriptor; -import io.spine.code.proto.FieldName; +import io.spine.type.MessageType; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/base/src/main/java/io/spine/validate/Constraints.java b/base/src/main/java/io/spine/validate/Constraints.java index 5243350f9b..49c8fa2360 100644 --- a/base/src/main/java/io/spine/validate/Constraints.java +++ b/base/src/main/java/io/spine/validate/Constraints.java @@ -23,8 +23,8 @@ import com.google.common.collect.ImmutableList; import com.google.errorprone.annotations.Immutable; import io.spine.code.proto.FieldContext; +import io.spine.code.proto.OneofDeclaration; import io.spine.type.MessageType; -import io.spine.type.OneofDeclaration; import io.spine.validate.option.IsRequired; import io.spine.validate.option.RequiredField; diff --git a/base/src/main/java/io/spine/validate/MessageValue.java b/base/src/main/java/io/spine/validate/MessageValue.java index 9648dc9df7..d36eca58b0 100644 --- a/base/src/main/java/io/spine/validate/MessageValue.java +++ b/base/src/main/java/io/spine/validate/MessageValue.java @@ -27,8 +27,8 @@ import com.google.protobuf.Message; import io.spine.code.proto.FieldContext; import io.spine.code.proto.FieldDeclaration; +import io.spine.code.proto.OneofDeclaration; import io.spine.type.MessageType; -import io.spine.type.OneofDeclaration; import org.checkerframework.checker.nullness.qual.Nullable; import java.util.Optional; diff --git a/base/src/main/java/io/spine/validate/option/IsRequired.java b/base/src/main/java/io/spine/validate/option/IsRequired.java index 2dee94ed99..10e1ebd6c0 100644 --- a/base/src/main/java/io/spine/validate/option/IsRequired.java +++ b/base/src/main/java/io/spine/validate/option/IsRequired.java @@ -22,7 +22,7 @@ import com.google.errorprone.annotations.Immutable; import com.google.protobuf.Descriptors.OneofDescriptor; -import io.spine.type.OneofDeclaration; +import io.spine.code.proto.OneofDeclaration; import io.spine.validate.Constraint; import java.util.Optional; diff --git a/base/src/main/java/io/spine/validate/option/IsRequiredConstraint.java b/base/src/main/java/io/spine/validate/option/IsRequiredConstraint.java index 3e5afbf30e..8944a91c94 100644 --- a/base/src/main/java/io/spine/validate/option/IsRequiredConstraint.java +++ b/base/src/main/java/io/spine/validate/option/IsRequiredConstraint.java @@ -23,8 +23,8 @@ import com.google.errorprone.annotations.Immutable; import io.spine.code.proto.FieldContext; import io.spine.code.proto.FieldName; +import io.spine.code.proto.OneofDeclaration; import io.spine.type.MessageType; -import io.spine.type.OneofDeclaration; import io.spine.validate.Constraint; import io.spine.validate.ConstraintTranslator; diff --git a/base/src/test/java/io/spine/type/OneofDeclarationTest.java b/base/src/test/java/io/spine/code/proto/OneofDeclarationTest.java similarity index 93% rename from base/src/test/java/io/spine/type/OneofDeclarationTest.java rename to base/src/test/java/io/spine/code/proto/OneofDeclarationTest.java index 23670526fe..e01073dfb7 100644 --- a/base/src/test/java/io/spine/type/OneofDeclarationTest.java +++ b/base/src/test/java/io/spine/code/proto/OneofDeclarationTest.java @@ -18,13 +18,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.type; +package io.spine.code.proto; import com.google.common.testing.NullPointerTester; import com.google.protobuf.Descriptors; import com.google.protobuf.Empty; -import io.spine.code.proto.FieldName; import io.spine.test.type.Transmission; +import io.spine.type.MessageType; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -46,8 +46,6 @@ void nonNull() { @Test @DisplayName("obtain name") - @SuppressWarnings("DuplicateStringLiteralInspection") - // "type" is also used in generated code. void obtainName() { Descriptors.Descriptor declaringType = Transmission.getDescriptor(); Descriptors.OneofDescriptor protocolOneof = declaringType diff --git a/license-report.md b/license-report.md index 33d9ce7247..1e5d2392a5 100644 --- a/license-report.md +++ b/license-report.md @@ -330,7 +330,7 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:47 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 **Mon Apr 06 12:01:12 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). @@ -777,7 +777,7 @@ This report was generated on **Fri Apr 03 19:14:47 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:47 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 **Mon Apr 06 12:01:13 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). @@ -1170,7 +1170,7 @@ This report was generated on **Fri Apr 03 19:14:47 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:48 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 **Mon Apr 06 12:01:14 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). @@ -1537,7 +1537,7 @@ This report was generated on **Fri Apr 03 19:14:48 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:49 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 **Mon Apr 06 12:01:14 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). @@ -1920,7 +1920,7 @@ This report was generated on **Fri Apr 03 19:14:49 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:49 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 **Mon Apr 06 12:01:15 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). @@ -2305,7 +2305,7 @@ This report was generated on **Fri Apr 03 19:14:49 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:50 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 **Mon Apr 06 12:01:15 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). @@ -2672,7 +2672,7 @@ This report was generated on **Fri Apr 03 19:14:50 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:50 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 **Mon Apr 06 12:01:16 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). @@ -3097,7 +3097,7 @@ This report was generated on **Fri Apr 03 19:14:50 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:51 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 **Mon Apr 06 12:01:16 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). @@ -3464,7 +3464,7 @@ This report was generated on **Fri Apr 03 19:14:51 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:51 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 **Mon Apr 06 12:01:17 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). @@ -3831,7 +3831,7 @@ This report was generated on **Fri Apr 03 19:14:51 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:52 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 **Mon Apr 06 12:01:17 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). @@ -4158,7 +4158,7 @@ This report was generated on **Fri Apr 03 19:14:52 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:52 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 **Mon Apr 06 12:01:18 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). @@ -4493,7 +4493,7 @@ This report was generated on **Fri Apr 03 19:14:52 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:53 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 **Mon Apr 06 12:01:18 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). @@ -4878,7 +4878,7 @@ This report was generated on **Fri Apr 03 19:14:53 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:53 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 **Mon Apr 06 12:01:18 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). @@ -5213,7 +5213,7 @@ This report was generated on **Fri Apr 03 19:14:53 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:53 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 **Mon Apr 06 12:01:19 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). @@ -5548,4 +5548,4 @@ This report was generated on **Fri Apr 03 19:14:53 EEST 2020** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Fri Apr 03 19:14:54 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 **Mon Apr 06 12:01:19 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/tools/validation-generator/src/main/java/io/spine/tools/validate/MessageAccess.java b/tools/validation-generator/src/main/java/io/spine/tools/validate/MessageAccess.java index 0ab206f853..63144ac9b1 100644 --- a/tools/validation-generator/src/main/java/io/spine/tools/validate/MessageAccess.java +++ b/tools/validation-generator/src/main/java/io/spine/tools/validate/MessageAccess.java @@ -23,9 +23,9 @@ import com.google.protobuf.Message; import com.google.protobuf.ProtocolMessageEnum; import io.spine.code.proto.FieldDeclaration; +import io.spine.code.proto.OneofDeclaration; import io.spine.tools.validate.code.CodeExpression; import io.spine.tools.validate.code.Expression; -import io.spine.type.OneofDeclaration; import static com.google.common.base.Preconditions.checkNotNull; import static io.spine.tools.validate.FieldAccess.fieldOfMessage;