From 0f9f805788a16b48a21d8e5a158fc44575a92895 Mon Sep 17 00:00:00 2001 From: Julia Gustafsson Date: Mon, 10 Jul 2023 19:03:37 +0200 Subject: [PATCH 01/16] Bump version to 3.0.4-SNAPSHOT --- docs/antora.yml | 2 +- jpastreamer.analytics/pom.xml | 2 +- jpastreamer.announcer/pom.xml | 2 +- jpastreamer.appinfo/pom.xml | 2 +- jpastreamer.application/pom.xml | 2 +- jpastreamer.autoclose/pom.xml | 2 +- jpastreamer.builder/pom.xml | 2 +- jpastreamer.core/pom.xml | 2 +- jpastreamer.criteria/pom.xml | 2 +- jpastreamer.exception/pom.xml | 2 +- jpastreamer.field/pom.xml | 2 +- .../jpastreamer.fieldgenerator.component/pom.xml | 2 +- .../jpastreamer.fieldgenerator.standard/pom.xml | 2 +- .../jpastreamer.fieldgenerator.test.package/pom.xml | 2 +- .../jpastreamer.fieldgenerator.test/pom.xml | 2 +- jpastreamer.fieldgenerator/pom.xml | 2 +- jpastreamer.integration/cdi/jpastreamer.integration.cdi/pom.xml | 2 +- jpastreamer.integration/cdi/pom.xml | 2 +- jpastreamer.integration/pom.xml | 2 +- .../spring/jpastreamer.integration.spring.autoconfigure/pom.xml | 2 +- jpastreamer.integration/spring/pom.xml | 2 +- jpastreamer.interopoptimizer/pom.xml | 2 +- jpastreamer.javanine/pom.xml | 2 +- jpastreamer.merger/pom.xml | 2 +- jpastreamer.pipeline/pom.xml | 2 +- jpastreamer.projection/pom.xml | 2 +- jpastreamer.provider/jpastreamer.analytics.standard/pom.xml | 2 +- jpastreamer.provider/jpastreamer.appinfo.standard/pom.xml | 2 +- jpastreamer.provider/jpastreamer.application.standard/pom.xml | 2 +- jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml | 2 +- jpastreamer.provider/jpastreamer.builder.standard/pom.xml | 2 +- jpastreamer.provider/jpastreamer.criteria.standard/pom.xml | 2 +- .../jpastreamer.interopoptimizer.standard/pom.xml | 2 +- jpastreamer.provider/jpastreamer.merger.standard/pom.xml | 2 +- jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml | 2 +- jpastreamer.provider/jpastreamer.renderer.standard/pom.xml | 2 +- .../jpastreamer.streamconfiguration.standard/pom.xml | 2 +- .../jpastreamer.termopmodifier.standard/pom.xml | 2 +- .../jpastreamer.termopoptimizer.standard/pom.xml | 2 +- jpastreamer.provider/pom.xml | 2 +- jpastreamer.renderer/pom.xml | 2 +- jpastreamer.rootfactory/pom.xml | 2 +- jpastreamer.streamconfiguration/pom.xml | 2 +- jpastreamer.termopmodifier/pom.xml | 2 +- jpastreamer.termopoptimizer/pom.xml | 2 +- pom.xml | 2 +- 46 files changed, 46 insertions(+), 46 deletions(-) diff --git a/docs/antora.yml b/docs/antora.yml index f41f39be..b90e44cd 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -13,7 +13,7 @@ name: jpa-streamer title: JPAStreamer Docs -version: 3.0.3 +version: 3.0.4-SNAPSHOT start_page: introduction:introduction.adoc nav: - modules/ROOT/nav.adoc diff --git a/jpastreamer.analytics/pom.xml b/jpastreamer.analytics/pom.xml index 67277e4f..0417e2b5 100644 --- a/jpastreamer.analytics/pom.xml +++ b/jpastreamer.analytics/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.announcer/pom.xml b/jpastreamer.announcer/pom.xml index 567485c2..dd537f3d 100644 --- a/jpastreamer.announcer/pom.xml +++ b/jpastreamer.announcer/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.appinfo/pom.xml b/jpastreamer.appinfo/pom.xml index 553a57a7..8576cd2b 100644 --- a/jpastreamer.appinfo/pom.xml +++ b/jpastreamer.appinfo/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.application/pom.xml b/jpastreamer.application/pom.xml index 2ee1004d..dff5c4db 100644 --- a/jpastreamer.application/pom.xml +++ b/jpastreamer.application/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.autoclose/pom.xml b/jpastreamer.autoclose/pom.xml index 910f28c7..d1ff6c4e 100644 --- a/jpastreamer.autoclose/pom.xml +++ b/jpastreamer.autoclose/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.builder/pom.xml b/jpastreamer.builder/pom.xml index 7dc3dd64..34e649df 100644 --- a/jpastreamer.builder/pom.xml +++ b/jpastreamer.builder/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.core/pom.xml b/jpastreamer.core/pom.xml index a7399441..aa2f338c 100644 --- a/jpastreamer.core/pom.xml +++ b/jpastreamer.core/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.criteria/pom.xml b/jpastreamer.criteria/pom.xml index bf591207..a0f01bd6 100644 --- a/jpastreamer.criteria/pom.xml +++ b/jpastreamer.criteria/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.exception/pom.xml b/jpastreamer.exception/pom.xml index 8c27319b..40e684ce 100644 --- a/jpastreamer.exception/pom.xml +++ b/jpastreamer.exception/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.field/pom.xml b/jpastreamer.field/pom.xml index 3bbf4bf4..40f13c47 100644 --- a/jpastreamer.field/pom.xml +++ b/jpastreamer.field/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.component/pom.xml b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.component/pom.xml index 42d5113a..805ee1e7 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.component/pom.xml +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.component/pom.xml @@ -19,7 +19,7 @@ fieldgenerator com.speedment.jpastreamer - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/pom.xml b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/pom.xml index 52459e0f..cb53da81 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/pom.xml +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/pom.xml @@ -19,7 +19,7 @@ fieldgenerator com.speedment.jpastreamer - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test.package/pom.xml b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test.package/pom.xml index 73a44f7a..8dcc7b5c 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test.package/pom.xml +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test.package/pom.xml @@ -19,7 +19,7 @@ fieldgenerator com.speedment.jpastreamer - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/pom.xml b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/pom.xml index 427768d1..f4a43eff 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/pom.xml +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/pom.xml @@ -19,7 +19,7 @@ fieldgenerator com.speedment.jpastreamer - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.fieldgenerator/pom.xml b/jpastreamer.fieldgenerator/pom.xml index 4bcb100f..bc1c7e78 100644 --- a/jpastreamer.fieldgenerator/pom.xml +++ b/jpastreamer.fieldgenerator/pom.xml @@ -19,7 +19,7 @@ jpastreamer-parent com.speedment.jpastreamer - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.integration/cdi/jpastreamer.integration.cdi/pom.xml b/jpastreamer.integration/cdi/jpastreamer.integration.cdi/pom.xml index f31857a4..3a9a31c9 100644 --- a/jpastreamer.integration/cdi/jpastreamer.integration.cdi/pom.xml +++ b/jpastreamer.integration/cdi/jpastreamer.integration.cdi/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer.integration.cdi cdi-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.integration/cdi/pom.xml b/jpastreamer.integration/cdi/pom.xml index ee3f044f..6d215ec3 100644 --- a/jpastreamer.integration/cdi/pom.xml +++ b/jpastreamer.integration/cdi/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer.integration integration-parent - 3.0.3 + 3.0.4-SNAPSHOT diff --git a/jpastreamer.integration/pom.xml b/jpastreamer.integration/pom.xml index 5ef42c30..8ddd89d6 100644 --- a/jpastreamer.integration/pom.xml +++ b/jpastreamer.integration/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.integration/spring/jpastreamer.integration.spring.autoconfigure/pom.xml b/jpastreamer.integration/spring/jpastreamer.integration.spring.autoconfigure/pom.xml index acd104dd..ae436aa7 100644 --- a/jpastreamer.integration/spring/jpastreamer.integration.spring.autoconfigure/pom.xml +++ b/jpastreamer.integration/spring/jpastreamer.integration.spring.autoconfigure/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer.integration.spring spring-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.integration/spring/pom.xml b/jpastreamer.integration/spring/pom.xml index 969106ac..16b40984 100644 --- a/jpastreamer.integration/spring/pom.xml +++ b/jpastreamer.integration/spring/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer.integration integration-parent - 3.0.3 + 3.0.4-SNAPSHOT diff --git a/jpastreamer.interopoptimizer/pom.xml b/jpastreamer.interopoptimizer/pom.xml index 11ea7ebd..5f0d8c33 100644 --- a/jpastreamer.interopoptimizer/pom.xml +++ b/jpastreamer.interopoptimizer/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.javanine/pom.xml b/jpastreamer.javanine/pom.xml index 42abcabd..bf29099b 100644 --- a/jpastreamer.javanine/pom.xml +++ b/jpastreamer.javanine/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.merger/pom.xml b/jpastreamer.merger/pom.xml index f44e0447..afbabbca 100644 --- a/jpastreamer.merger/pom.xml +++ b/jpastreamer.merger/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.pipeline/pom.xml b/jpastreamer.pipeline/pom.xml index 0270a011..84470356 100644 --- a/jpastreamer.pipeline/pom.xml +++ b/jpastreamer.pipeline/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.projection/pom.xml b/jpastreamer.projection/pom.xml index f528b226..244f540f 100644 --- a/jpastreamer.projection/pom.xml +++ b/jpastreamer.projection/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/jpastreamer.analytics.standard/pom.xml b/jpastreamer.provider/jpastreamer.analytics.standard/pom.xml index cada4dd3..ce7dd840 100644 --- a/jpastreamer.provider/jpastreamer.analytics.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.analytics.standard/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer provider - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/jpastreamer.appinfo.standard/pom.xml b/jpastreamer.provider/jpastreamer.appinfo.standard/pom.xml index ee5923e6..59ab1a00 100644 --- a/jpastreamer.provider/jpastreamer.appinfo.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.appinfo.standard/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer provider - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/jpastreamer.application.standard/pom.xml b/jpastreamer.provider/jpastreamer.application.standard/pom.xml index 2bc4d401..55ae9bbe 100644 --- a/jpastreamer.provider/jpastreamer.application.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.application.standard/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer provider - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml b/jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml index 318405c5..950844ce 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer provider - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/jpastreamer.builder.standard/pom.xml b/jpastreamer.provider/jpastreamer.builder.standard/pom.xml index 3411bfa6..9c825b48 100644 --- a/jpastreamer.provider/jpastreamer.builder.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.builder.standard/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer provider - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/jpastreamer.criteria.standard/pom.xml b/jpastreamer.provider/jpastreamer.criteria.standard/pom.xml index 8c4feb60..aba99ba1 100644 --- a/jpastreamer.provider/jpastreamer.criteria.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.criteria.standard/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer provider - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/jpastreamer.interopoptimizer.standard/pom.xml b/jpastreamer.provider/jpastreamer.interopoptimizer.standard/pom.xml index 8aeafc93..596ce5e9 100644 --- a/jpastreamer.provider/jpastreamer.interopoptimizer.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.interopoptimizer.standard/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer provider - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/jpastreamer.merger.standard/pom.xml b/jpastreamer.provider/jpastreamer.merger.standard/pom.xml index 9cf8ddac..efb23a96 100644 --- a/jpastreamer.provider/jpastreamer.merger.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.merger.standard/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer provider - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml b/jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml index a7642482..193e491c 100644 --- a/jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer provider - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/jpastreamer.renderer.standard/pom.xml b/jpastreamer.provider/jpastreamer.renderer.standard/pom.xml index e93839da..57ba85d5 100644 --- a/jpastreamer.provider/jpastreamer.renderer.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.renderer.standard/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer provider - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/jpastreamer.streamconfiguration.standard/pom.xml b/jpastreamer.provider/jpastreamer.streamconfiguration.standard/pom.xml index e69a9e6c..a34ac183 100644 --- a/jpastreamer.provider/jpastreamer.streamconfiguration.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.streamconfiguration.standard/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer provider - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/jpastreamer.termopmodifier.standard/pom.xml b/jpastreamer.provider/jpastreamer.termopmodifier.standard/pom.xml index 5cb5565f..13600437 100644 --- a/jpastreamer.provider/jpastreamer.termopmodifier.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.termopmodifier.standard/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer provider - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/jpastreamer.termopoptimizer.standard/pom.xml b/jpastreamer.provider/jpastreamer.termopoptimizer.standard/pom.xml index 1b857f20..d3e32f8e 100644 --- a/jpastreamer.provider/jpastreamer.termopoptimizer.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.termopoptimizer.standard/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer provider - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.provider/pom.xml b/jpastreamer.provider/pom.xml index 9cfcb670..a42bd6e0 100644 --- a/jpastreamer.provider/pom.xml +++ b/jpastreamer.provider/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.renderer/pom.xml b/jpastreamer.renderer/pom.xml index 2e0d426b..b60514ec 100644 --- a/jpastreamer.renderer/pom.xml +++ b/jpastreamer.renderer/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.rootfactory/pom.xml b/jpastreamer.rootfactory/pom.xml index ba7e42a1..28e87de1 100644 --- a/jpastreamer.rootfactory/pom.xml +++ b/jpastreamer.rootfactory/pom.xml @@ -19,7 +19,7 @@ jpastreamer-parent com.speedment.jpastreamer - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.streamconfiguration/pom.xml b/jpastreamer.streamconfiguration/pom.xml index d7700928..434fa2e3 100644 --- a/jpastreamer.streamconfiguration/pom.xml +++ b/jpastreamer.streamconfiguration/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.termopmodifier/pom.xml b/jpastreamer.termopmodifier/pom.xml index 34e65c4d..d9164fc4 100644 --- a/jpastreamer.termopmodifier/pom.xml +++ b/jpastreamer.termopmodifier/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/jpastreamer.termopoptimizer/pom.xml b/jpastreamer.termopoptimizer/pom.xml index b5ceacd1..d335b715 100644 --- a/jpastreamer.termopoptimizer/pom.xml +++ b/jpastreamer.termopoptimizer/pom.xml @@ -19,7 +19,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT 4.0.0 diff --git a/pom.xml b/pom.xml index 75011470..64434a75 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ com.speedment.jpastreamer jpastreamer-parent - 3.0.3 + 3.0.4-SNAPSHOT pom From 17c289f8eae5d614a744aecd60b27e31ba50e183 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Jul 2023 05:56:00 +0000 Subject: [PATCH 02/16] Bump maven-enforcer-plugin from 3.1.0 to 3.3.0 Bumps [maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.1.0 to 3.3.0. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.1.0...enforcer-3.3.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 64434a75..d73b1dde 100644 --- a/pom.xml +++ b/pom.xml @@ -428,7 +428,7 @@ maven-enforcer-plugin - 3.1.0 + 3.3.0 enforce From f48e16436e5566256f5897bf329eff78cdef78a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Jul 2023 05:56:04 +0000 Subject: [PATCH 03/16] Bump maven-surefire-plugin from 2.22.2 to 3.1.2 Bumps [maven-surefire-plugin](https://github.com/apache/maven-surefire) from 2.22.2 to 3.1.2. - [Release notes](https://github.com/apache/maven-surefire/releases) - [Commits](https://github.com/apache/maven-surefire/compare/surefire-2.22.2...surefire-3.1.2) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-surefire-plugin dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .../jpastreamer.fieldgenerator.standard/pom.xml | 2 +- jpastreamer.projection/pom.xml | 2 +- jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml | 2 +- jpastreamer.provider/jpastreamer.builder.standard/pom.xml | 2 +- jpastreamer.provider/jpastreamer.criteria.standard/pom.xml | 2 +- .../jpastreamer.interopoptimizer.standard/pom.xml | 2 +- jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml | 2 +- .../jpastreamer.streamconfiguration.standard/pom.xml | 2 +- .../jpastreamer.termopmodifier.standard/pom.xml | 2 +- .../jpastreamer.termopoptimizer.standard/pom.xml | 2 +- pom.xml | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/pom.xml b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/pom.xml index cb53da81..165e2c18 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/pom.xml +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/pom.xml @@ -103,7 +103,7 @@ maven-surefire-plugin - 2.22.2 + 3.1.2 --add-opens jpastreamer.fieldgenerator.standard/com.speedment.jpastreamer.fieldgenerator=ALL-UNNAMED diff --git a/jpastreamer.projection/pom.xml b/jpastreamer.projection/pom.xml index 244f540f..532559e4 100644 --- a/jpastreamer.projection/pom.xml +++ b/jpastreamer.projection/pom.xml @@ -48,7 +48,7 @@ maven-surefire-plugin - 2.22.2 + 3.1.2 --add-opens jpastreamer.projection/com.speedment.jpastreamer.projection=ALL-UNNAMED diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml b/jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml index 950844ce..c66e03f5 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml @@ -49,7 +49,7 @@ maven-surefire-plugin - 2.22.2 + 3.1.2 --add-opens jpastreamer.autoclose.standard/com.speedment.jpastreamer.autoclose.standard=ALL-UNNAMED diff --git a/jpastreamer.provider/jpastreamer.builder.standard/pom.xml b/jpastreamer.provider/jpastreamer.builder.standard/pom.xml index 9c825b48..23dbc3be 100644 --- a/jpastreamer.provider/jpastreamer.builder.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.builder.standard/pom.xml @@ -86,7 +86,7 @@ maven-surefire-plugin - 2.22.2 + 3.1.2 --add-opens jpastreamer.builder.standard/com.speedment.jpastreamer.builder.standard=ALL-UNNAMED diff --git a/jpastreamer.provider/jpastreamer.criteria.standard/pom.xml b/jpastreamer.provider/jpastreamer.criteria.standard/pom.xml index aba99ba1..fe1eadb9 100644 --- a/jpastreamer.provider/jpastreamer.criteria.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.criteria.standard/pom.xml @@ -57,7 +57,7 @@ maven-surefire-plugin - 2.22.2 + 3.1.2 --add-opens jpastreamer.criteria.standard/com.speedment.jpastreamer.criteria.standard=ALL-UNNAMED diff --git a/jpastreamer.provider/jpastreamer.interopoptimizer.standard/pom.xml b/jpastreamer.provider/jpastreamer.interopoptimizer.standard/pom.xml index 596ce5e9..62d459b2 100644 --- a/jpastreamer.provider/jpastreamer.interopoptimizer.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.interopoptimizer.standard/pom.xml @@ -65,7 +65,7 @@ maven-surefire-plugin - 2.22.2 + 3.1.2 --add-opens jpastreamer.interopoptimizer.standard/com.speedment.jpastreamer.interopoptimizer.standard=ALL-UNNAMED diff --git a/jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml b/jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml index 193e491c..4d6e359b 100644 --- a/jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml @@ -49,7 +49,7 @@ maven-surefire-plugin - 2.22.2 + 3.1.2 --add-opens jpastreamer.pipeline.standard/com.speedment.jpastreamer.pipeline.standard=ALL-UNNAMED diff --git a/jpastreamer.provider/jpastreamer.streamconfiguration.standard/pom.xml b/jpastreamer.provider/jpastreamer.streamconfiguration.standard/pom.xml index a34ac183..26103b03 100644 --- a/jpastreamer.provider/jpastreamer.streamconfiguration.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.streamconfiguration.standard/pom.xml @@ -44,7 +44,7 @@ maven-surefire-plugin - 2.22.2 + 3.1.2 --add-opens jpastreamer.streamconfiguration.standard/com.speedment.jpastreamer.streamconfiguration.standard=ALL-UNNAMED diff --git a/jpastreamer.provider/jpastreamer.termopmodifier.standard/pom.xml b/jpastreamer.provider/jpastreamer.termopmodifier.standard/pom.xml index 13600437..c1b2f5ad 100644 --- a/jpastreamer.provider/jpastreamer.termopmodifier.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.termopmodifier.standard/pom.xml @@ -64,7 +64,7 @@ maven-surefire-plugin - 2.22.2 + 3.1.2 --add-opens jpastreamer.termopmodifier.standard/com.speedment.jpastreamer.termopmodifier.standard=ALL-UNNAMED diff --git a/jpastreamer.provider/jpastreamer.termopoptimizer.standard/pom.xml b/jpastreamer.provider/jpastreamer.termopoptimizer.standard/pom.xml index d3e32f8e..a1cbe07b 100644 --- a/jpastreamer.provider/jpastreamer.termopoptimizer.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.termopoptimizer.standard/pom.xml @@ -68,7 +68,7 @@ maven-surefire-plugin - 2.22.2 + 3.1.2 --add-opens jpastreamer.termopoptimizer.standard/com.speedment.jpastreamer.termopoptimizer.standard=ALL-UNNAMED diff --git a/pom.xml b/pom.xml index 64434a75..9ed083e3 100644 --- a/pom.xml +++ b/pom.xml @@ -173,7 +173,7 @@ maven-surefire-plugin - 2.22.2 + 3.1.2 false From acc6277736fdf5d4fa4b701dfaf35c35eb0cc3ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Jul 2023 05:34:45 +0000 Subject: [PATCH 04/16] Bump maven-clean-plugin from 3.2.0 to 3.3.1 Bumps [maven-clean-plugin](https://github.com/apache/maven-clean-plugin) from 3.2.0 to 3.3.1. - [Release notes](https://github.com/apache/maven-clean-plugin/releases) - [Commits](https://github.com/apache/maven-clean-plugin/compare/maven-clean-plugin-3.2.0...maven-clean-plugin-3.3.1) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-clean-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 796d0cf5..700765f7 100644 --- a/pom.xml +++ b/pom.xml @@ -198,7 +198,7 @@ maven-clean-plugin - 3.2.0 + 3.3.1 From 6b67a23457ed9d5a5d9cfe910e279c9c48a48080 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Jul 2023 05:15:36 +0000 Subject: [PATCH 05/16] Bump org.springframework.boot:spring-boot-autoconfigure Bumps [org.springframework.boot:spring-boot-autoconfigure](https://github.com/spring-projects/spring-boot) from 2.7.1 to 3.1.2. - [Release notes](https://github.com/spring-projects/spring-boot/releases) - [Commits](https://github.com/spring-projects/spring-boot/compare/v2.7.1...v3.1.2) --- updated-dependencies: - dependency-name: org.springframework.boot:spring-boot-autoconfigure dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- jpastreamer.integration/spring/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jpastreamer.integration/spring/pom.xml b/jpastreamer.integration/spring/pom.xml index 16b40984..e8e86f27 100644 --- a/jpastreamer.integration/spring/pom.xml +++ b/jpastreamer.integration/spring/pom.xml @@ -23,7 +23,7 @@ - 2.7.1 + 3.1.2 4.0.0 From 10dd4ce1079dcf3f36ae8be311953d9170385af8 Mon Sep 17 00:00:00 2001 From: Julia Gustafsson Date: Fri, 11 Aug 2023 12:34:26 +0200 Subject: [PATCH 06/16] Revert Spring Boot update --- jpastreamer.integration/spring/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jpastreamer.integration/spring/pom.xml b/jpastreamer.integration/spring/pom.xml index e8e86f27..16b40984 100644 --- a/jpastreamer.integration/spring/pom.xml +++ b/jpastreamer.integration/spring/pom.xml @@ -23,7 +23,7 @@ - 3.1.2 + 2.7.1 4.0.0 From babcabff3fcbb94079cf04a208cb71474339eaa0 Mon Sep 17 00:00:00 2001 From: Julia Gustafsson Date: Fri, 11 Aug 2023 12:49:39 +0200 Subject: [PATCH 07/16] Remove module jpastreamer.analytics, fix #107 --- DISCLAIMER.md | 12 -- README.adoc | 3 - .../introduction/pages/introduction.adoc | 3 - jpastreamer.analytics/pom.xml | 33 ---- .../analytics/AnalyticsReporter.java | 29 ---- .../analytics/AnalyticsReporterFactory.java | 19 -- .../src/main/java/module-info.java | 15 -- .../jpastreamer.analytics.standard/pom.xml | 48 ----- .../StandardAnalyticsReporterFactory.java | 26 --- .../analytics/standard/internal/Handler.java | 23 --- .../InternalStandardAnalyticsReporter.java | 74 -------- .../standard/internal/google/EventType.java | 39 ----- .../google/GoogleAnalyticsHandler.java | 164 ------------------ .../standard/internal/google/HttpUtil.java | 105 ----------- .../google/InternalAnalyticsException.java | 21 --- .../standard/internal/google/JsonUtil.java | 50 ------ .../src/main/java/module-info.java | 21 --- ...treamer.analytics.AnalyticsReporterFactory | 1 - .../internal/StandardJPAStreamer.java | 7 - .../src/main/java/module-info.java | 3 - jpastreamer.provider/pom.xml | 1 - pom.xml | 1 - 22 files changed, 698 deletions(-) delete mode 100644 DISCLAIMER.md delete mode 100644 jpastreamer.analytics/pom.xml delete mode 100644 jpastreamer.analytics/src/main/java/com/speedment/jpastreamer/analytics/AnalyticsReporter.java delete mode 100644 jpastreamer.analytics/src/main/java/com/speedment/jpastreamer/analytics/AnalyticsReporterFactory.java delete mode 100644 jpastreamer.analytics/src/main/java/module-info.java delete mode 100644 jpastreamer.provider/jpastreamer.analytics.standard/pom.xml delete mode 100644 jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/StandardAnalyticsReporterFactory.java delete mode 100644 jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/Handler.java delete mode 100644 jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/InternalStandardAnalyticsReporter.java delete mode 100644 jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/EventType.java delete mode 100644 jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/GoogleAnalyticsHandler.java delete mode 100644 jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/HttpUtil.java delete mode 100644 jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/InternalAnalyticsException.java delete mode 100644 jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/JsonUtil.java delete mode 100644 jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/module-info.java delete mode 100644 jpastreamer.provider/jpastreamer.analytics.standard/src/main/resources/META-INF/services/com.speedment.jpastreamer.analytics.AnalyticsReporterFactory diff --git a/DISCLAIMER.md b/DISCLAIMER.md deleted file mode 100644 index cd47da01..00000000 --- a/DISCLAIMER.md +++ /dev/null @@ -1,12 +0,0 @@ -## Data -This product uses Google Analytics, a web analytics service provided by Google, Inc. ("Google"). - -This product stores a small file with a random client id in the user's home directory. Because it is random, it does not contain any personal information. - -## Consent -By using this product, you consent to the processing of data about you by Google and Speedment in the manner and for the purposes set out above. - -If you do not consent you can do either of the following: - -A) you should not use the product OR -B) you can contact info@jpastreamer.org to have this feature removed diff --git a/README.adoc b/README.adoc index 09fb9a1b..a7f6f9c2 100644 --- a/README.adoc +++ b/README.adoc @@ -167,9 +167,6 @@ We gladly welcome any form of contributions, whether it is comments and question Before we can accept your patches we need to establish a common legal ground to protect your rights to your contributions and the users of JPAstreamer. This is done by signing a Contributor License Agreement (link:https://github.com/speedment/jpa-streamer/blob/master/CONTRIBUTOR_LICENSE_AGREEMENT[CLA]) with Speedment, Inc. The details of this process is laid out link:https://github.com/speedment/jpa-streamer/blob/master/CONTRIBUTING.md[here]. -== Phone Home -JPAstreamer sends certain data back to servers as described link:https://github.com/speedment/jpa-streamer/blob/master/DISCLAIMER.md[here]. If you wish to disable this feature, please contact us at info@jpastreamer.org. - == License JPAstreamer is released under the link:https://github.com/speedment/jpa-streamer/blob/master/LICENSE[LGPL 2.1 License]. diff --git a/docs/modules/introduction/pages/introduction.adoc b/docs/modules/introduction/pages/introduction.adoc index 0cfe6cdf..aa9a2f4e 100644 --- a/docs/modules/introduction/pages/introduction.adoc +++ b/docs/modules/introduction/pages/introduction.adoc @@ -95,6 +95,3 @@ If you wish to learn more about the Java Stream API, start with the chapter xref - Website - https://www.jpastreamer.org - GitHub - https://github.com/speedment/jpa-streamer -== Phone Home -JPAstreamer sends certain anonymous usage data to Google Analytics as described link:https://github.com/speedment/jpa-streamer/blob/master/DISCLAIMER.md[here]. If you wish to disable this feature, please contact us at info@jpastreamer.org. - diff --git a/jpastreamer.analytics/pom.xml b/jpastreamer.analytics/pom.xml deleted file mode 100644 index 0417e2b5..00000000 --- a/jpastreamer.analytics/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - com.speedment.jpastreamer - jpastreamer-parent - 3.0.4-SNAPSHOT - - 4.0.0 - - analytics - - Analytics - - Analytics module - - - diff --git a/jpastreamer.analytics/src/main/java/com/speedment/jpastreamer/analytics/AnalyticsReporter.java b/jpastreamer.analytics/src/main/java/com/speedment/jpastreamer/analytics/AnalyticsReporter.java deleted file mode 100644 index 98dc0d88..00000000 --- a/jpastreamer.analytics/src/main/java/com/speedment/jpastreamer/analytics/AnalyticsReporter.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.analytics; - -public interface AnalyticsReporter { - - /** - * Starts analytics reporting. - * - */ - void start(); - - /** - * Stops analytics reporting and releases - * potential resources held by the component. - */ - void stop(); - -} diff --git a/jpastreamer.analytics/src/main/java/com/speedment/jpastreamer/analytics/AnalyticsReporterFactory.java b/jpastreamer.analytics/src/main/java/com/speedment/jpastreamer/analytics/AnalyticsReporterFactory.java deleted file mode 100644 index c0c68c66..00000000 --- a/jpastreamer.analytics/src/main/java/com/speedment/jpastreamer/analytics/AnalyticsReporterFactory.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.analytics; - -public interface AnalyticsReporterFactory { - - AnalyticsReporter createAnalyticsReporter(String version, boolean demoMode); - -} diff --git a/jpastreamer.analytics/src/main/java/module-info.java b/jpastreamer.analytics/src/main/java/module-info.java deleted file mode 100644 index 66c66c6b..00000000 --- a/jpastreamer.analytics/src/main/java/module-info.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -module jpastreamer.analytics { - exports com.speedment.jpastreamer.analytics; -} diff --git a/jpastreamer.provider/jpastreamer.analytics.standard/pom.xml b/jpastreamer.provider/jpastreamer.analytics.standard/pom.xml deleted file mode 100644 index ce7dd840..00000000 --- a/jpastreamer.provider/jpastreamer.analytics.standard/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - com.speedment.jpastreamer - provider - 3.0.4-SNAPSHOT - - 4.0.0 - - analytics-standard - - Analytics - Standard - - Standard provider of the Analytics module - - - - - - com.speedment.jpastreamer - analytics - - - - com.speedment.common - rest - ${speedment-version} - - - - - diff --git a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/StandardAnalyticsReporterFactory.java b/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/StandardAnalyticsReporterFactory.java deleted file mode 100644 index 16b90379..00000000 --- a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/StandardAnalyticsReporterFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.analytics.standard; - -import com.speedment.jpastreamer.analytics.AnalyticsReporter; -import com.speedment.jpastreamer.analytics.AnalyticsReporterFactory; -import com.speedment.jpastreamer.analytics.standard.internal.google.GoogleAnalyticsHandler; -import com.speedment.jpastreamer.analytics.standard.internal.InternalStandardAnalyticsReporter; - -public final class StandardAnalyticsReporterFactory implements AnalyticsReporterFactory { - - @Override - public AnalyticsReporter createAnalyticsReporter(final String version, final boolean demoMode) { - return new InternalStandardAnalyticsReporter(new GoogleAnalyticsHandler(version, demoMode)); - } -} diff --git a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/Handler.java b/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/Handler.java deleted file mode 100644 index 8db671c2..00000000 --- a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/Handler.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.analytics.standard.internal; - -public interface Handler { - - void starting(); - - void running(); - - void stopping(); - -} diff --git a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/InternalStandardAnalyticsReporter.java b/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/InternalStandardAnalyticsReporter.java deleted file mode 100644 index 377c23c3..00000000 --- a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/InternalStandardAnalyticsReporter.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.analytics.standard.internal; - -import com.speedment.jpastreamer.analytics.AnalyticsReporter; - -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -import static java.util.Objects.requireNonNull; - -public final class InternalStandardAnalyticsReporter implements AnalyticsReporter { - - private static final long ALIVE_INTERVAL_MS = TimeUnit.MINUTES.toMillis(20); - private static final AtomicInteger THREAD_COUNT = new AtomicInteger(); - - private final ScheduledExecutorService executorService; - private final AtomicBoolean started; - private final AtomicBoolean stopped; - private final Handler handler; - - public InternalStandardAnalyticsReporter(final Handler handler) { - this.handler = requireNonNull(handler); - executorService = Executors.newScheduledThreadPool(1, this::threadFactory); - started = new AtomicBoolean(); - stopped = new AtomicBoolean(); - } - - @Override - public void start() { - if (!stopped.get() && started.compareAndSet(false, true)) { - executorService.schedule(handler::starting, 1, TimeUnit.MILLISECONDS); - executorService.scheduleAtFixedRate(handler::running, ALIVE_INTERVAL_MS, ALIVE_INTERVAL_MS, TimeUnit.MILLISECONDS); - } - } - - @Override - public void stop() { - if (started.get() && stopped.compareAndSet(false, true)) { - executorService.execute(handler::stopping); - try { - Thread.sleep(10); - executorService.shutdown(); - if (!executorService.awaitTermination(1, TimeUnit.SECONDS)) { - System.out.println("Warning: Unable to shutdown analytics reporter."); - } - } catch (InterruptedException ignore) { - // Todo: re-interrupt or re-throw - } - executorService.shutdownNow(); - } - } - - private Thread threadFactory(final Runnable runnable) { - requireNonNull(runnable); - final Thread thread = new Thread(runnable, InternalStandardAnalyticsReporter.class.getSimpleName() + "-" + THREAD_COUNT.getAndIncrement()); - thread.setDaemon(true); - return thread; - } - -} diff --git a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/EventType.java b/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/EventType.java deleted file mode 100644 index d7a671c0..00000000 --- a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/EventType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.analytics.standard.internal.google; - -import java.util.Optional; - -enum EventType { - - STARTED("started", "start"), - ALIVE("alive", null), - STOPPED("stopped", "end"); - - private final String eventName; - private final String sessionControl; - - EventType(String eventName, String sessionControl) { - this.eventName = eventName; - this.sessionControl = sessionControl; - } - - String eventName() { - return eventName; - } - - Optional sessionControl() { - return Optional.ofNullable(sessionControl); - } - -} diff --git a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/GoogleAnalyticsHandler.java b/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/GoogleAnalyticsHandler.java deleted file mode 100644 index 20ab14f2..00000000 --- a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/GoogleAnalyticsHandler.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.analytics.standard.internal.google; - -import com.speedment.common.rest.Rest; -import com.speedment.jpastreamer.analytics.standard.internal.Handler; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.security.SecureRandom; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Stream; - -import static com.speedment.jpastreamer.analytics.standard.internal.google.HttpUtil.urlEncode; -import static com.speedment.jpastreamer.analytics.standard.internal.google.JsonUtil.asElement; -import static com.speedment.jpastreamer.analytics.standard.internal.google.JsonUtil.jsonElement; -import static java.util.Objects.requireNonNull; -import static java.util.stream.Collectors.joining; - -public final class GoogleAnalyticsHandler implements Handler { - - private static final String COOKIE_FILE_NAME = "JPAstreamer.clientid"; - private static final String URL_STRING = "https://www.google-analytics.com/mp/collect"; - private static final String MEASUREMENT_ID = "G-LNCF0RTS4N"; // JPAStreamer App Measurement ID - private static final String API_SECRET = "J-EHimWhT8anCwaHfq-h-Q"; - - private final String version; - private final boolean demoMode; - private final String clientId; - private final Random random; - private final Rest analytics; - - public GoogleAnalyticsHandler(final String version, boolean demoMode) { - this.version = requireNonNull(version); - this.demoMode = demoMode; - clientId = acquireClientId(); - random = new SecureRandom(); - analytics = Rest.connectHttps(URL_STRING); - } - - @Override - public void starting() { - report(EventType.STARTED); - } - - @Override - public void running() { - report(EventType.ALIVE); - } - - @Override - public void stopping() { - report(EventType.STOPPED); - } - - private void report(final EventType eventType) { - requireNonNull(eventType); - - final String eventName = eventType.eventName() + (demoMode ? "-demo" : ""); - final Map eventParameters = new HashMap<>(); - final Map userProperties = new HashMap<>(); - eventParameters.put("app_version", this.version); - - httpSend(eventName, eventParameters); - } - - void httpSend(String eventName, final Map eventParameters) { - requireNonNull(eventName); - requireNonNull(eventParameters); - final String url = URL_STRING + "?measurement_id=" + urlEncode(MEASUREMENT_ID) + "&api_secret=" + urlEncode(API_SECRET); - final String json = jsonFor(eventName, acquireClientId(), eventParameters); - HttpUtil.send(url, json); - } - - // This tries to read clientId from a "cookie" file in the - // user's home directory. If that fails, a new random clientId - // is generated and an attempt is made to save it in said file. - private String acquireClientId() { - final String userHome = System.getProperty("user.home"); - try { - final Path path = Paths.get(userHome, COOKIE_FILE_NAME); - try (Stream lines = Files.lines(path, StandardCharsets.UTF_8)) { - return lines - .findFirst() - .map(UUID::fromString) - .orElseThrow(NoSuchElementException::new) - .toString(); - } - } catch (Exception ignore) { - } - final String clientId = UUID.randomUUID().toString(); - try { - final Path path = Paths.get(userHome, COOKIE_FILE_NAME); - Files.write(path, clientId.getBytes(StandardCharsets.UTF_8)); - } catch (IOException ignore) { - } - return clientId; - } - - static String jsonFor(final String eventName, - final String clientId) { - requireNonNull(eventName); - requireNonNull(clientId); - return Stream.of( - "{", - jsonElement(" ", "clientId", clientId) + ',', - jsonElement(" ", "userId", clientId) + ',', - jsonElement(" ", "nonPersonalizedAds", true) + ',', - ' ' + asElement("events") + ": [{", - jsonElement(" ", "name", eventName) + ',', - " " + asElement("params") + ": {}", - " }],", - ' ' + asElement("userProperties") + ": {}", - "}" - ).collect(joining(JsonUtil.nl())); - } - - static String jsonFor(final String eventName, - final String clientId, - final Map eventParameters) { - requireNonNull(eventName); - requireNonNull(clientId); - requireNonNull(eventParameters); - return Stream.of( - "{", - jsonElement(" ", "clientId", clientId) + ',', - jsonElement(" ", "userId", clientId) + ',', - jsonElement(" ", "nonPersonalizedAds", true) + ',', - ' ' + asElement("events") + ": [{", - jsonElement(" ", "name", eventName) + ',', - " " + asElement("params") + ": {", - renderMap(eventParameters, e -> jsonElement(" ", e.getKey(), e.getValue())), - " }", - " }]", - "}" - ).collect(joining(JsonUtil.nl())); - } - static String userProperty(final Map.Entry userProperty) { - return String.format(" %s: {%n %s%n }", asElement(userProperty.getKey()), jsonElement(" ", "value", userProperty.getValue())); - } - - static String renderMap(final Map map, final Function, String> mapper) { - requireNonNull(map); - requireNonNull(mapper); - return map.entrySet().stream() - .map(mapper) - .collect(joining(String.format(",%n"))); - } - -} diff --git a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/HttpUtil.java b/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/HttpUtil.java deleted file mode 100644 index b3e66d88..00000000 --- a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/HttpUtil.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.analytics.standard.internal.google; - -import java.io.*; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; -import static java.util.Objects.requireNonNull; - -final class HttpUtil { - - private static final int DEFAULT_TIME_OUT_MS = 2_000; - - private static final String THREAD_NAME = "chronicle~analytics~http~client"; - private static final Executor EXECUTOR = Executors.newSingleThreadExecutor(runnable -> { - final Thread thread = new Thread(runnable, THREAD_NAME); - thread.setDaemon(true); - return thread; - }); - - private HttpUtil() { - } - - public static void send(final String urlString, - final String body) { - requireNonNull(urlString); - requireNonNull(body); - EXECUTOR.execute(new Sender(urlString, body)); - } - - static String urlEncode(final String s) { - requireNonNull(s); - try { - return URLEncoder.encode(s, StandardCharsets.UTF_8.toString()); - } catch (UnsupportedEncodingException e) { - System.err.println("Exception while URL encoding statistics for Google Analytics."); - e.printStackTrace(); - throw new InternalAnalyticsException("This should never happen as " + StandardCharsets.UTF_8 + " should always be present."); - } - } - - static final class Sender implements Runnable { - - private final String urlString; - private final String body; - - Sender(final String urlString, - final String body) { - requireNonNull(urlString); - requireNonNull(body); - this.urlString = urlString; - this.body = body; - } - - @Override - public void run() { - try { - final URL url = new URL(urlString); - final HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - // Do not linger if the connection is slow. Give up instead! - conn.setConnectTimeout(DEFAULT_TIME_OUT_MS); - conn.setReadTimeout(DEFAULT_TIME_OUT_MS); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "text/plain; charset=UTF-8"); - conn.setRequestProperty("t", "application/json"); - conn.setDoOutput(true); - try (OutputStream os = conn.getOutputStream()) { - final byte[] output = body.getBytes(StandardCharsets.UTF_8); - os.write(output, 0, output.length); - os.flush(); - } - - try (BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) { - final StringBuilder response = new StringBuilder(); - String sep = ""; - for (String responseLine; (responseLine = br.readLine()) != null; ) { - response.append(sep).append(responseLine); // preserve some white space - sep = " "; - } - final String logMsg = response.toString().replaceAll("\\s+(?=\\S)", " "); - if (!logMsg.isEmpty()) - System.out.println(logMsg); - } - - } catch (IOException ioe) { - System.err.println("Exception while sending usage statistics to Google Analytics."); - ioe.printStackTrace(); - } - } - } -} diff --git a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/InternalAnalyticsException.java b/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/InternalAnalyticsException.java deleted file mode 100644 index 402649a1..00000000 --- a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/InternalAnalyticsException.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.analytics.standard.internal.google; - -final class InternalAnalyticsException extends RuntimeException { - - InternalAnalyticsException(String message) { - super(message); - } - -} diff --git a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/JsonUtil.java b/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/JsonUtil.java deleted file mode 100644 index 6ea6bfc2..00000000 --- a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/com/speedment/jpastreamer/analytics/standard/internal/google/JsonUtil.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.analytics.standard.internal.google; - -final class JsonUtil { - - private static final String NL = String.format("%n"); - - private JsonUtil() { - } - - static String jsonElement(final String indent, - final String key, - final Object value) { - return indent + asElement(key) + ": " + asElement(value); - } - - static String asElement(final Object value) { - return value instanceof CharSequence - ? '"' + escape(value.toString()) + '"' - : value.toString(); - - } - - static String escape(final String raw) { - return raw - .replace("\\", "\\\\") - .replace("\"", "\\\"") - .replace("\b", "\\b") - .replace("\f", "\\f") - .replace("\n", "\\n") - .replace("\r", "\\r") - .replace("\t", "\\t"); - // Todo: escape other non-printing characters ... - } - - static String nl() { - return NL; - } -} diff --git a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/module-info.java b/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/module-info.java deleted file mode 100644 index f10a2897..00000000 --- a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/java/module-info.java +++ /dev/null @@ -1,21 +0,0 @@ -import com.speedment.jpastreamer.analytics.AnalyticsReporterFactory; -import com.speedment.jpastreamer.analytics.standard.StandardAnalyticsReporterFactory; - -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -module jpastreamer.analytics.standard { - requires transitive jpastreamer.analytics; - requires com.speedment.common.rest; - - provides AnalyticsReporterFactory with StandardAnalyticsReporterFactory; -} diff --git a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/resources/META-INF/services/com.speedment.jpastreamer.analytics.AnalyticsReporterFactory b/jpastreamer.provider/jpastreamer.analytics.standard/src/main/resources/META-INF/services/com.speedment.jpastreamer.analytics.AnalyticsReporterFactory deleted file mode 100644 index e1c428cc..00000000 --- a/jpastreamer.provider/jpastreamer.analytics.standard/src/main/resources/META-INF/services/com.speedment.jpastreamer.analytics.AnalyticsReporterFactory +++ /dev/null @@ -1 +0,0 @@ -com.speedment.jpastreamer.analytics.standard.StandardAnalyticsReporterFactory diff --git a/jpastreamer.provider/jpastreamer.application.standard/src/main/java/com/speedment/jpastreamer/application/standard/internal/StandardJPAStreamer.java b/jpastreamer.provider/jpastreamer.application.standard/src/main/java/com/speedment/jpastreamer/application/standard/internal/StandardJPAStreamer.java index b4ed30b6..10f20d83 100644 --- a/jpastreamer.provider/jpastreamer.application.standard/src/main/java/com/speedment/jpastreamer/application/standard/internal/StandardJPAStreamer.java +++ b/jpastreamer.provider/jpastreamer.application.standard/src/main/java/com/speedment/jpastreamer/application/standard/internal/StandardJPAStreamer.java @@ -14,8 +14,6 @@ import static java.util.Objects.requireNonNull; -import com.speedment.jpastreamer.analytics.AnalyticsReporter; -import com.speedment.jpastreamer.analytics.AnalyticsReporterFactory; import com.speedment.jpastreamer.announcer.Announcer; import com.speedment.jpastreamer.appinfo.ApplicationInformation; import com.speedment.jpastreamer.application.JPAStreamer; @@ -33,7 +31,6 @@ final class StandardJPAStreamer implements JPAStreamer { private final Supplier entityManagerSupplier; private final Runnable closeHandler; - private final AnalyticsReporter analyticsReporter; private final boolean closeEntityManagers; @@ -42,9 +39,6 @@ final class StandardJPAStreamer implements JPAStreamer { this.entityManagerSupplier = requireNonNull(entityManagerSupplier); this.closeEntityManagers = closeEntityManagers; final ApplicationInformation applicationInformation = RootFactory.getOrThrow(ApplicationInformation.class, ServiceLoader::load); - final AnalyticsReporterFactory analyticsReporterFactory = RootFactory.getOrThrow(AnalyticsReporterFactory.class, ServiceLoader::load); - analyticsReporter = analyticsReporterFactory.createAnalyticsReporter(applicationInformation.implementationVersion(), demoMode); - analyticsReporter.start(); printGreeting(applicationInformation); } @@ -70,7 +64,6 @@ public void resetStreamer(Class... entityClasses) { @Override public void close() { - analyticsReporter.stop(); closeHandler.run(); } diff --git a/jpastreamer.provider/jpastreamer.application.standard/src/main/java/module-info.java b/jpastreamer.provider/jpastreamer.application.standard/src/main/java/module-info.java index b2c626a2..36b40490 100644 --- a/jpastreamer.provider/jpastreamer.application.standard/src/main/java/module-info.java +++ b/jpastreamer.provider/jpastreamer.application.standard/src/main/java/module-info.java @@ -10,7 +10,6 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -import com.speedment.jpastreamer.analytics.AnalyticsReporterFactory; import com.speedment.jpastreamer.announcer.Announcer; import com.speedment.jpastreamer.appinfo.ApplicationInformation; import com.speedment.jpastreamer.application.JPAStreamerBuilderFactory; @@ -35,7 +34,6 @@ module jpastreamer.application.standard { requires transitive jpastreamer.application; requires transitive jpastreamer.streamconfiguration; - requires jpastreamer.analytics; requires jpastreamer.appinfo; requires jpastreamer.renderer; requires jpastreamer.builder; @@ -47,7 +45,6 @@ uses Announcer; uses ApplicationInformation; - uses AnalyticsReporterFactory; uses RendererFactory; uses BuilderFactory; uses AutoCloseFactory; diff --git a/jpastreamer.provider/pom.xml b/jpastreamer.provider/pom.xml index a42bd6e0..c53d9aba 100644 --- a/jpastreamer.provider/pom.xml +++ b/jpastreamer.provider/pom.xml @@ -39,7 +39,6 @@ jpastreamer.criteria.standard jpastreamer.termopmodifier.standard jpastreamer.termopoptimizer.standard - jpastreamer.analytics.standard jpastreamer.appinfo.standard jpastreamer.streamconfiguration.standard diff --git a/pom.xml b/pom.xml index 700765f7..aa4b4025 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,6 @@ jpastreamer.fieldgenerator jpastreamer.core jpastreamer.integration - jpastreamer.analytics jpastreamer.appinfo jpastreamer.streamconfiguration jpastreamer.announcer From cdc5270746a2b9fc79b618f1aea70185c46969c8 Mon Sep 17 00:00:00 2001 From: Julia Gustafsson Date: Fri, 11 Aug 2023 12:59:17 +0200 Subject: [PATCH 08/16] Remove analytics dependencies --- jpastreamer.core/pom.xml | 8 +------- jpastreamer.core/src/main/java/module-info.java | 1 - .../jpastreamer.application.standard/pom.xml | 5 ----- pom.xml | 12 ------------ 4 files changed, 1 insertion(+), 25 deletions(-) diff --git a/jpastreamer.core/pom.xml b/jpastreamer.core/pom.xml index aa2f338c..41f067c8 100644 --- a/jpastreamer.core/pom.xml +++ b/jpastreamer.core/pom.xml @@ -103,13 +103,7 @@ fieldgenerator-standard ${jpa-streamer.version} - - - com.speedment.jpastreamer - analytics-standard - ${jpa-streamer.version} - - + com.speedment.jpastreamer appinfo-standard diff --git a/jpastreamer.core/src/main/java/module-info.java b/jpastreamer.core/src/main/java/module-info.java index 5a20bd1b..016e06b5 100644 --- a/jpastreamer.core/src/main/java/module-info.java +++ b/jpastreamer.core/src/main/java/module-info.java @@ -27,7 +27,6 @@ requires jpastreamer.termopoptimizer.standard; requires jpastreamer.merger.standard; requires jpastreamer.criteria.standard; - requires jpastreamer.analytics.standard; requires jpastreamer.appinfo.standard; requires jpastreamer.fieldgenerator.standard; requires jpastreamer.streamconfiguration.standard; diff --git a/jpastreamer.provider/jpastreamer.application.standard/pom.xml b/jpastreamer.provider/jpastreamer.application.standard/pom.xml index 55ae9bbe..2342fa11 100644 --- a/jpastreamer.provider/jpastreamer.application.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.application.standard/pom.xml @@ -62,11 +62,6 @@ autoclose - - com.speedment.jpastreamer - analytics - - com.speedment.jpastreamer appinfo diff --git a/pom.xml b/pom.xml index aa4b4025..5a2165ae 100644 --- a/pom.xml +++ b/pom.xml @@ -948,18 +948,6 @@ ${jpa-streamer.version} - - com.speedment.jpastreamer - analytics - ${jpa-streamer.version} - - - - com.speedment.jpastreamer - analytics-standard - ${jpa-streamer.version} - - com.speedment.jpastreamer streamconfiguration From e801d3adfe4b832067fc8db4db8e035ac3af028f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Aug 2023 05:15:59 +0000 Subject: [PATCH 09/16] Bump org.apache.maven.plugins:maven-enforcer-plugin from 3.3.0 to 3.4.0 Bumps [org.apache.maven.plugins:maven-enforcer-plugin](https://github.com/apache/maven-enforcer) from 3.3.0 to 3.4.0. - [Release notes](https://github.com/apache/maven-enforcer/releases) - [Commits](https://github.com/apache/maven-enforcer/compare/enforcer-3.3.0...enforcer-3.4.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-enforcer-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5a2165ae..0f3e4163 100644 --- a/pom.xml +++ b/pom.xml @@ -427,7 +427,7 @@ maven-enforcer-plugin - 3.3.0 + 3.4.0 enforce From 86a7492be6f1f4dda5413f96991a93fc12f779c8 Mon Sep 17 00:00:00 2001 From: Julia Gustafsson Date: Mon, 28 Aug 2023 17:00:35 +0200 Subject: [PATCH 10/16] Inherit fields from parent entity, fix #328 --- integration-tests/pom.xml | 18 +--- .../integration/test/inheritance/.env | 4 + .../test/inheritance/InheritanceTest.java | 85 ++++++++++++++++ .../test/inheritance/docker-compose.yml | 20 ++++ .../test/inheritance/model/BlogPost.java | 20 ++++ .../test/inheritance/model/Book.java | 19 ++++ .../test/inheritance/model/Publication.java | 56 +++++++++++ .../integration/test/inheritance/run-test.sh | 4 + .../test/inheritance/scripts/data.sql | 35 +++++++ .../test/inheritance/scripts/schema.sql | 25 +++++ .../integration/test/inheritance2/.env | 4 + .../test/inheritance2/InheritanceTest2.java | 99 +++++++++++++++++++ .../test/inheritance2/docker-compose.yml | 20 ++++ .../test/inheritance2/model/Author.java | 57 +++++++++++ .../test/inheritance2/model/BlogPost2.java | 22 +++++ .../test/inheritance2/model/Book2.java | 21 ++++ .../test/inheritance2/model/Publication2.java | 76 ++++++++++++++ .../integration/test/inheritance2/run-test.sh | 4 + .../test/inheritance2/scripts/data.sql | 34 +++++++ .../test/inheritance2/scripts/schema.sql | 26 +++++ .../test/{ => standard}/CountTest.java | 7 +- .../test/{ => standard}/JPAStreamerTest.java | 2 +- .../test/{ => standard}/ManyToManyTest.java | 6 +- .../test/{ => standard}/ManyToOneTest.java | 6 +- .../{ => standard}/MapCustomClassTest.java | 4 +- .../test/{ => standard}/MapToIntTest.java | 7 +- .../test/{ => standard}/OneToManyTest.java | 11 +-- .../test/{ => standard}/PaginationTest.java | 6 +- .../test/{ => standard}/PartitionTest.java | 6 +- .../test/{ => standard}/PivotTest.java | 8 +- .../test/{ => standard}/ProjectionTest.java | 8 +- .../test/{ => standard}/ReorderTest.java | 6 +- .../test/{ => standard}/SquashTest.java | 6 +- .../test/{ => standard}/TermOpTest.java | 6 +- .../test/{ => standard}/UnionTest.java | 7 +- .../test/{ => standard}/model/Actor.java | 2 +- .../test/{ => standard}/model/Film.java | 6 +- .../test/{ => standard}/model/Language.java | 2 +- .../{ => standard}/model/groups/GroupA.java | 2 +- .../{ => standard}/model/groups/GroupB.java | 2 +- .../test/resources/META-INF/persistence.xml | 38 ++++++- .../InternalFieldGeneratorProcessor.java | 56 +++++++++-- .../fieldgenerator/test/BlogPost.java | 22 +++++ .../jpastreamer/fieldgenerator/test/Book.java | 21 ++++ .../fieldgenerator/test/Publication.java | 56 +++++++++++ 45 files changed, 872 insertions(+), 80 deletions(-) create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/.env create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/InheritanceTest.java create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/docker-compose.yml create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/BlogPost.java create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Book.java create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Publication.java create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/run-test.sh create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/data.sql create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/schema.sql create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/.env create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/InheritanceTest2.java create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/docker-compose.yml create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Author.java create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/BlogPost2.java create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Book2.java create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Publication2.java create mode 100755 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/run-test.sh create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/data.sql create mode 100644 integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/schema.sql rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/CountTest.java (89%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/JPAStreamerTest.java (92%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/ManyToManyTest.java (88%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/ManyToOneTest.java (88%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/MapCustomClassTest.java (92%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/MapToIntTest.java (87%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/OneToManyTest.java (84%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/PaginationTest.java (88%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/PartitionTest.java (88%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/PivotTest.java (84%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/ProjectionTest.java (91%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/ReorderTest.java (98%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/SquashTest.java (93%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/TermOpTest.java (91%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/UnionTest.java (89%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/model/Actor.java (97%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/model/Film.java (97%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/model/Language.java (97%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/model/groups/GroupA.java (88%) rename integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/{ => standard}/model/groups/GroupB.java (88%) create mode 100644 jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/BlogPost.java create mode 100644 jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Book.java create mode 100644 jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Publication.java diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index e9f5614b..fab8280d 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -17,7 +17,7 @@ jpastreamer-parent com.speedment.jpastreamer - 3.0.3-SNAPSHOT + 3.0.4-SNAPSHOT 4.0.0 @@ -26,14 +26,7 @@ Maven http://maven.apache.org/ 2001 - - - - website - scp://webhost.company.com/www/website - - - + UTF-8 @@ -41,14 +34,14 @@ - org.hibernate + org.hibernate.orm hibernate-core 6.0.2.Final test - org.hibernate + org.hibernate.validator hibernate-validator 6.0.13.Final test @@ -78,8 +71,7 @@ com.speedment.jpastreamer jpastreamer-core - 3.0.3-SNAPSHOT - test + ${jpa-streamer.version} diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/.env b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/.env new file mode 100644 index 00000000..0b3feabf --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/.env @@ -0,0 +1,4 @@ +MYSQL_ROOT_PASSWORD=password +MYSQL_DATABASE=testdb +MYSQL_USER=speedment +MYSQL_PASSWORD=password diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/InheritanceTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/InheritanceTest.java new file mode 100644 index 00000000..eb2ed928 --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/InheritanceTest.java @@ -0,0 +1,85 @@ +package com.speedment.jpastreamer.integration.test.inheritance; + +import com.speedment.jpastreamer.application.JPAStreamer; +import com.speedment.jpastreamer.integration.test.inheritance.model.BlogPost; +import com.speedment.jpastreamer.integration.test.inheritance.model.BlogPost$; +import com.speedment.jpastreamer.integration.test.inheritance.model.Book; +import com.speedment.jpastreamer.integration.test.inheritance.model.Book$; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.stream.Collectors; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class InheritanceTest { + + final static protected JPAStreamer jpaStreamer = JPAStreamer.of("testdb"); + + @Test + void countTest() { + + final List collect = jpaStreamer.stream(Book.class).collect(Collectors.toList()); + + final long expected = collect.stream() + .filter(b -> b.getPages() > 300) + .count(); + + final long actual = jpaStreamer.stream(Book.class) + .filter(Book$.pages.greaterThan(300)) + .count(); + + assertEquals(expected, actual); + } + + @Test + void inheritanceTest() { + + final List collect = jpaStreamer.stream(Book.class).collect(Collectors.toList()); + + final long expected = collect.stream() + .filter(b -> b.getTitle().contains("1")) + .count(); + + final long actual = jpaStreamer.stream(Book.class) + .filter(Book$.title.contains("1")) + .count(); + + assertEquals(expected, actual); + } + + @Test + void inheritanceTest2() { + + final List collect = jpaStreamer.stream(BlogPost.class).collect(Collectors.toList()); + + final long expected = collect.stream() + .filter(b -> b.getTitle().contains("1")) + .count(); + + final long actual = jpaStreamer.stream(BlogPost.class) + .filter(BlogPost$.title.contains("1")) + .count(); + + assertEquals(expected, actual); + } + + @Test + void inheritanceTest3() { + + final List collect = jpaStreamer.stream(BlogPost.class) + .collect(Collectors.toList()); + + final long expected = collect.stream() + .filter(b -> b.getTitle().contains("1")) + .count(); + + final long actual = jpaStreamer.stream(BlogPost.class) + .filter(BlogPost$.title.contains("1")) + .count(); + + assertEquals(expected, actual); + } + + +} diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/docker-compose.yml b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/docker-compose.yml new file mode 100644 index 00000000..05ae15e4 --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/docker-compose.yml @@ -0,0 +1,20 @@ +version: '3.8' + +services: + test-db: + container_name: test-db + image: mysql:8.0 + command: --default-authentication-plugin=mysql_native_password + restart: always + volumes: + - "./scripts/schema.sql:/docker-entrypoint-initdb.d/1.sql" + - "./scripts/data.sql:/docker-entrypoint-initdb.d/2.sql" + environment: + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} + MYSQL_DATABASE: ${MYSQL_DATABASE} + MYSQL_USER: ${MYSQL_USER} + MYSQL_PASSWORD: ${MYSQL_PASSWORD} + ports: + - "3305:3306" + expose: + - "3305" diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/BlogPost.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/BlogPost.java new file mode 100644 index 00000000..3b7a05e0 --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/BlogPost.java @@ -0,0 +1,20 @@ +package com.speedment.jpastreamer.integration.test.inheritance.model; + +import jakarta.persistence.*; + +@Entity +@Table(name = "blogpost", schema = "publications") +public class BlogPost extends Publication { + + @Column(name = "url", nullable = false, updatable = false, columnDefinition = "varchar(255)") + private String url ; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + +} diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Book.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Book.java new file mode 100644 index 00000000..c70850b1 --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Book.java @@ -0,0 +1,19 @@ +package com.speedment.jpastreamer.integration.test.inheritance.model; + +import jakarta.persistence.*; + +@Entity +@Table(name = "books", schema = "publications") +public class Book extends Publication { + + @Column(name = "pages", nullable = false, updatable = false, columnDefinition = "int(6)") + private Integer pages; + + public Integer getPages() { + return pages; + } + + public void setPages(Integer pages) { + this.pages = pages; + } +} diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Publication.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Publication.java new file mode 100644 index 00000000..f8510655 --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Publication.java @@ -0,0 +1,56 @@ +package com.speedment.jpastreamer.integration.test.inheritance.model; + +import jakarta.persistence.*; + +import java.time.LocalDateTime; + +@MappedSuperclass +public abstract class Publication { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false, updatable = false, columnDefinition = "int(6)") + protected Integer id; + + @Column(name = "publishing_date", nullable = false, updatable = false, columnDefinition = "date") + protected LocalDateTime publishingDate; + + @Column(name = "title", nullable = false, updatable = false, columnDefinition = "varchar(255)") + private String title; + + @Version + @Column(name = "version", nullable = false, updatable = false, columnDefinition = "int(6)") + private Integer version; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public LocalDateTime getPublishingDate() { + return publishingDate; + } + + public void setPublishingDate(LocalDateTime publishingDate) { + this.publishingDate = publishingDate; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getVersion() { + return version; + } + + public void setVersion(Integer version) { + this.version = version; + } +} diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/run-test.sh b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/run-test.sh new file mode 100644 index 00000000..51baf5be --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/run-test.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +docker-compose rm -v -f -s test-db && docker-compose up -d +mysql -h 127.0.0.1 -P 3305 -u speedment -ppassword publications diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/data.sql b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/data.sql new file mode 100644 index 00000000..b7e0c7a5 --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/data.sql @@ -0,0 +1,35 @@ +INSERT INTO books (id, publishing_date, title, version, pages) +VALUES (1, '2008-7-04', 'Book 1', 2, 213), + (2, '2009-7-04', 'Book 2', 2, 234), + (3, '2010-7-04', 'Book 3', 2, 643), + (4, '2011-7-04', 'Book 4', 2, 211), + (5, '2012-7-04', 'Book 5', 2, 887), + (6, '2013-7-04', 'Book 6', 2, 123), + (7, '2014-7-04', 'Book 7', 2, 312), + (8, '2015-7-04', 'Book 8', 2, 11), + (9, '2016-7-04', 'Book 9', 2, 523), + (10, '2017-7-04', 'Book 10', 2, 432), + (11, '2018-7-04', 'Book 11', 2, 322), + (12, '2019-7-04', 'Book 12', 2, 121); + +INSERT INTO blogposts (id, publishing_date, title, version, url) +VALUES (1, '2008-7-04', 'Blog Post 1', 2, 'http://speedment.com'), + (2, '2009-7-04', 'Blog Post 2', 2, 'http://speedment.com'), + (3, '2010-7-04', 'Blog Post 3', 2, 'http://speedment.com'), + (4, '2011-7-04', 'Blog Post 4', 2, 'http://speedment.com'), + (5, '2012-7-04', 'Blog Post 5', 2, 'http://speedment.com'), + (6, '2013-7-04', 'Blog Post 6', 2, 'http://speedment.com'), + (7, '2014-7-04', 'Blog Post 7', 2, 'http://speedment.com'), + (8, '2015-7-04', 'Blog Post 8', 2, 'http://speedment.com'), + (9, '2016-7-04', 'Blog Post 9', 2, 'http://speedment.com'), + (10, '2017-7-04', 'Blog Post 10', 2, 'http://speedment.com'), + (11, '2018-7-04', 'Blog Post 11', 2, 'http://speedment.com'), + (12, '2019-7-04', 'Blog Post 12', 2, 'http://speedment.com'), + +INSERT INTO author (id, firstname, lastname, version) + (1, 'Author 1', 'Lastname', 2), + (2, 'Author 2', 'Blog Post 2', 2), + (3, 'Author 3', 'Blog Post 3', 2), + (4, 'Author 5', 'Blog Post 4', 2), + (5, 'Author 6', 'Blog Post 5', 2); + diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/schema.sql b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/schema.sql new file mode 100644 index 00000000..90c3e24e --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/schema.sql @@ -0,0 +1,25 @@ +CREATE TABLE books ( + id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, + publishing_date DATE NOT NULL, + title VARCHAR(255) NOT NULL, + version INT(6), + pages INT(6), + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE blogpost ( + id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, + publishing_date DATE NOT NULL, + title VARCHAR(255) NOT NULL, + version INT(6), + url VARCHAR(255) NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE author ( + id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, + firstname VARCHAR(255) NOT NULL, + lastname VARCHAR(255) NOT NULL, + version INT(6), + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/.env b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/.env new file mode 100644 index 00000000..1e3da257 --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/.env @@ -0,0 +1,4 @@ +MYSQL_ROOT_PASSWORD=password +MYSQL_DATABASE=testdb2 +MYSQL_USER=speedment +MYSQL_PASSWORD=password diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/InheritanceTest2.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/InheritanceTest2.java new file mode 100644 index 00000000..b9006629 --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/InheritanceTest2.java @@ -0,0 +1,99 @@ +package com.speedment.jpastreamer.integration.test.inheritance2; + +import com.speedment.jpastreamer.application.JPAStreamer; +import com.speedment.jpastreamer.integration.test.inheritance.model.Publication; +import com.speedment.jpastreamer.integration.test.inheritance2.model.*; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.stream.Collectors; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class InheritanceTest2 { + + final static protected JPAStreamer jpaStreamer = JPAStreamer.of("testdb2"); + + @Test + void countTest() { + + final List collect = jpaStreamer.stream(Book2.class).collect(Collectors.toList()); + + final long expected = collect.stream() + .filter(b -> b.getPages() > 300) + .count(); + + final long actual = jpaStreamer.stream(Book2.class) + .filter(Book2$.pages.greaterThan(300)) + .count(); + + assertEquals(expected, actual); + } + + @Test + void inheritanceTest() { + + final List collect = jpaStreamer.stream(Book2.class).collect(Collectors.toList()); + + final long expected = collect.stream() + .filter(b -> b.getTitle().contains("1")) + .count(); + + final long actual = jpaStreamer.stream(Book2.class) + .filter(Book2$.title.contains("1")) + .count(); + + assertEquals(expected, actual); + } + + @Test + void inheritanceTest2() { + + final List collect = jpaStreamer.stream(BlogPost2.class).collect(Collectors.toList()); + + final long expected = collect.stream() + .filter(b -> b.getTitle().contains("1")) + .count(); + + final long actual = jpaStreamer.stream(BlogPost2.class) + .filter(BlogPost2$.title.contains("1")) + .count(); + + assertEquals(expected, actual); + } + + + @Test + void inheritanceTest3() { + + final List collect = jpaStreamer.stream(BlogPost2.class).collect(Collectors.toList()); + + final long expected = collect.stream() + .filter(b -> b.getUrl().contains("www")) + .count(); + + final long actual = jpaStreamer.stream(BlogPost2.class) + .filter(BlogPost2$.url.contains("www")) + .count(); + + assertEquals(expected, actual); + } + + @Test + void inheritanceTest4() { + + final List collect = jpaStreamer.stream(Publication2.class) + .collect(Collectors.toList()); + + final long expected = collect.stream() + .filter(p -> p.getTitle().contains("1")) + .count(); + + final long actual = jpaStreamer.stream(Publication2.class) + .filter(Publication2$.title.contains("1")) + .count(); + + assertEquals(expected, actual); + } + +} diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/docker-compose.yml b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/docker-compose.yml new file mode 100644 index 00000000..719761c9 --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/docker-compose.yml @@ -0,0 +1,20 @@ +version: '3.8' + +services: + test-db-2: + container_name: test-db-2 + image: mysql:8.0 + command: --default-authentication-plugin=mysql_native_password + restart: always + volumes: + - "./scripts/schema.sql:/docker-entrypoint-initdb.d/1.sql" + - "./scripts/data.sql:/docker-entrypoint-initdb.d/2.sql" + environment: + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} + MYSQL_DATABASE: ${MYSQL_DATABASE} + MYSQL_USER: ${MYSQL_USER} + MYSQL_PASSWORD: ${MYSQL_PASSWORD} + ports: + - "3304:3306" + expose: + - "3304" diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Author.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Author.java new file mode 100644 index 00000000..98c9a26a --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Author.java @@ -0,0 +1,57 @@ +package com.speedment.jpastreamer.integration.test.inheritance2.model; + +import jakarta.persistence.*; + +import java.util.ArrayList; +import java.util.List; + +@Entity +@Table(name = "author", schema = "publications2") +public class Author { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id", nullable = false, columnDefinition = "int(6)") + protected Long id; + + @Column(name = "firstname", columnDefinition = "varchar(255)") + private String firstname; + + @Column(name = "lastname", columnDefinition = "varchar(255)") + private String lastname; + + @ManyToMany(mappedBy = "authors") + private List publications = new ArrayList<>(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public List getPublications() { + return publications; + } + + public void setPublications(List publications) { + this.publications = publications; + } +} diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/BlogPost2.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/BlogPost2.java new file mode 100644 index 00000000..b381949f --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/BlogPost2.java @@ -0,0 +1,22 @@ +package com.speedment.jpastreamer.integration.test.inheritance2.model; + +import jakarta.persistence.Column; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.Entity; + +@Entity +@DiscriminatorValue("BlogPost") +public class BlogPost2 extends Publication2 { + + @Column(name = "url", columnDefinition = "varchar(255)") + private String url ; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + +} diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Book2.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Book2.java new file mode 100644 index 00000000..399c9bdf --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Book2.java @@ -0,0 +1,21 @@ +package com.speedment.jpastreamer.integration.test.inheritance2.model; + +import jakarta.persistence.Column; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.Entity; + +@Entity +@DiscriminatorValue("Book") +public class Book2 extends Publication2 { + + @Column(name = "pages", columnDefinition = "int(6)") + private Integer pages; + + public Integer getPages() { + return pages; + } + + public void setPages(Integer pages) { + this.pages = pages; + } +} diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Publication2.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Publication2.java new file mode 100644 index 00000000..b731e8a6 --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Publication2.java @@ -0,0 +1,76 @@ +package com.speedment.jpastreamer.integration.test.inheritance2.model; + +import jakarta.persistence.*; + +import java.time.LocalDateTime; +import java.util.HashSet; +import java.util.Set; + +@Entity +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(name = "publication_type") +public abstract class Publication2 { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id", nullable = false, columnDefinition = "int(6)") + protected Long id; + + @Column(name = "publishing_date", nullable = false, columnDefinition = "date") + protected LocalDateTime publishingDate; + + @Column(name = "title", nullable = false, columnDefinition = "varchar(255)") + private String title; + + @Version + @Column(name = "version", nullable = false, columnDefinition = "int(6)") + private Integer version; + + @ManyToMany(cascade = { CascadeType.ALL }) + @JoinTable( + name = "publication_author", + joinColumns = { @JoinColumn(name = "publication_id", referencedColumnName = "id")}, + inverseJoinColumns = { @JoinColumn(name = "author_id", referencedColumnName = "id")} + ) + private Set authors = new HashSet<>(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public LocalDateTime getPublishingDate() { + return publishingDate; + } + + public void setPublishingDate(LocalDateTime publishingDate) { + this.publishingDate = publishingDate; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getVersion() { + return version; + } + + public void setVersion(Integer version) { + this.version = version; + } + + public Set getAuthors() { + return authors; + } + + public void setAuthors(Set authors) { + this.authors = authors; + } +} diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/run-test.sh b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/run-test.sh new file mode 100755 index 00000000..4132d822 --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/run-test.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +docker-compose rm -v -f -s test-db-2 && docker-compose up -d +mysql -h 127.0.0.1 -P 3304 -u speedment -ppassword testdb2 diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/data.sql b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/data.sql new file mode 100644 index 00000000..130ddda3 --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/data.sql @@ -0,0 +1,34 @@ +INSERT INTO publication(id, publication_type, publishing_date, title, version, pages, url) +VALUES (1, 'Book', '2008-7-04', 'Book 1', 2, 213, null), + (2, 'Book', '2009-7-04', 'Book 2', 2, 234, null), + (3, 'Book', '2010-7-04', 'Book 3', 2, 643, null), + (4, 'Book', '2011-7-04', 'Book 4', 2, 211, null), + (5, 'Book', '2012-7-04', 'Book 5', 2, 887, null), + (6, 'Book', '2013-7-04', 'Book 6', 2, 123, null), + (7, 'Book', '2014-7-04', 'Book 7', 2, 312, null), + (8, 'BlogPost', '2015-7-04', 'BlogPost 1', 2, null, 'www.speedment.com'), + (9, 'BlogPost', '2016-7-04', 'BlogPost 2', 2, null, 'www.speedment.com'), + (10, 'BlogPost', '2017-7-04', 'BlogPost 3', 2, null, 'www.speedment.com'), + (11, 'BlogPost', '2018-7-04', 'BlogPost 4', 2, null, 'www.speedment.com'), + (12, 'BlogPost', '2019-7-04', 'BlogPost 5', 2, null, 'www.speedment.com'); + +INSERT INTO author (id, firstname, lastname, version) +VALUES (1, 'Author 1', 'Lastname', 2), + (2, 'Author 2', 'Blog Post 2', 2), + (3, 'Author 3', 'Blog Post 3', 2), + (4, 'Author 5', 'Blog Post 4', 2), + (5, 'Author 6', 'Blog Post 5', 2); + +INSERT INTO publication_author(publication_id, author_id) +VALUES (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5), + (6, 1), + (7, 2), + (8, 3), + (9, 4), + (10, 5), + (11, 1), + (12, 2); diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/schema.sql b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/schema.sql new file mode 100644 index 00000000..a63ae362 --- /dev/null +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/schema.sql @@ -0,0 +1,26 @@ +CREATE TABLE publication ( + id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, + publication_type VARCHAR(31), + publishing_date DATE NOT NULL, + title VARCHAR(255) NOT NULL, + version INT(6), + pages INT(6) UNSIGNED, + url VARCHAR(255), + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE author ( + id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, + firstname VARCHAR(255) NOT NULL, + lastname VARCHAR(255) NOT NULL, + version INT(6), + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +CREATE TABLE publication_author ( + publication_id INT(6) UNSIGNED, + author_id INT(6) UNSIGNED, + PRIMARY KEY (publication_id, author_id), + FOREIGN KEY (publication_id) REFERENCES publication(id), + FOREIGN KEY (author_id) REFERENCES author(id) +); diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/CountTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/CountTest.java similarity index 89% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/CountTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/CountTest.java index c34adee2..07c32405 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/CountTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/CountTest.java @@ -10,12 +10,11 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; -import com.speedment.jpastreamer.application.JPAStreamer; import com.speedment.jpastreamer.application.StreamSupplier; -import com.speedment.jpastreamer.integration.test.model.Film; -import com.speedment.jpastreamer.integration.test.model.Film$; +import com.speedment.jpastreamer.integration.test.standard.model.Film; +import com.speedment.jpastreamer.integration.test.standard.model.Film$; import org.junit.jupiter.api.Test; import java.util.List; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/JPAStreamerTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/JPAStreamerTest.java similarity index 92% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/JPAStreamerTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/JPAStreamerTest.java index c8152939..dab9154d 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/JPAStreamerTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/JPAStreamerTest.java @@ -10,7 +10,7 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; import com.speedment.jpastreamer.application.JPAStreamer; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ManyToManyTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/ManyToManyTest.java similarity index 88% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ManyToManyTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/ManyToManyTest.java index aeaaa238..59776e68 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ManyToManyTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/ManyToManyTest.java @@ -10,10 +10,10 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; -import com.speedment.jpastreamer.integration.test.model.Actor; -import com.speedment.jpastreamer.integration.test.model.Actor$; +import com.speedment.jpastreamer.integration.test.standard.model.Actor; +import com.speedment.jpastreamer.integration.test.standard.model.Actor$; import org.junit.jupiter.api.Test; import java.util.Comparator; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ManyToOneTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/ManyToOneTest.java similarity index 88% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ManyToOneTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/ManyToOneTest.java index 8b86763a..c92c9abc 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ManyToOneTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/ManyToOneTest.java @@ -10,10 +10,10 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; -import com.speedment.jpastreamer.integration.test.model.Film; -import com.speedment.jpastreamer.integration.test.model.Film$; +import com.speedment.jpastreamer.integration.test.standard.model.Film; +import com.speedment.jpastreamer.integration.test.standard.model.Film$; import org.junit.jupiter.api.Test; import java.util.Comparator; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/MapCustomClassTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/MapCustomClassTest.java similarity index 92% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/MapCustomClassTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/MapCustomClassTest.java index e279cb89..8f5e06ae 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/MapCustomClassTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/MapCustomClassTest.java @@ -10,9 +10,9 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; -import com.speedment.jpastreamer.integration.test.model.Film; +import com.speedment.jpastreamer.integration.test.standard.model.Film; import org.junit.jupiter.api.Test; import java.util.Optional; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/MapToIntTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/MapToIntTest.java similarity index 87% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/MapToIntTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/MapToIntTest.java index 4a190132..6349f5c7 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/MapToIntTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/MapToIntTest.java @@ -10,15 +10,14 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; -import com.speedment.jpastreamer.integration.test.model.Film; -import com.speedment.jpastreamer.integration.test.model.Film$; +import com.speedment.jpastreamer.integration.test.standard.model.Film; +import com.speedment.jpastreamer.integration.test.standard.model.Film$; import org.junit.jupiter.api.Test; import java.util.Comparator; import java.util.List; -import java.util.OptionalInt; import java.util.stream.Collectors; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/OneToManyTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/OneToManyTest.java similarity index 84% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/OneToManyTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/OneToManyTest.java index ec7af671..c1fe4d08 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/OneToManyTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/OneToManyTest.java @@ -10,13 +10,12 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; -import com.speedment.jpastreamer.integration.test.model.Film; -import com.speedment.jpastreamer.integration.test.model.Film$; -import com.speedment.jpastreamer.integration.test.model.Language; -import com.speedment.jpastreamer.integration.test.model.Language$; -import org.junit.jupiter.api.Disabled; +import com.speedment.jpastreamer.integration.test.standard.model.Film; +import com.speedment.jpastreamer.integration.test.standard.model.Film$; +import com.speedment.jpastreamer.integration.test.standard.model.Language; +import com.speedment.jpastreamer.integration.test.standard.model.Language$; import org.junit.jupiter.api.Test; import java.util.Comparator; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/PaginationTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/PaginationTest.java similarity index 88% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/PaginationTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/PaginationTest.java index f4da0530..8874fe1f 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/PaginationTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/PaginationTest.java @@ -10,11 +10,11 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; import com.speedment.jpastreamer.application.StreamSupplier; -import com.speedment.jpastreamer.integration.test.model.Film; -import com.speedment.jpastreamer.integration.test.model.Film$; +import com.speedment.jpastreamer.integration.test.standard.model.Film; +import com.speedment.jpastreamer.integration.test.standard.model.Film$; import org.junit.jupiter.api.Test; import java.util.Comparator; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/PartitionTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/PartitionTest.java similarity index 88% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/PartitionTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/PartitionTest.java index a4f9ba04..65f85639 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/PartitionTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/PartitionTest.java @@ -10,11 +10,11 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; import com.speedment.jpastreamer.application.StreamSupplier; -import com.speedment.jpastreamer.integration.test.model.Film; -import com.speedment.jpastreamer.integration.test.model.Film$; +import com.speedment.jpastreamer.integration.test.standard.model.Film; +import com.speedment.jpastreamer.integration.test.standard.model.Film$; import org.junit.jupiter.api.Test; import java.util.List; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/PivotTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/PivotTest.java similarity index 84% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/PivotTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/PivotTest.java index 10e46e6e..c1a02897 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/PivotTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/PivotTest.java @@ -10,11 +10,11 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; -import com.speedment.jpastreamer.integration.test.model.Actor; -import com.speedment.jpastreamer.integration.test.model.Actor$; -import com.speedment.jpastreamer.integration.test.model.Film; +import com.speedment.jpastreamer.integration.test.standard.model.Actor; +import com.speedment.jpastreamer.integration.test.standard.model.Actor$; +import com.speedment.jpastreamer.integration.test.standard.model.Film; import org.junit.jupiter.api.Test; import java.util.Map; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ProjectionTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/ProjectionTest.java similarity index 91% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ProjectionTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/ProjectionTest.java index dfd4796e..9d08f067 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ProjectionTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/ProjectionTest.java @@ -10,20 +10,18 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; import com.speedment.jpastreamer.application.StreamSupplier; -import com.speedment.jpastreamer.integration.test.model.Film; -import com.speedment.jpastreamer.integration.test.model.Film$; +import com.speedment.jpastreamer.integration.test.standard.model.Film; +import com.speedment.jpastreamer.integration.test.standard.model.Film$; import com.speedment.jpastreamer.projection.Projection; import com.speedment.jpastreamer.streamconfiguration.StreamConfiguration; -import jakarta.persistence.Tuple; import org.junit.jupiter.api.Test; import java.util.List; import java.util.stream.Collectors; -import static java.util.Comparator.*; import static org.junit.jupiter.api.Assertions.*; public class ProjectionTest extends JPAStreamerTest { diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ReorderTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/ReorderTest.java similarity index 98% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ReorderTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/ReorderTest.java index eb5ce426..60513501 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/ReorderTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/ReorderTest.java @@ -10,11 +10,11 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; import com.speedment.jpastreamer.application.StreamSupplier; -import com.speedment.jpastreamer.integration.test.model.Film; -import com.speedment.jpastreamer.integration.test.model.Film$; +import com.speedment.jpastreamer.integration.test.standard.model.Film; +import com.speedment.jpastreamer.integration.test.standard.model.Film$; import org.junit.jupiter.api.Test; import java.util.Comparator; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/SquashTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/SquashTest.java similarity index 93% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/SquashTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/SquashTest.java index 6e414666..58fa3963 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/SquashTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/SquashTest.java @@ -10,11 +10,11 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; import com.speedment.jpastreamer.application.StreamSupplier; -import com.speedment.jpastreamer.integration.test.model.Film; -import com.speedment.jpastreamer.integration.test.model.Film$; +import com.speedment.jpastreamer.integration.test.standard.model.Film; +import com.speedment.jpastreamer.integration.test.standard.model.Film$; import org.junit.jupiter.api.Test; import java.util.Comparator; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/TermOpTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/TermOpTest.java similarity index 91% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/TermOpTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/TermOpTest.java index b850a209..2394edf7 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/TermOpTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/TermOpTest.java @@ -10,10 +10,10 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; -import com.speedment.jpastreamer.integration.test.model.Film; -import com.speedment.jpastreamer.integration.test.model.Film$; +import com.speedment.jpastreamer.integration.test.standard.model.Film; +import com.speedment.jpastreamer.integration.test.standard.model.Film$; import org.junit.jupiter.api.Test; import java.util.Optional; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/UnionTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/UnionTest.java similarity index 89% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/UnionTest.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/UnionTest.java index 65019f33..4eb010f5 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/UnionTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/UnionTest.java @@ -10,12 +10,11 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test; +package com.speedment.jpastreamer.integration.test.standard; -import com.speedment.jpastreamer.application.JPAStreamer; import com.speedment.jpastreamer.application.StreamSupplier; -import com.speedment.jpastreamer.integration.test.model.Film; -import com.speedment.jpastreamer.integration.test.model.Film$; +import com.speedment.jpastreamer.integration.test.standard.model.Film; +import com.speedment.jpastreamer.integration.test.standard.model.Film$; import com.speedment.jpastreamer.streamconfiguration.StreamConfiguration; import org.junit.jupiter.api.Test; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/Actor.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/Actor.java similarity index 97% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/Actor.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/Actor.java index 290f21f1..b3a5a0ad 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/Actor.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/Actor.java @@ -10,7 +10,7 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test.model; +package com.speedment.jpastreamer.integration.test.standard.model; import jakarta.persistence.*; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/Film.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/Film.java similarity index 97% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/Film.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/Film.java index 1661a8fd..b6994158 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/Film.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/Film.java @@ -10,10 +10,10 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test.model; +package com.speedment.jpastreamer.integration.test.standard.model; -import com.speedment.jpastreamer.integration.test.model.groups.GroupA; -import com.speedment.jpastreamer.integration.test.model.groups.GroupB; +import com.speedment.jpastreamer.integration.test.standard.model.groups.GroupA; +import com.speedment.jpastreamer.integration.test.standard.model.groups.GroupB; import jakarta.persistence.*; import javax.validation.constraints.NotNull; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/Language.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/Language.java similarity index 97% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/Language.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/Language.java index 5bdf45d6..39d55c88 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/Language.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/Language.java @@ -10,7 +10,7 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test.model; +package com.speedment.jpastreamer.integration.test.standard.model; import jakarta.persistence.*; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/groups/GroupA.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/groups/GroupA.java similarity index 88% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/groups/GroupA.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/groups/GroupA.java index 90b5e2f7..dd4695f0 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/groups/GroupA.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/groups/GroupA.java @@ -10,7 +10,7 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test.model.groups; +package com.speedment.jpastreamer.integration.test.standard.model.groups; public interface GroupA { } diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/groups/GroupB.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/groups/GroupB.java similarity index 88% rename from integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/groups/GroupB.java rename to integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/groups/GroupB.java index daf01777..45bd4c4e 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/model/groups/GroupB.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/groups/GroupB.java @@ -10,6 +10,6 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -package com.speedment.jpastreamer.integration.test.model.groups; +package com.speedment.jpastreamer.integration.test.standard.model.groups; public interface GroupB { } diff --git a/integration-tests/src/test/resources/META-INF/persistence.xml b/integration-tests/src/test/resources/META-INF/persistence.xml index f707a062..39348bd5 100644 --- a/integration-tests/src/test/resources/META-INF/persistence.xml +++ b/integration-tests/src/test/resources/META-INF/persistence.xml @@ -18,7 +18,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"> - + Test org.hibernate.jpa.HibernatePersistenceProvider @@ -35,4 +35,40 @@ + + + Inheritance Test + org.hibernate.jpa.HibernatePersistenceProvider + + + + + + + + + + + + + + + + Inheritance Test 2 + org.hibernate.jpa.HibernatePersistenceProvider + + + + + + + + + + + + + + + diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/src/main/java/com/speedment/jpastreamer/fieldgenerator/internal/InternalFieldGeneratorProcessor.java b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/src/main/java/com/speedment/jpastreamer/fieldgenerator/internal/InternalFieldGeneratorProcessor.java index 0253d4e4..e215a4b1 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/src/main/java/com/speedment/jpastreamer/fieldgenerator/internal/InternalFieldGeneratorProcessor.java +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/src/main/java/com/speedment/jpastreamer/fieldgenerator/internal/InternalFieldGeneratorProcessor.java @@ -29,12 +29,14 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Lob; +import jakarta.persistence.MappedSuperclass; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.Messager; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; import javax.lang.model.element.*; +import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.Elements; @@ -96,6 +98,7 @@ public boolean process(Set annotations, RoundEnvironment } Set entities = roundEnv.getElementsAnnotatedWith(Entity.class); + Set superClasses = roundEnv.getElementsAnnotatedWith(MappedSuperclass.class); if (entities.isEmpty()) { messager.printMessage(Diagnostic.Kind.WARNING, "[JPAStreamer Field Generator Processor] Found no classes annotated with jakarta.persistence.Entity.\n"); @@ -124,13 +127,34 @@ public boolean process(Set annotations, RoundEnvironment } else { annotatedElementPackageName = packageElement.getQualifiedName().toString(); } - + String packageName = processingEnv.getOptions().getOrDefault("jpaStreamerPackage", annotatedElementPackageName); String qualifiedGenEntityName = packageName + "." + genEntityName; JavaFileObject builderFile = processingEnv.getFiler().createSourceFile(qualifiedGenEntityName); Writer writer = builderFile.openWriter(); - generateFields(ae, entityName, genEntityName, packageName, writer); + + TypeMirror type = ae.asType(); + List typeMirrors = processingEnvironment.getTypeUtils().directSupertypes(type); + + Optional superClass = typeMirrors.stream() + .filter(DeclaredType.class::isInstance) + .map(DeclaredType.class::cast) + .map(DeclaredType::asElement) + .filter(e -> e.getAnnotation(MappedSuperclass.class) != null || e.getAnnotation(Entity.class ) != null) + .map(e -> e.getSimpleName().toString()) + .findFirst(); + + Optional superClassElement = Optional.empty(); + if (superClass.isPresent()) { + // Entity should inherit fields from the superclass, retrieve element + superClassElement = Stream.concat(entities.stream(), superClasses.stream()) + .filter(sc -> sc.getKind() == ElementKind.CLASS) + .filter(sc -> sc.getSimpleName().toString().equals(superClass.get())) + .findFirst(); + } + + generateFields(ae, entityName, genEntityName, packageName, superClassElement, writer); writer.close(); } catch (IOException e) { e.printStackTrace(); @@ -140,8 +164,13 @@ public boolean process(Set annotations, RoundEnvironment return true; } - void generateFields(final Element annotatedElement, final String entityName, final String genEntityName, final String packageName, final Writer writer) throws IOException { - + void generateFields(final Element annotatedElement, + final String entityName, + final String genEntityName, + final String packageName, + final Optional superClass, + final Writer writer) throws IOException { + final Map getters = annotatedElement.getEnclosedElements().stream() .filter(ee -> ee.getKind() == ElementKind.METHOD) // Only consider methods with no parameters @@ -158,8 +187,15 @@ void generateFields(final Element annotatedElement, final String entityName, fin .map(Formatting::lcfirst) .collect(toSet()); + Stream fields = annotatedElement.getEnclosedElements().stream(); + + if (superClass.isPresent()) { + // Add parent fields + fields = Stream.concat(fields, superClass.get().getEnclosedElements().stream()); + } + // Retrieve all declared non-final instance fields of the annotated class - Map enclosedFields = annotatedElement.getEnclosedElements().stream() + Map enclosedFields = fields .filter(ee -> ee.getKind().isField() && !ee.getModifiers().contains(Modifier.STATIC) // Ignore static fields && !ee.getModifiers().contains(Modifier.FINAL)) // Ignore final fields @@ -168,8 +204,8 @@ void generateFields(final Element annotatedElement, final String entityName, fin Function.identity(), ee -> findGetter(ee, getters, isGetters, shortName(entityName), lombokGetterAvailable(annotatedElement, ee))) ); - - final File file = generatedEntity(enclosedFields, entityName, genEntityName, packageName); + + final File file = generatedEntity(annotatedElement, enclosedFields, entityName, genEntityName, packageName); writer.write(generator.on(file).orElseThrow(NoSuchElementException::new)); } @@ -220,7 +256,11 @@ private String findGetter(final Element field, return lambdaName + " -> {throw new " + IllegalJavaBeanException.class.getSimpleName() + "(" + entityName + ".class, \"" + fieldName + "\");}"; } - private File generatedEntity(final Map enclosedFields, final String entityName, final String genEntityName, final String packageName) { + private File generatedEntity(final Element annotatedElement, + final Map enclosedFields, + final String entityName, + final String genEntityName, + final String packageName) { final File file = packageName.isEmpty() ? File.of(genEntityName + ".java") : File.of(packageName + "/" + genEntityName + ".java"); diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/BlogPost.java b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/BlogPost.java new file mode 100644 index 00000000..3836fdf2 --- /dev/null +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/BlogPost.java @@ -0,0 +1,22 @@ +package com.speedment.jpastreamer.fieldgenerator.test; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +@Entity +@Table(name = "blogpost", schema = "publications") +public class BlogPost extends Publication { + + @Column(name = "url", nullable = false, updatable = false, columnDefinition = "varchar(255)") + private String url ; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + +} diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Book.java b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Book.java new file mode 100644 index 00000000..044aa1d3 --- /dev/null +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Book.java @@ -0,0 +1,21 @@ +package com.speedment.jpastreamer.fieldgenerator.test; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; + +@Entity +@Table(name = "books", schema = "publications") +public class Book extends Publication { + + @Column(name = "pages", nullable = false, updatable = false, columnDefinition = "int(6)") + private Integer pages; + + public Integer getPages() { + return pages; + } + + public void setPages(Integer pages) { + this.pages = pages; + } +} diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Publication.java b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Publication.java new file mode 100644 index 00000000..36e74a23 --- /dev/null +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Publication.java @@ -0,0 +1,56 @@ +package com.speedment.jpastreamer.fieldgenerator.test; + +import jakarta.persistence.*; + +import java.time.LocalDateTime; + +@MappedSuperclass +public abstract class Publication { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false, updatable = false, columnDefinition = "int(6)") + protected Integer id; + + @Column(name = "publishing_date", nullable = false, updatable = false, columnDefinition = "date") + protected LocalDateTime publishingDate; + + @Column(name = "title", nullable = false, updatable = false, columnDefinition = "varchar(255)") + private String title; + + @Version + @Column(name = "version", nullable = false, updatable = false, columnDefinition = "int(6)") + private Integer version; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public LocalDateTime getPublishingDate() { + return publishingDate; + } + + public void setPublishingDate(LocalDateTime publishingDate) { + this.publishingDate = publishingDate; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getVersion() { + return version; + } + + public void setVersion(Integer version) { + this.version = version; + } +} From 4f7edd9df3f36f0c8a039ea813f89b54415c510a Mon Sep 17 00:00:00 2001 From: Julia Gustafsson Date: Tue, 29 Aug 2023 10:59:25 +0200 Subject: [PATCH 11/16] Correct annotation processing, fix #368 --- integration-tests/pom.xml | 19 +++++++++---------- .../integration/test/standard/model/Film.java | 11 ++++++----- .../InternalFieldGeneratorProcessor.java | 7 ++++--- .../jpastreamer.fieldgenerator.test/pom.xml | 6 +++--- .../jpastreamer/fieldgenerator/test/Film.java | 10 ++++++++-- .../fieldgenerator/test/User2.java | 4 ++-- .../src/main/java/module-info.java | 2 +- 7 files changed, 33 insertions(+), 26 deletions(-) diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index fab8280d..b48f6c39 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -39,35 +39,34 @@ 6.0.2.Final test - org.hibernate.validator hibernate-validator - 6.0.13.Final + 8.0.1.Final test - - org.hibernate.javax.persistence - hibernate-jpa-2.1-api - 1.0.2 - test + jakarta.el + jakarta.el-api + 5.0.1 + + + org.glassfish + jakarta.el + 5.0.0-M1 - net.bytebuddy byte-buddy 1.12.12 test - mysql mysql-connector-java 8.0.30 test - com.speedment.jpastreamer jpastreamer-core diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/Film.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/Film.java index b6994158..b46578f5 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/Film.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/standard/model/Film.java @@ -15,9 +15,10 @@ import com.speedment.jpastreamer.integration.test.standard.model.groups.GroupA; import com.speedment.jpastreamer.integration.test.standard.model.groups.GroupB; import jakarta.persistence.*; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.Size; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; import java.io.Serializable; import java.time.LocalDateTime; import java.util.ArrayList; @@ -45,11 +46,11 @@ public Film(Integer filmId, String title) { private Integer filmId; @Column(name = "title", nullable = false, columnDefinition = "varchar(255)") - //@NotEmpty(message = "Title may not be empty", groups = {GroupA.class, GroupB.class}) - @NotNull(message = "Title may not be null", groups = {GroupA.class, GroupB.class}) + @NotEmpty(message = "Title may not be empty", groups = {GroupA.class, GroupB.class}) private String title; - + @Column(name = "description", nullable = false, columnDefinition = "text") + @NotBlank private String description; @ManyToOne diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/src/main/java/com/speedment/jpastreamer/fieldgenerator/internal/InternalFieldGeneratorProcessor.java b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/src/main/java/com/speedment/jpastreamer/fieldgenerator/internal/InternalFieldGeneratorProcessor.java index e215a4b1..d1aeaaab 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/src/main/java/com/speedment/jpastreamer/fieldgenerator/internal/InternalFieldGeneratorProcessor.java +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.standard/src/main/java/com/speedment/jpastreamer/fieldgenerator/internal/InternalFieldGeneratorProcessor.java @@ -385,7 +385,6 @@ private String trimAnnotations(Element field) { final String fieldType = field.asType().toString(); final List annotations = field.getAnnotationMirrors().stream() .map(Object::toString) - .filter(s -> !(s.contains("jakarta"))) .collect(Collectors.toList()); if (annotations.isEmpty() && !fieldType.contains("@")) { final int index = fieldType.lastIndexOf(' '); @@ -393,10 +392,12 @@ private String trimAnnotations(Element field) { } String result = fieldType; for (String annotation : annotations) { - result = result.replace(annotation, ""); + // ensure that trailing commas are removed + result = result.contains(annotation + ',') ? + result.replace(annotation + ',', "") : + result.replace(annotation, ""); } result = result.replace(" ", ""); - result = result.replace(",", ""); return result; } diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/pom.xml b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/pom.xml index f4a43eff..ab14e22d 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/pom.xml +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/pom.xml @@ -60,9 +60,9 @@ - javax.validation - validation-api - 2.0.1.Final + org.hibernate.validator + hibernate-validator + 8.0.1.Final diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Film.java b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Film.java index 1fc7ef21..2ad837d4 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Film.java +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Film.java @@ -13,9 +13,11 @@ package com.speedment.jpastreamer.fieldgenerator.test; import jakarta.persistence.*; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; import java.sql.Time; import java.time.LocalDateTime; import java.util.*; @@ -37,6 +39,7 @@ public class Film { private String title; @Column(name = "description", nullable = false, columnDefinition = "text") + @NotBlank private String description; @Column(name = "audienceScore", nullable = true, columnDefinition = "decimal(4,2)") @@ -73,6 +76,9 @@ public class Film { private Language originalLanguage; @Column(name = "complex_column") + @NotBlank + @NotEmpty + @NotNull private Map>, Integer>, Long> complexColumn; @Column(name = "rental_duration", columnDefinition = "smallint(5)") diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/User2.java b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/User2.java index 7f7b4fcd..c103855d 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/User2.java +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/User2.java @@ -13,21 +13,21 @@ package com.speedment.jpastreamer.fieldgenerator.test; import jakarta.persistence.*; -import javax.validation.constraints.NotEmpty; import java.io.Serializable; +import jakarta.validation.constraints.NotEmpty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; + @Entity @Table(name="user") @Data @Builder @NoArgsConstructor @AllArgsConstructor - public class User2 implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_shared") diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/module-info.java b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/module-info.java index 04c28657..4bc04091 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/module-info.java +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/module-info.java @@ -17,7 +17,7 @@ requires jpastreamer.fieldgenerator.standard; requires jakarta.persistence; requires lombok; - requires java.validation; + requires jakarta.validation; requires transitive java.sql; requires transitive jpastreamer.field; From 04a2ca7bade4f8d51372586754a79616b2e8fb60 Mon Sep 17 00:00:00 2001 From: Julia Gustafsson Date: Wed, 30 Aug 2023 08:25:19 +0200 Subject: [PATCH 12/16] Add support for toList() and mapMulti(), fix #370 and fix #371 --- .../javanine/Java9DoubleStreamAdditions.java | 28 -- .../javanine/Java9IntStreamAdditions.java | 28 -- .../javanine/Java9LongStreamAdditions.java | 28 -- .../javanine/Java9StreamAdditions.java | 28 -- .../jpastreamer/javanine/Java9StreamUtil.java | 148 -------- .../internal/InternalJava9StreamUtil.java | 335 ------------------ .../pom.xml | 2 +- .../javasixteen/Java16StreamAdditions.java | 38 ++ .../javasixteen/Java16StreamUtil.java | 108 ++++++ .../internal/InternalJava16StreamUtil.java | 154 ++++++++ .../javasixteen}/package-info.java | 4 +- .../src/main/java/module-info.java | 5 +- .../jpastreamer.autoclose.standard/pom.xml | 2 +- .../internal/AutoClosingDoubleStream.java | 9 +- .../internal/AutoClosingIntStream.java | 9 +- .../internal/AutoClosingLongStream.java | 9 +- .../standard/internal/AutoClosingStream.java | 42 ++- .../src/main/java/module-info.java | 2 +- .../AbstractAutoClosingStreamTest.java | 2 - .../internal/AutoClosingDoubleStreamTest.java | 12 +- .../internal/AutoClosingIntStreamTest.java | 7 +- .../internal/AutoClosingLongStreamTest.java | 5 +- .../internal/AutoClosingStreamTest.java | 45 ++- .../jpastreamer.builder.standard/pom.xml | 2 +- .../internal/DoubleStreamBuilder.java | 3 +- .../standard/internal/IntStreamBuilder.java | 3 +- .../standard/internal/LongStreamBuilder.java | 3 +- .../src/main/java/module-info.java | 2 +- .../jpastreamer.pipeline.standard/pom.xml | 2 +- pom.xml | 4 +- 30 files changed, 405 insertions(+), 664 deletions(-) delete mode 100644 jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9DoubleStreamAdditions.java delete mode 100644 jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9IntStreamAdditions.java delete mode 100644 jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9LongStreamAdditions.java delete mode 100644 jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9StreamAdditions.java delete mode 100644 jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9StreamUtil.java delete mode 100644 jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/internal/InternalJava9StreamUtil.java rename {jpastreamer.javanine => jpastreamer.javasixteen}/pom.xml (96%) create mode 100644 jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/Java16StreamAdditions.java create mode 100644 jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/Java16StreamUtil.java create mode 100644 jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/internal/InternalJava16StreamUtil.java rename {jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine => jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen}/package-info.java (88%) rename {jpastreamer.javanine => jpastreamer.javasixteen}/src/main/java/module-info.java (87%) diff --git a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9DoubleStreamAdditions.java b/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9DoubleStreamAdditions.java deleted file mode 100644 index 2839ce2e..00000000 --- a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9DoubleStreamAdditions.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.javanine; - -import java.util.function.DoublePredicate; -import java.util.stream.DoubleStream; - -/** - * - * @author Per Minborg - */ -public interface Java9DoubleStreamAdditions { - - DoubleStream takeWhile(DoublePredicate predicate); - - DoubleStream dropWhile(DoublePredicate predicate); - -} diff --git a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9IntStreamAdditions.java b/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9IntStreamAdditions.java deleted file mode 100644 index 2e02ba81..00000000 --- a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9IntStreamAdditions.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.javanine; - -import java.util.function.IntPredicate; -import java.util.stream.IntStream; - -/** - * - * @author Per Minborg - */ -public interface Java9IntStreamAdditions { - - IntStream takeWhile(IntPredicate predicate); - - IntStream dropWhile(IntPredicate predicate); - -} diff --git a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9LongStreamAdditions.java b/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9LongStreamAdditions.java deleted file mode 100644 index 8a9d65b4..00000000 --- a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9LongStreamAdditions.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.javanine; - -import java.util.function.LongPredicate; -import java.util.stream.LongStream; - -/** - * - * @author Per Minborg - */ -public interface Java9LongStreamAdditions { - - LongStream takeWhile(LongPredicate predicate); - - LongStream dropWhile(LongPredicate predicate); - -} diff --git a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9StreamAdditions.java b/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9StreamAdditions.java deleted file mode 100644 index 2e15dc16..00000000 --- a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9StreamAdditions.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.javanine; - -import java.util.function.Predicate; -import java.util.stream.Stream; - -/** - * - * @author Per Minborg - */ -public interface Java9StreamAdditions { - - Stream takeWhile(Predicate predicate); - - Stream dropWhile(Predicate predicate); - -} diff --git a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9StreamUtil.java b/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9StreamUtil.java deleted file mode 100644 index 922063d2..00000000 --- a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/Java9StreamUtil.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.javanine; - -import com.speedment.jpastreamer.javanine.internal.InternalJava9StreamUtil; - -import java.util.function.DoublePredicate; -import java.util.function.IntPredicate; -import java.util.function.LongPredicate; -import java.util.function.Predicate; -import java.util.stream.DoubleStream; -import java.util.stream.IntStream; -import java.util.stream.LongStream; -import java.util.stream.Stream; - -/** - * - * @author Per Minborg - */ -public final class Java9StreamUtil { - - private Java9StreamUtil() {} - - /** - * Delegates a DoubleStream::takeWhile operation to the Java platforms - * underlying default Stream implementation. If run under Java 8, this - * method will throw an UnsupportedOperationException. - * - * @param stream to apply the takeWhile operation to - * @param predicate to use for takeWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the takeWhile(predicate) has been applied - */ - public static DoubleStream takeWhile(DoubleStream stream, DoublePredicate predicate) { - return InternalJava9StreamUtil.takeWhile(stream, predicate); - } - - /** - * Delegates a DoubleStream::dropWhile operation to the Java platforms - * underlying default Stream implementation. If run under Java 8, this - * method will throw an UnsupportedOperationException. - * - * @param stream to apply the dropWhile operation to - * @param predicate to use for dropWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the dropWhile(predicate) has been applied - */ - public static DoubleStream dropWhile(DoubleStream stream, DoublePredicate predicate) { - return InternalJava9StreamUtil.dropWhile(stream, predicate); - } - - /** - * Delegates an IntStream::takeWhile operation to the Java platforms - * underlying default Stream implementation. If run under Java 8, this - * method will throw an UnsupportedOperationException. - * - * @param stream to apply the takeWhile operation to - * @param predicate to use for takeWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the takeWhile(predicate) has been applied - */ - public static IntStream takeWhile(IntStream stream, IntPredicate predicate) { - return InternalJava9StreamUtil.takeWhile(stream, predicate); - } - - /** - * Delegates an InteStream::dropWhile operation to the Java platforms - * underlying default Stream implementation. If run under Java 8, this - * method will throw an UnsupportedOperationException. - * - * @param stream to apply the dropWhile operation to - * @param predicate to use for dropWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the dropWhile(predicate) has been applied - */ - public static IntStream dropWhile(IntStream stream, IntPredicate predicate) { - return InternalJava9StreamUtil.takeWhile(stream, predicate); - } - - /** - * Delegates a LongStream::takeWhile operation to the Java platforms - * underlying default Stream implementation. If run under Java 8, this - * method will throw an UnsupportedOperationException. - * - * @param stream to apply the takeWhile operation to - * @param predicate to use for takeWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the takeWhile(predicate) has been applied - */ - public static LongStream takeWhile(LongStream stream, LongPredicate predicate) { - return InternalJava9StreamUtil.takeWhile(stream, predicate); - } - - /** - * Delegates a LongStream::dropWhile operation to the Java platforms - * underlying default Stream implementation. If run under Java 8, this - * method will throw an UnsupportedOperationException. - * - * @param stream to apply the dropWhile operation to - * @param predicate to use for dropWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the dropWhile(predicate) has been applied - */ - public static LongStream dropWhile(LongStream stream, LongPredicate predicate) { - return InternalJava9StreamUtil.dropWhile(stream, predicate); - } - - /** - * Delegates a Stream::takeWhile operation to the Java platforms underlying - * default Stream implementation. If run under Java 8, this method will - * throw an UnsupportedOperationException. - * - * @param Element type in the Stream - * @param stream to apply the takeWhile operation to - * @param predicate to use for takeWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the takeWhile(predicate) has been applied - */ - public static Stream takeWhile(Stream stream, Predicate predicate) { - return InternalJava9StreamUtil.takeWhile(stream, predicate); - } - - /** - * Delegates a Stream::dropWhile operation to the Java platforms underlying - * default Stream implementation. If run under Java 8, this method will - * throw an UnsupportedOperationException. - * - * @param Element type in the Stream - * @param stream to apply the dropWhile operation to - * @param predicate to use for dropWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the dropWhile(predicate) has been applied - */ - public static Stream dropWhile(Stream stream, Predicate predicate) { - return InternalJava9StreamUtil.dropWhile(stream, predicate); - } - -} diff --git a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/internal/InternalJava9StreamUtil.java b/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/internal/InternalJava9StreamUtil.java deleted file mode 100644 index c9633055..00000000 --- a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/internal/InternalJava9StreamUtil.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * JPAstreamer - Express JPA queries with Java Streams - * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * - * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE - */ -package com.speedment.jpastreamer.javanine.internal; - -import com.speedment.jpastreamer.exception.JPAStreamerException; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.util.function.DoublePredicate; -import java.util.function.IntPredicate; -import java.util.function.LongPredicate; -import java.util.function.Predicate; -import java.util.stream.DoubleStream; -import java.util.stream.IntStream; -import java.util.stream.LongStream; -import java.util.stream.Stream; - -import static java.util.Objects.requireNonNull; - -/** - * - * @author Per Minborg - */ -public final class InternalJava9StreamUtil { - - private InternalJava9StreamUtil() {} - - private static final String TAKE_WHILE = "takeWhile"; - private static final String DROP_WHILE = "dropWhile"; - private static final String FILTER = "filter"; - - private static final MethodType DOUBLE_METHOD_TYPE = MethodType.methodType(DoubleStream.class, DoublePredicate.class); - private static final MethodHandle DOUBLE_TAKE_WHILE_METHOD_HANDLE - = createMethodHandle(TAKE_WHILE, DoubleStream.class, DOUBLE_METHOD_TYPE); - - private static final MethodHandle DOUBLE_DROP_WHILE_METHOD_HANDLE - = createMethodHandle(DROP_WHILE, DoubleStream.class, DOUBLE_METHOD_TYPE); - - static final MethodHandle DOUBLE_FILTER_METHOD_HANDLE - = createMethodHandle(FILTER, DoubleStream.class, DOUBLE_METHOD_TYPE); // Just for Java 8 testing - - private static final MethodType INT_METHOD_TYPE = MethodType.methodType(IntStream.class, IntPredicate.class); - private static final MethodHandle INT_TAKE_WHILE_METHOD_HANDLE - = createMethodHandle(TAKE_WHILE, IntStream.class, INT_METHOD_TYPE); - private static final MethodHandle INT_DROP_WHILE_METHOD_HANDLE - = createMethodHandle(DROP_WHILE, IntStream.class, INT_METHOD_TYPE); - static final MethodHandle INT_FILTER_METHOD_HANDLE - = createMethodHandle(FILTER, IntStream.class, INT_METHOD_TYPE); // Just for Java 8 testing - - private static final MethodType LONG_METHOD_TYPE = MethodType.methodType(LongStream.class, LongPredicate.class); - private static final MethodHandle LONG_TAKE_WHILE_METHOD_HANDLE - = createMethodHandle(TAKE_WHILE, LongStream.class, LONG_METHOD_TYPE); - private static final MethodHandle LONG_DROP_WHILE_METHOD_HANDLE - = createMethodHandle(DROP_WHILE, LongStream.class, LONG_METHOD_TYPE); - static final MethodHandle LONG_FILTER_METHOD_HANDLE - = createMethodHandle(FILTER, LongStream.class, LONG_METHOD_TYPE); // Just for Java 8 testing - - private static final MethodType METHOD_TYPE - = MethodType.methodType(Stream.class, Predicate.class); - private static final MethodHandle TAKE_WHILE_METHOD_HANDLE - = createMethodHandle(TAKE_WHILE, Stream.class, METHOD_TYPE); - private static final MethodHandle DROP_WHILE_METHOD_HANDLE - = createMethodHandle(DROP_WHILE, Stream.class, METHOD_TYPE); - static final MethodHandle FILTER_METHOD_HANDLE - = createMethodHandle(FILTER, Stream.class, METHOD_TYPE); // Just for Java 8 testing - - /** - * Delegates a DoubleStream::takeWhile operation to the Java platforms - * underlying default Stream implementation. If run under Java 8, this - * method will throw an UnsupportedOperationException. - * - * @param stream to apply the takeWhile operation to - * @param predicate to use for takeWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the takeWhile(predicate) has been applied - */ - @SuppressWarnings("unchecked") - public static DoubleStream takeWhile(DoubleStream stream, DoublePredicate predicate) { - requireNonNull(stream); - requireNonNull(predicate); - if (DOUBLE_TAKE_WHILE_METHOD_HANDLE == null) { - throw newUnsupportedOperationException(TAKE_WHILE); - } - try { - final Object obj = DOUBLE_TAKE_WHILE_METHOD_HANDLE.invoke(stream, predicate); - return (DoubleStream) obj; - } catch (Throwable t) { - throw new JPAStreamerException(t); - } - } - - /** - * Delegates a DoubleStream::dropWhile operation to the Java platforms - * underlying default Stream implementation. If run under Java 8, this - * method will throw an UnsupportedOperationException. - * - * @param stream to apply the dropWhile operation to - * @param predicate to use for dropWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the dropWhile(predicate) has been applied - */ - public static DoubleStream dropWhile(DoubleStream stream, DoublePredicate predicate) { - requireNonNull(stream); - requireNonNull(predicate); - if (DOUBLE_DROP_WHILE_METHOD_HANDLE == null) { - throw newUnsupportedOperationException(DROP_WHILE); - } - try { - final Object obj = DOUBLE_DROP_WHILE_METHOD_HANDLE.invoke(stream, predicate); - return (DoubleStream) obj; - } catch (Throwable t) { - throw new JPAStreamerException(t); - } - } - - // just for Java 8 testing - static DoubleStream filter(DoubleStream stream, DoublePredicate predicate) { - requireNonNull(stream); - requireNonNull(predicate); - try { - return (DoubleStream) DOUBLE_FILTER_METHOD_HANDLE.invoke(stream, predicate); - } catch (Throwable t) { - throw new JPAStreamerException(t); - } - } - - /** - * Delegates an IntStream::takeWhile operation to the Java platforms - * underlying default Stream implementation. If run under Java 8, this - * method will throw an UnsupportedOperationException. - * - * @param stream to apply the takeWhile operation to - * @param predicate to use for takeWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the takeWhile(predicate) has been applied - */ - public static IntStream takeWhile(IntStream stream, IntPredicate predicate) { - requireNonNull(stream); - requireNonNull(predicate); - if (INT_TAKE_WHILE_METHOD_HANDLE == null) { - throw newUnsupportedOperationException(TAKE_WHILE); - } - try { - final Object obj = INT_TAKE_WHILE_METHOD_HANDLE.invoke(stream, predicate); - return (IntStream) obj; - } catch (Throwable t) { - throw new JPAStreamerException(t); - } - } - - /** - * Delegates an InteStream::dropWhile operation to the Java platforms - * underlying default Stream implementation. If run under Java 8, this - * method will throw an UnsupportedOperationException. - * - * @param stream to apply the dropWhile operation to - * @param predicate to use for dropWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the dropWhile(predicate) has been applied - */ - public static IntStream dropWhile(IntStream stream, IntPredicate predicate) { - requireNonNull(stream); - requireNonNull(predicate); - if (INT_DROP_WHILE_METHOD_HANDLE == null) { - throw newUnsupportedOperationException(DROP_WHILE); - } - try { - final Object obj = INT_DROP_WHILE_METHOD_HANDLE.invoke(stream, predicate); - return (IntStream) obj; - } catch (Throwable t) { - throw new JPAStreamerException(t); - } - } - - // just for Java 8 testing - static IntStream filter(IntStream stream, IntPredicate predicate) { - requireNonNull(stream); - requireNonNull(predicate); - try { - return (IntStream) INT_FILTER_METHOD_HANDLE.invoke(stream, predicate); - } catch (Throwable t) { - throw new JPAStreamerException(t); - } - } - - /** - * Delegates a LongStream::takeWhile operation to the Java platforms - * underlying default Stream implementation. If run under Java 8, this - * method will throw an UnsupportedOperationException. - * - * @param stream to apply the takeWhile operation to - * @param predicate to use for takeWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the takeWhile(predicate) has been applied - */ - public static LongStream takeWhile(LongStream stream, LongPredicate predicate) { - requireNonNull(stream); - requireNonNull(predicate); - if (LONG_TAKE_WHILE_METHOD_HANDLE == null) { - throw newUnsupportedOperationException(TAKE_WHILE); - } - try { - final Object obj = LONG_TAKE_WHILE_METHOD_HANDLE.invoke(stream, predicate); - return (LongStream) obj; - } catch (Throwable t) { - throw new JPAStreamerException(t); - } - } - - /** - * Delegates a LongStream::dropWhile operation to the Java platforms - * underlying default Stream implementation. If run under Java 8, this - * method will throw an UnsupportedOperationException. - * - * @param stream to apply the dropWhile operation to - * @param predicate to use for dropWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the dropWhile(predicate) has been applied - */ - public static LongStream dropWhile(LongStream stream, LongPredicate predicate) { - requireNonNull(stream); - requireNonNull(predicate); - if (LONG_DROP_WHILE_METHOD_HANDLE == null) { - throw newUnsupportedOperationException(DROP_WHILE); - } - try { - final Object obj = LONG_DROP_WHILE_METHOD_HANDLE.invoke(stream, predicate); - return (LongStream) obj; - } catch (Throwable t) { - throw new JPAStreamerException(t); - } - } - - // just for Java 8 testing - static LongStream filter(LongStream stream, LongPredicate predicate) { - requireNonNull(stream); - requireNonNull(predicate); - try { - return (LongStream) LONG_FILTER_METHOD_HANDLE.invoke(stream, predicate); - } catch (Throwable t) { - throw new JPAStreamerException(t); - } - } - - /** - * Delegates a Stream::takeWhile operation to the Java platforms underlying - * default Stream implementation. If run under Java 8, this method will - * throw an UnsupportedOperationException. - * - * @param Element type in the Stream - * @param stream to apply the takeWhile operation to - * @param predicate to use for takeWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the takeWhile(predicate) has been applied - */ - @SuppressWarnings("unchecked") - public static Stream takeWhile(Stream stream, Predicate predicate) { - requireNonNull(stream); - requireNonNull(predicate); - if (TAKE_WHILE_METHOD_HANDLE == null) { - throw newUnsupportedOperationException(TAKE_WHILE); - } - try { - final Object obj = TAKE_WHILE_METHOD_HANDLE.invoke(stream, predicate); - return (Stream) obj; - } catch (Throwable t) { - throw new JPAStreamerException(t); - } - } - - /** - * Delegates a Stream::dropWhile operation to the Java platforms underlying - * default Stream implementation. If run under Java 8, this method will - * throw an UnsupportedOperationException. - * - * @param Element type in the Stream - * @param stream to apply the dropWhile operation to - * @param predicate to use for dropWhile - * @throws UnsupportedOperationException if run under Java 8 - * @return a Stream where the dropWhile(predicate) has been applied - */ - @SuppressWarnings("unchecked") - public static Stream dropWhile(Stream stream, Predicate predicate) { - requireNonNull(stream); - requireNonNull(predicate); - if (DROP_WHILE_METHOD_HANDLE == null) { - throw newUnsupportedOperationException(DROP_WHILE); - } - try { - final Object obj = DROP_WHILE_METHOD_HANDLE.invoke(stream, predicate); - return (Stream) obj; - } catch (Throwable t) { - throw new JPAStreamerException(t); - } - } - - // just for Java 8 testing - static Stream filter(Stream stream, Predicate predicate) { - requireNonNull(stream); - requireNonNull(predicate); - try { - @SuppressWarnings("unchecked") - final Stream s = (Stream) FILTER_METHOD_HANDLE.invoke(stream, predicate); - return s; - } catch (Throwable t) { - throw new JPAStreamerException(t); - } - } - - private static MethodHandle createMethodHandle(String methodName, Class refc, MethodType methodType) { - final MethodHandles.Lookup lookup = MethodHandles.lookup(); - try { - return lookup.findVirtual(refc, methodName, methodType); - } catch (IllegalAccessException | NoSuchMethodException e) { - // We are running under Java 8 - return null; - } - } - - private static UnsupportedOperationException newUnsupportedOperationException(String methodName) { - return new UnsupportedOperationException("Stream::" + methodName + " is not supported by this Java version. Use Java 9 or greater."); - } - -} diff --git a/jpastreamer.javanine/pom.xml b/jpastreamer.javasixteen/pom.xml similarity index 96% rename from jpastreamer.javanine/pom.xml rename to jpastreamer.javasixteen/pom.xml index bf29099b..0323e558 100644 --- a/jpastreamer.javanine/pom.xml +++ b/jpastreamer.javasixteen/pom.xml @@ -23,7 +23,7 @@ 4.0.0 - javanine + javasixteen Java9 diff --git a/jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/Java16StreamAdditions.java b/jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/Java16StreamAdditions.java new file mode 100644 index 00000000..ed84ef14 --- /dev/null +++ b/jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/Java16StreamAdditions.java @@ -0,0 +1,38 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ +package com.speedment.jpastreamer.javasixteen; + +import java.util.List; +import java.util.function.*; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; +import java.util.stream.LongStream; +import java.util.stream.Stream; + +/** + * + * @author Per Minborg, Julia Gustafsson + */ +public interface Java16StreamAdditions { + + List toList(Stream stream); + + Stream mapMulti(Stream stream, BiConsumer> mapper); + + IntStream mapMultiToInt(Stream stream, BiConsumer mapper); + + DoubleStream mapMultiToDouble(Stream stream, BiConsumer mapper); + + LongStream mapMultiToLong(Stream stream, BiConsumer mapper); + +} diff --git a/jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/Java16StreamUtil.java b/jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/Java16StreamUtil.java new file mode 100644 index 00000000..0b584cb8 --- /dev/null +++ b/jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/Java16StreamUtil.java @@ -0,0 +1,108 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ +package com.speedment.jpastreamer.javasixteen; + +import com.speedment.jpastreamer.javasixteen.internal.InternalJava16StreamUtil; + +import java.util.List; +import java.util.function.*; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; +import java.util.stream.LongStream; +import java.util.stream.Stream; + +/** + * + * @author Per Minborg, Julia Gustafsson + */ +public final class Java16StreamUtil { + + private Java16StreamUtil() {} + + /** + * Delegates a Stream::toList operation to the Java platforms + * underlying default Stream implementation. If run under Java 15 or prior, this + * method will throw an UnsupportedOperationException. + * + * @param Element type in the Stream + * @param stream to apply the toList operation to + * @throws UnsupportedOperationException if run under Java 15 or prior + * @return a List containing the stream elements + */ + public static List toList(Stream stream) { + return InternalJava16StreamUtil.toList(stream); + } + + /** + * Delegates a Stream::mapMulti operation to the Java platforms + * underlying default Stream implementation. If run under Java 15 or prior, this + * method will throw an UnsupportedOperationException. + * + * @param The element type in the source Stream + * @param The element type of the new Stream + * @param stream to apply the mapMulti operation to + * @param mapper a non-interfering, stateless function that generates replacement elements + * @throws UnsupportedOperationException if run under Java 15 or prior + * @return the new Stream + */ + public static Stream mapMulti(Stream stream, BiConsumer> mapper) { + return InternalJava16StreamUtil.mapMulti(stream, mapper); + } + + /** + * Delegates a Stream::mapMultiToInt operation to the Java platforms + * underlying default Stream implementation. If run under Java 15 or prior, this + * method will throw an UnsupportedOperationException. + * + * @param The element type in the source Stream + * @param stream to apply the mapMultiToInt operation to + * @param mapper a non-interfering, stateless function that generates replacement elements + * @throws UnsupportedOperationException if run under Java 15 or prior + * @return the new Stream + */ + public static IntStream mapMultiToInt(Stream stream, BiConsumer mapper) { + return InternalJava16StreamUtil.mapMultiToInt(stream, mapper); + } + + /** + * Delegates a Stream::mapMultiToDouble operation to the Java platforms + * underlying default Stream implementation. If run under Java 15 or prior, this + * method will throw an UnsupportedOperationException. + * + * @param The element type in the source Stream + * @param stream to apply the mapMultiToDouble operation to + * @param mapper a non-interfering, stateless function that generates replacement elements + * @throws UnsupportedOperationException if run under Java 15 or prior + * @return the new Stream + */ + public static DoubleStream mapMultiToDouble(Stream stream, BiConsumer mapper) { + return InternalJava16StreamUtil.mapMultiToDouble(stream, mapper); + } + + /** + * Delegates a Stream::mapMultiToLong operation to the Java platforms + * underlying default Stream implementation. If run under Java 15 or prior, this + * method will throw an UnsupportedOperationException. + * + * @param The element type in the source Stream + * @param stream to apply the mapMultiToLong operation to + * @param mapper a non-interfering, stateless function that generates replacement elements + * @throws UnsupportedOperationException if run under Java 15 or prior + * @return the new Stream + */ + public static LongStream mapMultiToLong(Stream stream, BiConsumer mapper) { + return InternalJava16StreamUtil.mapMultiToLong(stream, mapper); + } + + +} diff --git a/jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/internal/InternalJava16StreamUtil.java b/jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/internal/InternalJava16StreamUtil.java new file mode 100644 index 00000000..ffb6ae7c --- /dev/null +++ b/jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/internal/InternalJava16StreamUtil.java @@ -0,0 +1,154 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ +package com.speedment.jpastreamer.javasixteen.internal; + +import com.speedment.jpastreamer.exception.JPAStreamerException; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; +import java.util.List; +import java.util.function.*; +import java.util.stream.DoubleStream; +import java.util.stream.IntStream; +import java.util.stream.LongStream; +import java.util.stream.Stream; + +import static java.util.Objects.requireNonNull; + +/** + * + * @author Per Minborg, Julia Gustafsson + */ +public final class InternalJava16StreamUtil { + + private InternalJava16StreamUtil() {} + + private static final String TO_LIST = "toList"; + private static final String MAP_MULTI = "mapMulti"; + private static final String MAP_MULTI_TO_INT = "mapMultiToInt"; + private static final String MAP_MULTI_TO_LONG = "mapMultiToLong"; + private static final String MAP_MULTI_TO_DOUBLE = "mapMultiToDouble"; + + // mapMulti() + private static final MethodType MAP_MULTI_DOUBLE_METHOD_TYPE = + MethodType.methodType(DoubleStream.class, BiConsumer.class); + static final MethodHandle MAP_MULTI_DOUBLE_HANDLE = + createMethodHandle(MAP_MULTI_TO_DOUBLE, Stream.class, MAP_MULTI_DOUBLE_METHOD_TYPE); + + private static final MethodType MAP_MULTI_LONG_METHOD_TYPE = + MethodType.methodType(LongStream.class, BiConsumer.class); + static final MethodHandle MAP_MULTI_LONG_HANDLE = + createMethodHandle(MAP_MULTI_TO_LONG, Stream.class, MAP_MULTI_LONG_METHOD_TYPE); + + private static final MethodType MAP_MULTI_INT_METHOD_TYPE = + MethodType.methodType(IntStream.class, BiConsumer.class); + static final MethodHandle MAP_MULTI_INT_HANDLE = + createMethodHandle(MAP_MULTI_TO_INT, Stream.class, MAP_MULTI_INT_METHOD_TYPE); + + private static final MethodType MAP_MULTI_METHOD_TYPE = + MethodType.methodType(Stream.class, BiConsumer.class); + private static final MethodHandle MAP_MULTI_METHOD_HANDLE = + createMethodHandle(MAP_MULTI, Stream.class, MAP_MULTI_METHOD_TYPE); + + // toList() + private static final MethodType TO_LIST_METHOD_TYPE = + MethodType.methodType(List.class); + private static final MethodHandle TO_LIST_METHOD_HANDLE = + createMethodHandle(TO_LIST, Stream.class, TO_LIST_METHOD_TYPE); + + @SuppressWarnings("unchecked") + public static List toList(Stream stream) { + requireNonNull(stream); + if (TO_LIST_METHOD_HANDLE == null) { + throw newUnsupportedOperationException(TO_LIST); + } + try { + final Object obj = TO_LIST_METHOD_HANDLE.invoke(stream); + return (List) obj; + } catch (Throwable t) { + throw new JPAStreamerException(t); + } + } + @SuppressWarnings("unchecked") + public static Stream mapMulti(Stream stream, BiConsumer> mapper) { + requireNonNull(stream); + requireNonNull(mapper); + if (MAP_MULTI_METHOD_HANDLE == null) { + throw newUnsupportedOperationException(MAP_MULTI); + } + try { + final Object obj = MAP_MULTI_METHOD_HANDLE.invoke(stream, mapper); + return (Stream) obj; + } catch (Throwable t) { + throw new JPAStreamerException(t); + } + } + @SuppressWarnings("unchecked") + public static IntStream mapMultiToInt(Stream stream, BiConsumer mapper) { + requireNonNull(stream); + requireNonNull(mapper); + if (MAP_MULTI_INT_HANDLE == null) { + throw newUnsupportedOperationException(MAP_MULTI); + } + try { + final Object obj = MAP_MULTI_INT_HANDLE.invoke(stream, mapper); + return (IntStream) obj; + } catch (Throwable t) { + throw new JPAStreamerException(t); + } + } + @SuppressWarnings("unchecked") + public static DoubleStream mapMultiToDouble(Stream stream, BiConsumer mapper) { + requireNonNull(stream); + requireNonNull(mapper); + if (MAP_MULTI_DOUBLE_HANDLE == null) { + throw newUnsupportedOperationException(MAP_MULTI); + } + try { + final Object obj = MAP_MULTI_DOUBLE_HANDLE.invoke(stream, mapper); + return (DoubleStream) obj; + } catch (Throwable t) { + throw new JPAStreamerException(t); + } + } + @SuppressWarnings("unchecked") + public static LongStream mapMultiToLong(Stream stream, BiConsumer mapper) { + requireNonNull(stream); + requireNonNull(mapper); + if (MAP_MULTI_LONG_HANDLE == null) { + throw newUnsupportedOperationException(MAP_MULTI); + } + try { + final Object obj = MAP_MULTI_LONG_HANDLE.invoke(stream, mapper); + return (LongStream) obj; + } catch (Throwable t) { + throw new JPAStreamerException(t); + } + } + + private static MethodHandle createMethodHandle(String methodName, Class refc, MethodType methodType) { + final MethodHandles.Lookup lookup = MethodHandles.lookup(); + try { + return lookup.findVirtual(refc, methodName, methodType); + } catch (IllegalAccessException | NoSuchMethodException e) { + // We are running under Java 15 or prior + return null; + } + } + + private static UnsupportedOperationException newUnsupportedOperationException(String methodName) { + return new UnsupportedOperationException("Stream::" + methodName + " is not supported by this Java version. Use Java 16 or greater."); + } + +} diff --git a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/package-info.java b/jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/package-info.java similarity index 88% rename from jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/package-info.java rename to jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/package-info.java index 4de66dd7..d093e411 100644 --- a/jpastreamer.javanine/src/main/java/com/speedment/jpastreamer/javanine/package-info.java +++ b/jpastreamer.javasixteen/src/main/java/com/speedment/jpastreamer/javasixteen/package-info.java @@ -13,9 +13,9 @@ */ /** - * This package contains java9 classes. + * This package contains Java 16 classes. *

* This package is part of the API. Modifications to classes here should only * (if ever) be done in major releases. */ -package com.speedment.jpastreamer.javanine; +package com.speedment.jpastreamer.javasixteen; diff --git a/jpastreamer.javanine/src/main/java/module-info.java b/jpastreamer.javasixteen/src/main/java/module-info.java similarity index 87% rename from jpastreamer.javanine/src/main/java/module-info.java rename to jpastreamer.javasixteen/src/main/java/module-info.java index 45201c5c..9ebf5662 100644 --- a/jpastreamer.javanine/src/main/java/module-info.java +++ b/jpastreamer.javasixteen/src/main/java/module-info.java @@ -10,9 +10,8 @@ * * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE */ -module jpastreamer.javanine { +module jpastreamer.javasixteen { requires jpastreamer.exception; - exports com.speedment.jpastreamer.javanine; - + exports com.speedment.jpastreamer.javasixteen; } diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml b/jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml index c66e03f5..8e34f7de 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/pom.xml @@ -39,7 +39,7 @@ com.speedment.jpastreamer - javanine + javasixteen diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingDoubleStream.java b/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingDoubleStream.java index 627ad986..fee70cd8 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingDoubleStream.java +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingDoubleStream.java @@ -12,9 +12,6 @@ */ package com.speedment.jpastreamer.autoclose.standard.internal; -import com.speedment.jpastreamer.javanine.Java9DoubleStreamAdditions; -import com.speedment.jpastreamer.javanine.Java9StreamUtil; - import java.util.DoubleSummaryStatistics; import java.util.OptionalDouble; import java.util.PrimitiveIterator; @@ -38,7 +35,7 @@ */ final class AutoClosingDoubleStream extends AbstractAutoClosingBaseStream - implements DoubleStream, Java9DoubleStreamAdditions { + implements DoubleStream { AutoClosingDoubleStream(final DoubleStream stream) { this(stream, Boolean.getBoolean("jpastreamer.allowiteratorandspliterator")); @@ -108,12 +105,12 @@ public DoubleStream skip(long n) { @Override public DoubleStream takeWhile(DoublePredicate predicate) { - return wrap(Java9StreamUtil.takeWhile(stream(), predicate)); + return wrap(stream().takeWhile(predicate)); } @Override public DoubleStream dropWhile(DoublePredicate predicate) { - return wrap(Java9StreamUtil.dropWhile(stream(), predicate)); + return wrap(stream().dropWhile(predicate)); } @Override diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingIntStream.java b/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingIntStream.java index b88aed7e..6983ebde 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingIntStream.java +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingIntStream.java @@ -12,9 +12,6 @@ */ package com.speedment.jpastreamer.autoclose.standard.internal; -import com.speedment.jpastreamer.javanine.Java9IntStreamAdditions; -import com.speedment.jpastreamer.javanine.Java9StreamUtil; - import java.util.*; import java.util.function.*; import java.util.stream.DoubleStream; @@ -35,7 +32,7 @@ */ final class AutoClosingIntStream extends AbstractAutoClosingBaseStream - implements IntStream, Java9IntStreamAdditions { + implements IntStream { AutoClosingIntStream(final IntStream stream) { this(stream, Boolean.getBoolean("jpastreamer.allowiteratorandspliterator")); @@ -105,12 +102,12 @@ public IntStream skip(long n) { @Override public IntStream takeWhile(IntPredicate predicate) { - return wrap(Java9StreamUtil.takeWhile(stream(), predicate)); + return wrap(stream().takeWhile(predicate)); } @Override public IntStream dropWhile(IntPredicate predicate) { - return wrap(Java9StreamUtil.dropWhile(stream(), predicate)); + return wrap(stream().dropWhile(predicate)); } @Override diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingLongStream.java b/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingLongStream.java index e3ffaba0..34586ab6 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingLongStream.java +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingLongStream.java @@ -12,9 +12,6 @@ */ package com.speedment.jpastreamer.autoclose.standard.internal; -import com.speedment.jpastreamer.javanine.Java9LongStreamAdditions; -import com.speedment.jpastreamer.javanine.Java9StreamUtil; - import java.util.*; import java.util.function.*; import java.util.stream.DoubleStream; @@ -35,7 +32,7 @@ */ final class AutoClosingLongStream extends AbstractAutoClosingBaseStream - implements LongStream, Java9LongStreamAdditions { + implements LongStream { AutoClosingLongStream(final LongStream stream) { this(stream, Boolean.getBoolean("jpastreamer.allowiteratorandspliterator")); @@ -105,12 +102,12 @@ public LongStream skip(long n) { @Override public LongStream takeWhile(LongPredicate predicate) { - return wrap(Java9StreamUtil.takeWhile(stream(), predicate)); + return wrap(stream().takeWhile(predicate)); } @Override public LongStream dropWhile(LongPredicate predicate) { - return wrap(Java9StreamUtil.dropWhile(stream(), predicate)); + return wrap(stream().dropWhile(predicate)); } @Override diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingStream.java b/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingStream.java index 39c70dbf..2340a7a1 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingStream.java +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingStream.java @@ -12,13 +12,10 @@ */ package com.speedment.jpastreamer.autoclose.standard.internal; -import com.speedment.jpastreamer.javanine.Java9StreamAdditions; -import com.speedment.jpastreamer.javanine.Java9StreamUtil; +import com.speedment.jpastreamer.javasixteen.Java16StreamAdditions; +import com.speedment.jpastreamer.javasixteen.Java16StreamUtil; -import java.util.Comparator; -import java.util.Iterator; -import java.util.Optional; -import java.util.Spliterator; +import java.util.*; import java.util.function.*; import java.util.stream.*; @@ -32,11 +29,12 @@ * allowStreamIteratorAndSpliterator flag * * @param Stream type + * @param The new Stream type * @author Per Minborg */ -final class AutoClosingStream +final class AutoClosingStream extends AbstractAutoClosingBaseStream> - implements Stream, Java9StreamAdditions { + implements Stream, Java16StreamAdditions { AutoClosingStream(final Stream stream) { this(stream, Boolean.getBoolean("jpastreamer.allowiteratorandspliterator")); @@ -126,12 +124,12 @@ public Stream skip(long n) { @Override public Stream takeWhile(Predicate predicate) { - return wrap(Java9StreamUtil.takeWhile(stream(), predicate)); + return wrap(stream().takeWhile(predicate)); } @Override public Stream dropWhile(Predicate predicate) { - return wrap(Java9StreamUtil.dropWhile(stream(), predicate)); + return wrap(stream().dropWhile(predicate)); } @Override @@ -260,4 +258,28 @@ public Stream onClose(Runnable closeHandler) { return wrap(stream().onClose(closeHandler)); } + @Override + public List toList(Stream stream) { + return finallyClose(() -> Java16StreamUtil.toList(stream)); + } + + @Override + public Stream mapMulti(Stream stream, BiConsumer> mapper) { + return wrap(Java16StreamUtil.mapMulti(stream, mapper)); + } + + @Override + public IntStream mapMultiToInt(Stream stream, BiConsumer mapper) { + return wrap(Java16StreamUtil.mapMultiToInt(stream, mapper)); + } + + @Override + public DoubleStream mapMultiToDouble(Stream stream, BiConsumer mapper) { + return wrap(Java16StreamUtil.mapMultiToDouble(stream, mapper)); + } + + @Override + public LongStream mapMultiToLong(Stream stream, BiConsumer mapper) { + return wrap(Java16StreamUtil.mapMultiToLong(stream, mapper)); + } } diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/module-info.java b/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/module-info.java index a8cca3b7..9461c618 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/module-info.java +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/src/main/java/module-info.java @@ -15,7 +15,7 @@ */ module jpastreamer.autoclose.standard { requires transitive jpastreamer.autoclose; - requires jpastreamer.javanine; + requires jpastreamer.javasixteen; exports com.speedment.jpastreamer.autoclose.standard; diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AbstractAutoClosingStreamTest.java b/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AbstractAutoClosingStreamTest.java index 9145703e..0e385dee 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AbstractAutoClosingStreamTest.java +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AbstractAutoClosingStreamTest.java @@ -19,10 +19,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiPredicate; import java.util.function.Function; -import java.util.function.IntPredicate; import java.util.function.UnaryOperator; import java.util.stream.BaseStream; -import java.util.stream.IntStream; import java.util.stream.Stream; import static java.util.stream.Collectors.toList; diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingDoubleStreamTest.java b/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingDoubleStreamTest.java index 088d81f4..9014c212 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingDoubleStreamTest.java +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingDoubleStreamTest.java @@ -12,17 +12,15 @@ */ package com.speedment.jpastreamer.autoclose.standard.internal; -import com.speedment.jpastreamer.javanine.Java9StreamUtil; +import com.speedment.jpastreamer.javasixteen.Java16StreamUtil; import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.function.DoublePredicate; -import java.util.function.LongPredicate; import java.util.stream.DoubleStream; import java.util.stream.IntStream; -import java.util.stream.LongStream; import java.util.stream.Stream; import static java.util.stream.Collectors.toList; @@ -113,14 +111,14 @@ void skip() { @Test void takeWhile() { - testIntermediate(s -> Java9StreamUtil.takeWhile(s, i -> i < 3)); + testIntermediate(s -> s.takeWhile(i -> i < 3)); } - + @Test void dropWhile() { - testIntermediate(s -> Java9StreamUtil.dropWhile(s, i -> i < 3)); + testIntermediate(s -> s.dropWhile(i -> i < 3)); } - + @Test void forEach() { final AtomicInteger cnt = new AtomicInteger(); diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingIntStreamTest.java b/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingIntStreamTest.java index 066428f5..b056dabd 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingIntStreamTest.java +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingIntStreamTest.java @@ -12,7 +12,7 @@ */ package com.speedment.jpastreamer.autoclose.standard.internal; -import com.speedment.jpastreamer.javanine.Java9StreamUtil; +import com.speedment.jpastreamer.javasixteen.Java16StreamUtil; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -109,12 +109,12 @@ void skip() { @Test void takeWhile() { - testIntermediate(s -> Java9StreamUtil.takeWhile(s, i -> i < 3)); + testIntermediate(s -> s.takeWhile(i -> i < 3)); } @Test void dropWhile() { - testIntermediate(s -> Java9StreamUtil.dropWhile(s, i -> i < 3)); + testIntermediate(s -> s.dropWhile(i -> i < 3)); } @Test @@ -216,4 +216,5 @@ void asLongStream() { void asDoubleStream() { testTerminal(s -> s.asDoubleStream().boxed().collect(toList())); } + } diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingLongStreamTest.java b/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingLongStreamTest.java index 42ee5cf2..a22527d1 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingLongStreamTest.java +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingLongStreamTest.java @@ -12,7 +12,6 @@ */ package com.speedment.jpastreamer.autoclose.standard.internal; -import com.speedment.jpastreamer.javanine.Java9StreamUtil; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -111,12 +110,12 @@ void skip() { @Test void takeWhile() { - testIntermediate(s -> Java9StreamUtil.takeWhile(s, i -> i < 3)); + testIntermediate(s -> s.takeWhile(i -> i < 3)); } @Test void dropWhile() { - testIntermediate(s -> Java9StreamUtil.dropWhile(s, i -> i < 3)); + testIntermediate(s -> s.dropWhile(i -> i < 3)); } @Test diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingStreamTest.java b/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingStreamTest.java index 2176569d..a7cbb5e2 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingStreamTest.java +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingStreamTest.java @@ -12,16 +12,16 @@ */ package com.speedment.jpastreamer.autoclose.standard.internal; -import com.speedment.jpastreamer.javanine.Java9StreamUtil; +import com.speedment.jpastreamer.javasixteen.Java16StreamUtil; import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Predicate; +import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; -import static java.util.stream.Collectors.toList; import static org.junit.jupiter.api.Assertions.assertEquals; final class AutoClosingStreamTest extends AbstractAutoClosingStreamTest> { @@ -60,17 +60,17 @@ void map() { @Test void mapToInt() { - testTerminal(s -> s.mapToInt(i -> i + 1).boxed().collect(toList())); + testTerminal(s -> s.mapToInt(i -> i + 1).boxed().collect(Collectors.toList())); } @Test void mapToLong() { - testTerminal(s -> s.mapToLong(i -> i + 1).boxed().collect(toList())); + testTerminal(s -> s.mapToLong(i -> i + 1).boxed().collect(Collectors.toList())); } @Test void mapToDouble() { - testTerminal(s -> s.mapToDouble(i -> i + 1).boxed().collect(toList())); + testTerminal(s -> s.mapToDouble(i -> i + 1).boxed().collect(Collectors.toList())); } @Test @@ -109,12 +109,12 @@ void skip() { @Test void takeWhile() { - testIntermediate(s -> Java9StreamUtil.takeWhile(s, i -> i < 3)); + testIntermediate(s -> s.takeWhile(i -> i < 3)); } @Test void dropWhile() { - testIntermediate(s -> Java9StreamUtil.dropWhile(s, i -> i < 3)); + testIntermediate(s -> s.dropWhile(i -> i < 3)); } @Test @@ -182,4 +182,35 @@ void findAny() { testTerminal(Stream::findAny); } + @Test + void toList() { testTerminal(Java16StreamUtil::toList); } + + @Test + void mapMulti() { testIntermediate(s -> Java16StreamUtil.mapMulti(s, ((i, mapper) -> { + if (EVEN.test(i)) { + mapper.accept(i); + } + }))); } + + @Test + void mapMultiToInt() { testTerminal(s -> Java16StreamUtil.mapMultiToDouble(s, ((i, mapper) -> { + if (EVEN.test(i)) { + mapper.accept(i); + } + })).boxed().collect(Collectors.toList())); } + + @Test + void mapMultiToDouble() { testTerminal(s -> Java16StreamUtil.mapMultiToDouble(s, ((i, mapper) -> { + if (EVEN.test(i)) { + mapper.accept(i); + } + })).boxed().collect(Collectors.toList())); } + + @Test + void mapMultiToLong() { testTerminal(s -> Java16StreamUtil.mapMultiToLong(s, ((i, mapper) -> { + if (EVEN.test(i)) { + mapper.accept(i); + } + })).boxed().collect(Collectors.toList())); } + } diff --git a/jpastreamer.provider/jpastreamer.builder.standard/pom.xml b/jpastreamer.provider/jpastreamer.builder.standard/pom.xml index 23dbc3be..7c1e8230 100644 --- a/jpastreamer.provider/jpastreamer.builder.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.builder.standard/pom.xml @@ -59,7 +59,7 @@ com.speedment.jpastreamer - javanine + javasixteen diff --git a/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/com/speedment/jpastreamer/builder/standard/internal/DoubleStreamBuilder.java b/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/com/speedment/jpastreamer/builder/standard/internal/DoubleStreamBuilder.java index 67efcf39..6ee61ce4 100644 --- a/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/com/speedment/jpastreamer/builder/standard/internal/DoubleStreamBuilder.java +++ b/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/com/speedment/jpastreamer/builder/standard/internal/DoubleStreamBuilder.java @@ -12,7 +12,6 @@ */ package com.speedment.jpastreamer.builder.standard.internal; -import com.speedment.jpastreamer.javanine.Java9DoubleStreamAdditions; import com.speedment.jpastreamer.pipeline.intermediate.DoubleIntermediateOperationFactory; import com.speedment.jpastreamer.pipeline.terminal.DoubleTerminalOperationFactory; @@ -28,7 +27,7 @@ final class DoubleStreamBuilder extends BaseStreamBuilder - implements DoubleStream, Java9DoubleStreamAdditions { + implements DoubleStream { DoubleStreamBuilder(final BaseBuilderState baseState) { super(baseState); diff --git a/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/com/speedment/jpastreamer/builder/standard/internal/IntStreamBuilder.java b/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/com/speedment/jpastreamer/builder/standard/internal/IntStreamBuilder.java index 9c3c01bb..9f4962e0 100644 --- a/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/com/speedment/jpastreamer/builder/standard/internal/IntStreamBuilder.java +++ b/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/com/speedment/jpastreamer/builder/standard/internal/IntStreamBuilder.java @@ -12,7 +12,6 @@ */ package com.speedment.jpastreamer.builder.standard.internal; -import com.speedment.jpastreamer.javanine.Java9IntStreamAdditions; import com.speedment.jpastreamer.pipeline.intermediate.IntIntermediateOperationFactory; import com.speedment.jpastreamer.pipeline.terminal.IntTerminalOperationFactory; @@ -25,7 +24,7 @@ final class IntStreamBuilder extends BaseStreamBuilder - implements IntStream, Java9IntStreamAdditions { + implements IntStream { IntStreamBuilder(final BaseBuilderState baseState) { super(baseState); diff --git a/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/com/speedment/jpastreamer/builder/standard/internal/LongStreamBuilder.java b/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/com/speedment/jpastreamer/builder/standard/internal/LongStreamBuilder.java index cbd9d2b5..825692a3 100644 --- a/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/com/speedment/jpastreamer/builder/standard/internal/LongStreamBuilder.java +++ b/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/com/speedment/jpastreamer/builder/standard/internal/LongStreamBuilder.java @@ -12,7 +12,6 @@ */ package com.speedment.jpastreamer.builder.standard.internal; -import com.speedment.jpastreamer.javanine.Java9LongStreamAdditions; import com.speedment.jpastreamer.pipeline.intermediate.LongIntermediateOperationFactory; import com.speedment.jpastreamer.pipeline.terminal.LongTerminalOperationFactory; @@ -25,7 +24,7 @@ final class LongStreamBuilder extends BaseStreamBuilder - implements LongStream, Java9LongStreamAdditions { + implements LongStream { LongStreamBuilder(final BaseBuilderState baseState) { super(baseState); diff --git a/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/module-info.java b/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/module-info.java index 5bd5640a..d94a5bf4 100644 --- a/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/module-info.java +++ b/jpastreamer.provider/jpastreamer.builder.standard/src/main/java/module-info.java @@ -38,7 +38,7 @@ requires transitive jpastreamer.builder; requires jpastreamer.rootfactory; requires jpastreamer.autoclose; - requires jpastreamer.javanine; + requires jpastreamer.javasixteen; exports com.speedment.jpastreamer.builder.standard; diff --git a/jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml b/jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml index 4d6e359b..58fb36be 100644 --- a/jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml +++ b/jpastreamer.provider/jpastreamer.pipeline.standard/pom.xml @@ -39,7 +39,7 @@ com.speedment.jpastreamer - javanine + javasixteen diff --git a/pom.xml b/pom.xml index 0f3e4163..6ae615a5 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ jpastreamer.rootfactory jpastreamer.field jpastreamer.application - jpastreamer.javanine + jpastreamer.javasixteen jpastreamer.autoclose jpastreamer.pipeline jpastreamer.builder @@ -938,7 +938,7 @@ com.speedment.jpastreamer - javanine + javasixteen ${jpa-streamer.version} From 5633faa3c28c353e547e3c9927c97b3ffd08e1d6 Mon Sep 17 00:00:00 2001 From: Julia Gustafsson Date: Wed, 30 Aug 2023 12:39:55 +0200 Subject: [PATCH 13/16] Document toList() and mapMulti()-operations --- .../pages/intermediate_operations.adoc | 329 +++++++++++------- .../pages/terminal_operations.adoc | 189 +++++----- 2 files changed, 297 insertions(+), 221 deletions(-) diff --git a/docs/modules/stream-fundamentals/pages/intermediate_operations.adoc b/docs/modules/stream-fundamentals/pages/intermediate_operations.adoc index a14e8781..2a3da26f 100644 --- a/docs/modules/stream-fundamentals/pages/intermediate_operations.adoc +++ b/docs/modules/stream-fundamentals/pages/intermediate_operations.adoc @@ -16,108 +16,108 @@ The following intermediate operations are accepted by a `Stream`: |========================================================== | Operation | Parameter | Returns a `Stream` that: -| `filter` | `Predicate` | contains only the elements that match the `Predicate` -| `map` | `Function` | contains the results of applying the given `Function` to the elements of this stream -| `distinct` | - | contains the distinct (i.e. unique) elements in the stream as per the element's `equals()` method -| `sorted` | - | contains the elements in the stream in sorted order as per the element's `compareTo()` method -| `sorted` | `Comparator` | contains the elements in the stream in sorted order as per the given `Comparator` -| `limit` | `long` | contains the original elements in the stream but truncated to be no longer than the given `long` value -| `skip` | `long` | contains the original elements in the stream but after discarding the given `long` value of elements -| `flatMap` | `Function` | contains the elements of the `Stream`s in this stream obtained by applying the given `Function` to the stream elements of this stream -| `peek` | `Consumer` | contains the original elements in the stream but additionally letting the given `Consumer` accept each element (side effect) +| `filter` | `Predicate` | Contains only the elements that match the `Predicate` +| `map` | `Function` | Contains the results of applying the given `Function` to the elements of this stream +| `distinct` | - | Contains the distinct (i.e. unique) elements in the stream as per the element's `equals()` method +| `sorted` | - | Contains the elements in the stream in sorted order as per the element's `compareTo()` method +| `sorted` | `Comparator` | Contains the elements in the stream in sorted order as per the given `Comparator` +| `limit` | `long` | Contains the original elements in the stream but truncated to be no longer than the given `long` value +| `skip` | `long` | Contains the original elements in the stream but after discarding the given `long` value of elements +| `flatMap` | `Function` | Contains the elements of the `Stream`s in this stream obtained by applying the given `Function` to the stream elements of this stream +| `peek` | `Consumer` | Contains the original elements in the stream but additionally letting the given `Consumer` accept each element (side effect) |========================================================== Below are examples that demonstrate how these operations can be applied. -=== filter +=== filter() [source, java] ---- - Stream.of("B", "A", "C" , "B") - .filter(s -> s.equals("B")) +Stream.of("B", "A", "C" , "B") + .filter(s -> s.equals("B")) ---- -returns a `Stream` with the elements "B" and "B" because only elements that are equal to "B" will pass the `filter` operation. +Returns a `Stream` with the elements "B" and "B" because only elements that are equal to "B" will pass the `filter` operation. -=== map +=== map() [source, java] ---- - Stream.of("B", "A", "C" , "B") - .map(s -> s.toLowerCase()) +Stream.of("B", "A", "C" , "B") + .map(s -> s.toLowerCase()) ---- -returns a `Stream` with the elements "b", "a", "c" and "b" because each element will be mapped (converted) to its lower case representation. +Returns a `Stream` with the elements "b", "a", "c" and "b" because each element will be mapped (converted) to its lower case representation. -=== distinct +=== distinct() [source, java] ---- - Stream.of("B", "A", "C" , "B") - .distinct() +Stream.of("B", "A", "C" , "B") + .distinct() ---- -returns a `Stream` with the elements "B", "A" and "C" because only unique elements will pass the `distinct` operation. +Returns a `Stream` with the elements "B", "A" and "C" because only unique elements will pass the `distinct` operation. -=== sorted +=== sorted() [source, java] ---- - Stream.of("B", "A", "C" , "B") - .sorted() +Stream.of("B", "A", "C" , "B") + .sorted() ---- -returns a `Stream` with the elements "A", "B", "B" and "C" because the `sort` operation will sort all elements in the stream in natural order. +Returns a `Stream` with the elements "A", "B", "B" and "C" because the `sort` operation will sort all elements in the stream in natural order. [source,java] ---- - Stream.of("B", "A", "C" , "B") - .sorted(Comparator.reverseOrder()) +Stream.of("B", "A", "C" , "B") + .sorted(Comparator.reverseOrder()) ---- -returns a `Stream` with the elements "C", "B", "B" and "A" because the `sort` operation will sort all elements in the stream according to the provided `Comparator` (in reversed natural order). +Returns a `Stream` with the elements "C", "B", "B" and "A" because the `sort` operation will sort all elements in the stream according to the provided `Comparator` (in reversed natural order). -=== limit +=== limit() [source,java] ---- - Stream.of("B", "A", "C" , "B") - .limit(2) +Stream.of("B", "A", "C" , "B") + .limit(2) ---- -returns a `Stream` with the elements "B" and "A" because after the two first elements the rest of the elements will be discarded. +Returns a `Stream` with the elements "B" and "A" because after the two first elements the rest of the elements will be discarded. -=== skip +=== skip() [source,java] ---- - Stream.of("B", "A", "C" , "B") - .skip(1) +Stream.of("B", "A", "C" , "B") + .skip(1) ---- -returns a `Stream` with the elements "A", "C" and "B" because the first element in the stream will be skipped. +Returns a `Stream` with the elements "A", "C" and "B" because the first element in the stream will be skipped. -=== flatMap +=== flatMap() [source,java] ---- - Stream.of( - Stream.of("B", "A"), - Stream.of("C", "B") - ) - .flatMap(Function.identity()) - .forEachOrdered(System.out::println); +Stream.of( + Stream.of("B", "A"), + Stream.of("C", "B") +) + .flatMap(Function.identity()) + .forEachOrdered(System.out::println); ---- -returns a `Stream` with the elements "B", "A", "C" and "B" because the two streams (that each contain two elements) are "flattened" to a single `Stream` with four elements. +Returns a `Stream` with the elements "B", "A", "C" and "B" because the two streams (that each contain two elements) are "flattened" to a single `Stream` with four elements. [source,java] ---- - Stream.of( - Arrays.asList("B", "A"), - Arrays.asList("C", "B") - ) - .flatMap(l -> l.stream()) +Stream.of( + Arrays.asList("B", "A"), + Arrays.asList("C", "B") +) + .flatMap(l -> l.stream()) ---- -returns a `Stream` with the elements "B", "A", "C" and "B" because the two lists (that each contain two elements) are "flattened" to a single `Stream` with four elements. The lists are converted to sub-streams using the `List::stream` mapper method. +Returns a `Stream` with the elements "B", "A", "C" and "B" because the two lists (that each contain two elements) are "flattened" to a single `Stream` with four elements. The lists are converted to sub-streams using the `List::stream` mapper method. -=== peek +=== peek() [source,java] ---- - Stream.of("B", "A", "C" , "B") - .peek(System.out::print) +Stream.of("B", "A", "C" , "B") + .peek(System.out::print) ---- -returns a `Stream` with the elements "B", "A", "C" and "B" but, when consumed in its entirety, will print out the text "BACB" as a side effect. +Returns a `Stream` with the elements "B", "A", "C" and "B" but, when consumed in its entirety, will print out the text "BACB" as a side effect. NOTE: Side-effect usage is discouraged in Streams. Use this operation for debug only. @@ -134,42 +134,42 @@ There are also a number of intermediate operations that controls the properties | `onClose` | `Runnable` | will run the provided `Runnable` when closed |============= -=== parallel +=== parallel() [source,java] ---- - Stream.of("B", "A", "C" , "B") - .parallel() +Stream.of("B", "A", "C" , "B") + .parallel() ---- -returns a `Stream` with the elements "B", "A", "C" and "B" but, when consumed, elements in the `Stream` may be propagated through the pipeline using different `Threads. By default, parallel streams are executed on the default `ForkJoinPool`. +Returns a `Stream` with the elements "B", "A", "C" and "B" but, when consumed, elements in the `Stream` may be propagated through the pipeline using different `Threads. By default, parallel streams are executed on the default `ForkJoinPool`. -=== sequential +=== sequential() [source,java] ---- - Stream.of("B", "A", "C" , "B") - .parallel() - .sequential() +Stream.of("B", "A", "C" , "B") + .parallel() + .sequential() ---- -returns a `Stream` with the elements "B", "A", "C" and "B" that is not parallel. +Returns a `Stream` with the elements "B", "A", "C" and "B" that is not parallel. -=== unordered +=== unordered() [source,java] ---- - Stream.of("B", "A", "C" , "B") - .unordered() +Stream.of("B", "A", "C" , "B") + .unordered() ---- -returns a `Stream` with the given elements but not necessary in any particular order. So when consumed, elements might be encountered in any order, for example in the order "C", "B", "B", "A". Note that `unordered` is just a relaxation of the stream requirements. Unordered streams can retain their original element order or elements can appear in any other order. +Returns a `Stream` with the given elements but not necessary in any particular order. So when consumed, elements might be encountered in any order, for example in the order "C", "B", "B", "A". Note that `unordered` is just a relaxation of the stream requirements. Unordered streams can retain their original element order or elements can appear in any other order. -=== onClose +=== onClose() [source,java] ---- - Stream.of("B", "A", "C", "B") - .onClose( () -> System.out.println("The Stream was closed") ); +Stream.of("B", "A", "C", "B") + .onClose( () -> System.out.println("The Stream was closed") ); ---- -is a `Stream` with the elements "B", "A", "C" and "B" but, when closed, will print out the text "The Stream was closed". +Is a `Stream` with the elements "B", "A", "C" and "B" but, when closed, will print out the text "The Stream was closed". == Map to Primitive Operations There are also some intermediate operations that maps a `Stream` to one of the special primitive stream types; `IntStrem`, `LongStream` and `DoubleStream`: @@ -177,77 +177,145 @@ There are also some intermediate operations that maps a `Stream` to one of the s [width="100%", cols="3", options="header"] |============= | Operation | Parameter | Returns a `Stream` that: -| `mapToInt` | `ToIntFunction` | is an `IntStream` containing `int` elements obtained by applying the given `ToIntFunction` to the elements of this stream -| `mapToLong` | `ToLongFunction` | is a `LongStream` containing `long` elements obtained by applying the given `ToLongFunction` to the elements of this stream -| `mapToDouble` | `ToDoubleFunction` | is a `DoubleStream` containing `double` elements obtained by applying the given `ToDoubleFunction` to the elements of this stream -| `flatMapToInt` | `Function` | contains the `int` elements of the `IntStream`s in this stream obtained by applying the given `Function` to the stream elements of this stream -| `flatMapToLong` | `Function` | contains the `long` elements of the `LongStream`s in this stream obtained by applying the given `Function` to the stream elements of this stream -| `flatMapToDouble` | `Function` | contains the `double` elements of the `DoubleStream`s in this stream obtained by applying the given `Function` to the stream elements of this stream +| `mapToInt` | `ToIntFunction` | Is an `IntStream` containing `int` elements obtained by applying the given `ToIntFunction` to the elements of this stream +| `mapToLong` | `ToLongFunction` | Is a `LongStream` containing `long` elements obtained by applying the given `ToLongFunction` to the elements of this stream +| `mapToDouble` | `ToDoubleFunction` | Is a `DoubleStream` containing `double` elements obtained by applying the given `ToDoubleFunction` to the elements of this stream +| `flatMapToInt` | `Function` | Contains the `int` elements of the `IntStream`s in this stream obtained by applying the given `Function` to the stream elements of this stream +| `flatMapToLong` | `Function` | Contains the `long` elements of the `LongStream`s in this stream obtained by applying the given `Function` to the stream elements of this stream +| `flatMapToDouble` | `Function` | Contains the `double` elements of the `DoubleStream`s in this stream obtained by applying the given `Function` to the stream elements of this stream |============= NOTE: In many cases, primitive streams provide better performance but can only handle streams of: `int`, `long` and `double`. -=== mapToInt +=== mapToInt() [source,java] ---- - Stream.of("B", "A", "C" , "B") - .mapToInt(s -> s.hashCode()) +Stream.of("B", "A", "C" , "B") + .mapToInt(s -> s.hashCode()) ---- -returns an `IntStream` with the `int` elements 66, 65, 67 and 66. (A is 65, B is 66 and so on) +Returns an `IntStream` with the `int` elements 66, 65, 67 and 66. (A is 65, B is 66 and so on) -=== mapToLong +=== mapToLong() [source,java] ---- - Stream.of("B", "A", "C", "B") - .mapToLong(s -> s.hashCode() * 1_000_000_000_000l) +Stream.of("B", "A", "C", "B") + .mapToLong(s -> s.hashCode() * 1_000_000_000_000l) ---- -returns a `LongStream` with the `long` elements 66000000000000, 65000000000000, 67000000000000 and 66000000000000. +Returns a `LongStream` with the `long` elements 66000000000000, 65000000000000, 67000000000000 and 66000000000000. -=== mapToDouble +=== mapToDouble() [source,java] ---- - Stream.of("B", "A", "C", "B") - .mapToDouble(s -> s.hashCode() / 10.0) +Stream.of("B", "A", "C", "B") + .mapToDouble(s -> s.hashCode() / 10.0) ---- -returns a `DoubleStream` with the `double` elements 6.6, 6.5, 6.7 and 6.6. +Returns a `DoubleStream` with the `double` elements 6.6, 6.5, 6.7 and 6.6. === flatMapToInt [source,java] ---- - Stream.of( - IntStream.of(1, 2), - IntStream.of(3, 4) - ) - .flatMapToInt(s -> s.map(i -> i + 1)) +Stream.of( + IntStream.of(1, 2), + IntStream.of(3, 4) +) + .flatMapToInt(s -> s.map(i -> i + 1)) ---- -returns an `IntStream` with the `int` elements 2, 3, 4 and 5 because the two `IntStream`s where flattened to one stream whereby 1 was added to each element. +Returns an `IntStream` with the `int` elements 2, 3, 4 and 5 because the two `IntStream`s where flattened to one stream whereby 1 was added to each element. -=== flatMapToLong +=== flatMapToLong() [source,java] ---- - Stream.of( - LongStream.of(1, 2), - LongStream.of(3, 4) - ) - .flatMapToLong(s -> s.map(i -> i + 1)) +Stream.of( + LongStream.of(1, 2), + LongStream.of(3, 4) +) + .flatMapToLong(s -> s.map(i -> i + 1)) ---- -returns a `LongStream` with the `long` elements 2, 3, 4 and 5 because the two `LongStreams` where flattened to one stream whereby 1 was added to each element. +Returns a `LongStream` with the `long` elements 2, 3, 4 and 5 because the two `LongStreams` where flattened to one stream whereby 1 was added to each element. -=== flatMapToDouble +=== flatMapToDouble() [source,java] ---- - Stream.of( - DoubleStream.of(1.0, 2.0), - DoubleStream.of(3.0, 4.0) - ) - .flatMapToDouble(s -> s.map(i -> i + 1)) +Stream.of( + DoubleStream.of(1.0, 2.0), + DoubleStream.of(3.0, 4.0) +) + .flatMapToDouble(s -> s.map(i -> i + 1)) ---- -returns a `DoubleStream` with the `double` elements 2.0, 3.0, 4.0 and 5.0 because the two `DoubleStream`s where flattened to one stream whereby 1 was added to each element. +Returns a `DoubleStream` with the `double` elements 2.0, 3.0, 4.0 and 5.0 because the two `DoubleStream`s where flattened to one stream whereby 1 was added to each element. + +== Map Multi Operations (Java 16 Only) +Java 16 introduced several new map operations, expanding the capabilities of Streams. The `mapMulti()` function enables the mapping of a single element within the Stream to zero or multiple elements, contingent on specific conditions. + +[width="100%", cols="3", options="header"] +|============= +| Operation | Parameter | Returns a `Stream` that: +| `mapMulti` | `BiConsumer` | Returns a stream consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements. +| `mapMultiToDouble` | `BiConsumer` | Returns a `DoubleStream` consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements. +| `mapMultiToInt` | `BiConsumer` | Returns an `IntStream` +consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements. +| `mapMultiToLong` | `BiConsumer` | Returns a `LongStream` consisting of the results of replacing each element of this stream with multiple elements, specifically zero or more elements. + +|============= + +WARNING: These operations are only available in applications running Java 16 or later. + +=== mapMulti() +[source,java] +---- +Stream.of(1.0, 2.0, 3.0, 4.0, 5.0) + .mapMulti((i, mapper) -> { + if (i % 2 == 0) { + mapper.accept(i); + mapper.accept(i); + } + }); +---- +Returns a `Stream` with the elements [2.0, 2.0, 4.0, 4.0] because the even elements were duplicated by accepting them twice. + +=== mapMultiToDouble() +[source,java] +---- +Stream.of(1.0, 2.0, 3.0, 4.0, 5.0) + .mapMulti((i, mapper) -> { + if (i % 2 == 0) { + mapper.accept(i); + mapper.accept(i); + } + }); +---- +Returns an `DoubleStream` with the elements [2.0, 2.0, 4.0, 4.0] because the even elements were duplicated by accepting them twice. + +=== mapMultiToInt() +[source,java] +---- +Stream.of(1, 2, 3, 4, 5) + .mapMulti((i, mapper) -> { + if (i % 2 == 0) { + mapper.accept(i); + mapper.accept(i); + } + }); +---- +Returns an `IntStream` with the elements [2, 2, 4, 4] because the even elements were duplicated by accepting them twice. + +=== mapMultiToLong() +[source,java] +---- +Stream.of(1.0, 2.0, 3.0, 4.0, 5.0) + .mapMulti((i, mapper) -> { + if (i % 2 == 0) { + mapper.accept(i.longValue()); + mapper.accept(i.longValue()); + } + }); +---- +Returns an `LongStream` with the elements [2, 2, 4, 4] because the even elements were duplicated by accepting them twice. == Primitive Operations Primitive streams (like `IntStream` and `LongStream`) provide similar functionality as ordinary streams but usually the parameter count and types differ so that primitive streams can accept more optimized function variants. @@ -261,58 +329,57 @@ Here is a table of some additional *Intermediate Operations* that primitive Stre | `asDoubleStream` | - | contains the elements in the original stream converted to `double` elements |============= -=== boxed +=== boxed() [source,java] ---- - IntStream.of(1, 2, 3, 4) - .boxed() +IntStream.of(1, 2, 3, 4) + .boxed() ---- returns a `Stream` with the `Integer` elements 1, 2, 3 and 4 because the original `int` elements were boxed to their corresponding `Integer` elements. -=== asLongStream +=== asLongStream() [source,java] ---- - IntStream.of(1, 2, 3, 4) - .asLongStream() +IntStream.of(1, 2, 3, 4) + .asLongStream() ---- returns a `LongStream` with the `long` elements 1, 2, 3 and 4 because the original `int` elements were converted to `long` elements. -=== asDoubleStream +=== asDoubleStream() [source,java] ---- - IntStream.of(1, 2, 3, 4) - .asDoubleStream() +IntStream.of(1, 2, 3, 4) + .asDoubleStream() ---- returns a `DoubleStream` with the `double` elements 1.0, 2.0, 3.0 and 4.0 because the original `int` elements were converted to `double` elements. - -== Java 9 Operations -Two new intermediate operations were introduced in Java 9. Since these methods were added to the `Stream` interface with default implementations, these methods can be used by any `Stream` implementation written in either Java 8 or Java 9. +== Selective Operations +Two stream operations exist for capturing or omitting elements within the stream until a particular condition is satisfied. Unlike a filter, these operations discontinue predicate evaluation once it turns true for the first time. [width="100%", cols="3", options="header"] |============= | Operation | Parameter | Returns a `Stream` that: -| `takeWhile` | `Predicate` | contains the elements in the original stream until the the first one fails the `Predicate` test -| `dropWhile` | `Predicate` | contains the elements in the original stream dropping all elements until the the first one fails the `Predicate` test then containing the rest of the elements +| `takeWhile` | `Predicate` | Contains the elements in the original stream until the the first one fails the `Predicate` test +| `dropWhile` | `Predicate` | Contains the elements in the original stream dropping all elements until the the first one fails the `Predicate` test then containing the rest of the elements |============= -=== takeWhile (Java 9 only) +=== takeWhile() [source,java] ---- - Stream.of("B", "A", "C", "B") - .takeWhile(s -> "B".compareTo(s) >= 0) +Stream.of("B", "A", "C", "B") + .takeWhile(s -> "B".compareTo(s) >= 0) ---- -returns a `Stream` with the elements "B" and "A" because when "C" is encountered in the `Stream`, that element and all following are dropped. +Returns a `Stream` with the elements "B" and "A" because when "C" is encountered in the `Stream`, that element and all following are dropped. -=== dropWhile (Java 9 only) +=== dropWhile() [source,java] ---- - Stream.of("B", "A", "C", "B") - .dropWhile(s -> "B".compareTo(s) >= 0) +Stream.of("B", "A", "C", "B") + .dropWhile(s -> "B".compareTo(s) >= 0) ---- -returns a `Stream` with the elements "C" and "B" because elements are dropped from the `Stream` but when "C" in encountered, subsequent elements are not dropped. \ No newline at end of file +Returns a `Stream` with the elements "C" and "B" because elements are dropped from the `Stream` but when "C" in encountered, subsequent elements are not dropped. diff --git a/docs/modules/stream-fundamentals/pages/terminal_operations.adoc b/docs/modules/stream-fundamentals/pages/terminal_operations.adoc index e42fce36..b5077be9 100644 --- a/docs/modules/stream-fundamentals/pages/terminal_operations.adoc +++ b/docs/modules/stream-fundamentals/pages/terminal_operations.adoc @@ -28,176 +28,187 @@ The following terminal operations are accepted by a `Stream`: | `findAny` | - | Returns any element in this stream (if any) | `toArray` | - | Returns an array containing all the elements in this stream | `toArray` | `IntFunction` | Returns an array containing all the elements in this stream whereby the array is created using the provided `IntFunction` +| `toList` | - | Returns a list containing all the elements in this stream |========================================================== -=== forEach +=== forEach() [source,java] ---- - Stream.of("B", "A", "C" , "B") - .forEach(System.out::print); +Stream.of("B", "A", "C" , "B") + .forEach(System.out::print); ---- might output "CBBA". However, there is no guarantee of a particular order using `forEach`. Despite this, most `Stream` implementations actually _would_ output "BACB". -=== forEachOrdered +=== forEachOrdered() [source,java] ---- - Stream.of("B", "A", "C" , "B") - .forEachOrdered(System.out::print); +Stream.of("B", "A", "C" , "B") + .forEachOrdered(System.out::print); ---- *always* outputs "BACB" (as opposed to `forEach`). -=== collect +=== collect() [source,java] ---- - Stream.of("B", "A", "C" , "B") - .collect(Collectors.toList()); +Stream.of("B", "A", "C" , "B") + .collect(Collectors.toList()); ---- returns a `List` equal to ["B", "A", "C", "B"] [source,java] ---- - Stream.of("B", "A", "C" , "B") - .collect(Collectors.toSet()); +Stream.of("B", "A", "C" , "B") + .collect(Collectors.toSet()); ---- returns a `Set` equal to ["A", "B", "C"] [source,java] ---- - Stream.of("I", "am", "a", "stream") - .collect(Collectors.toMap( - s -> s.toLowerCase(), // Key extractor - s -> s.length()) // Value extractor - ) +Stream.of("I", "am", "a", "stream") + .collect(Collectors.toMap( + s -> s.toLowerCase(), // Key extractor + s -> s.length()) // Value extractor + ) ---- returns a `Map` equal to {a=1, stream=6, i=1, am=2}. Thus, the `Map` contains a mapping from a word (key) to how many characters that word has (value). -=== min +=== min() [source,java] ---- - Stream.of("B", "A", "C" , "B") - .min(String::compareTo); +Stream.of("B", "A", "C" , "B") + .min(String::compareTo); ---- returns `Optional[A]` because "A" is the smallest element in the stream. [source,java] ---- - Stream.empty() - .min(String::compareTo); +Stream.empty() + .min(String::compareTo); ---- returns `Optional.empty` because there is no min value because the stream is empty. -=== max +=== max() [source,java] ---- - Stream.of("B", "A", "C" , "B") - .max(String::compareTo); +Stream.of("B", "A", "C" , "B") + .max(String::compareTo); ---- returns `Optional[C]` because "C" is the largest element in the stream. [source,java] ---- - Stream.empty() - .max(String::compareTo); +Stream.empty() + .max(String::compareTo); ---- returns `Optional.empty` because there is no max value because the stream is empty. -=== count +=== count() [source,java] -----a - Stream.of("B", "A", "C" , "B") - .count(); +---- +Stream.of("B", "A", "C" , "B") + .count(); ---- returns 4 because there are four elements in the stream. [source,java] -----a - Stream.empty() - .count(); +---- +Stream.empty() + .count(); ---- returns 0 because there are no elements in an empty stream. -=== anyMatch +=== anyMatch() [source,java] ---- - Stream.of("B", "A", "C", "B") - .anyMatch("A"::equals); +Stream.of("B", "A", "C", "B") + .anyMatch("A"::equals); ---- returns `true` because there is an "A" element in the stream. [source,java] ---- - Stream.of("B", "A", "C", "B") - .anyMatch("Z"::equals); +Stream.of("B", "A", "C", "B") + .anyMatch("Z"::equals); ---- returns `false` because there are no "Z" elements in the stream. -=== noneMatch +=== noneMatch() [source,java] ---- - Stream.of("B", "A", "C", "B") - .noneMatch("A"::equals); +Stream.of("B", "A", "C", "B") + .noneMatch("A"::equals); ---- returns `false` because there is an "A" element in the stream. [source,java] ---- - Stream.of("B", "A", "C", "B") - .noneMatch("Z"::equals); +Stream.of("B", "A", "C", "B") + .noneMatch("Z"::equals); ---- returns `true` because there are no "Z" elements in the stream. -=== findFirst +=== findFirst() [source,java] ---- - Stream.of("B", "A", "C", "B") - .findFirst(); +Stream.of("B", "A", "C", "B") + .findFirst(); ---- returns `Optional[B]` because "B" is the first element in the stream. [source,java] ---- - Stream.empty() - .findFirst(); +Stream.empty() + .findFirst(); ---- returns `Optional.empty` because the stream is empty. -=== findAny +=== findAny() [source,java] ---- - Stream.of("B", "A", "C", "B") - .findAny(); +Stream.of("B", "A", "C", "B") + .findAny(); ---- might return `Optional[C]` or any other element in the stream. [source,java] ---- - Stream.empty() - .findAny(); +Stream.empty() + .findAny(); ---- returns `Optional.empty` because the stream is empty. -=== toArray +=== toArray() [source,java] ---- - Stream.of("B", "A", "C", "B") - .toArray(); +Stream.of("B", "A", "C", "B") + .toArray(); ---- Returns an array containing [B, A, C, B] created automatically by the `toArray` operator. [source,java] ---- - Stream.of("B", "A", "C", "B") - .toArray(String[]::new) +Stream.of("B", "A", "C", "B") + .toArray(String[]::new) ---- Returns an array containing [B, A, C, B] that will be created by the provided constructor, for example using the equivalent to `new String[4]`. +=== toList() +[source,java] +---- +Stream.of("B", "A", "C", "B") + .toList(); +---- +Returns a `List` containing [B, A, C, B]. + +WARNING: Use of this method requires Java 16 or later. + == Less Common Operations Here is a list of other terminal operations that are a bit less commonly used by at least some programmers: @@ -217,58 +228,56 @@ Here is a list of other terminal operations that are a bit less commonly used by [source,java] ---- - Stream.of("B", "A", "C", "B") - .collect( - () -> new StringBuilder(), - (sb0, sb1) -> sb0.append(sb1), - (sb0, sb1) -> sb0.append(sb1) - ) +Stream.of("B", "A", "C", "B") + .collect( + () -> new StringBuilder(), + (sb0, sb1) -> sb0.append(sb1), + (sb0, sb1) -> sb0.append(sb1) + ); ---- returns a `StringBuilder` containing "BACB" that will be created by the provided supplier and then built up by the append-lambdas. -=== reduce +=== reduce() [source,java] ---- - Stream.of(1, 2, 3, 4) - .reduce((a, b) -> a + b) +Stream.of(1, 2, 3, 4) + .reduce((a, b) -> a + b); ---- returns the value of `Optional[10]` because 10 is the sum of all `Integer` elements in the `Stream`. If the `Stream` is empty, `Optional.empty()` is returned. [source,java] ---- - Stream.of(1, 2, 3, 4) - .reduce(100, (a, b) -> a + b) +Stream.of(1, 2, 3, 4) + .reduce(100, (a, b) -> a + b); ---- returns the value of 110 since all the `Integer` elements in the `Stream` are added to the `Integer` 100. If the `Stream` is empty, 100 is returned. [source,java] ---- - Stream.of(1, 2, 3, 4) - .parallel() - .reduce( +Stream.of(1, 2, 3, 4) + .parallel() + .reduce( 0, (a, b) -> a + b, (a, b) -> a + b - ) + ); ---- returns the value of 10 since this example simply adds all the `Integer` elements in the `Stream` beginning with 0. The `Stream` can be executed in parallel whereby the last lambda will be used to combine results from each thread. If the `Stream` is empty, 0 is returned. -=== iterator +=== iterator() [source,java] ---- - Iterator iterator - = Stream.of("B", "A", "C", "B") - .iterator(); +Iterator iterator = Stream.of("B", "A", "C", "B") + .iterator(); ---- creates a new `Iterator` over all the elements in the `Stream`. -=== spliterator +=== spliterator() [source,java] ---- - Spliterator spliterator - = Stream.of("B", "A", "C", "B") - .spliterator(); +Spliterator spliterator = Stream.of("B", "A", "C", "B") + .spliterator(); ---- creates a new `Spliterator` over all the elements in the `Stream`. @@ -285,29 +294,29 @@ Here is a list of terminal operations that are available *only* for primitive st | `summaryStatistics`| - | Returns a reduction of the elements which is a summary of a number of statistic measurements (min, max, sum, average and count) |========================================================== -=== sum +=== sum() [source,java] ---- - IntStream.of(1, 2, 3, 4) - .sum() +IntStream.of(1, 2, 3, 4) + .sum(); ---- returns 10 because 10 is the sum of all elements in the `Stream`. -=== average +=== average() [source,java] ---- - IntStream.of(1, 2, 3, 4) - .average() +IntStream.of(1, 2, 3, 4) + .average(); ---- returns `OptionalDouble[2.5]` because 2.5 is the average of all elements in the `Stream`. If the `Stream` is empty, `OptionalDouble.empty()` is returned. -=== summaryStatistics +=== summaryStatistics() [source,java] ---- - IntStream.of(1, 2, 3, 4) - .summaryStatistics() +IntStream.of(1, 2, 3, 4) + .summaryStatistics(); ---- returns `IntSummaryStatistics{count=4, sum=10, min=1, average=2.500000, max=4}`. From 17050cd12e8b61ab6f7d31aace3c04174096e6a8 Mon Sep 17 00:00:00 2001 From: Julia Gustafsson Date: Wed, 30 Aug 2023 12:40:12 +0200 Subject: [PATCH 14/16] Improve tests of mapMulti() --- .../internal/AutoClosingStreamTest.java | 50 +++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingStreamTest.java b/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingStreamTest.java index a7cbb5e2..7be8b161 100644 --- a/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingStreamTest.java +++ b/jpastreamer.provider/jpastreamer.autoclose.standard/src/test/java/com/speedment/jpastreamer/autoclose/standard/internal/AutoClosingStreamTest.java @@ -14,6 +14,8 @@ import com.speedment.jpastreamer.javasixteen.Java16StreamUtil; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledForJreRange; +import org.junit.jupiter.api.condition.JRE; import java.util.Arrays; import java.util.concurrent.atomic.AtomicInteger; @@ -23,6 +25,7 @@ import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; final class AutoClosingStreamTest extends AbstractAutoClosingStreamTest> { @@ -183,9 +186,11 @@ void findAny() { } @Test + @EnabledForJreRange(min = JRE.JAVA_16) void toList() { testTerminal(Java16StreamUtil::toList); } @Test + @EnabledForJreRange(min = JRE.JAVA_16) void mapMulti() { testIntermediate(s -> Java16StreamUtil.mapMulti(s, ((i, mapper) -> { if (EVEN.test(i)) { mapper.accept(i); @@ -193,24 +198,63 @@ void mapMulti() { testIntermediate(s -> Java16StreamUtil.mapMulti(s, ((i, mapper }))); } @Test - void mapMultiToInt() { testTerminal(s -> Java16StreamUtil.mapMultiToDouble(s, ((i, mapper) -> { + @EnabledForJreRange(min = JRE.JAVA_16) + void mapMultiToInt16() { testTerminal(s -> Java16StreamUtil.mapMultiToInt(s, ((i, mapper) -> { if (EVEN.test(i)) { mapper.accept(i); } })).boxed().collect(Collectors.toList())); } + + @Test + @EnabledForJreRange(max = JRE.JAVA_15) + void mapMultiToInt() { + Exception exception = assertThrows(UnsupportedOperationException.class, () -> { + testTerminal(s -> Java16StreamUtil.mapMultiToInt(s, ((i, mapper) -> { + if (EVEN.test(i)) { + mapper.accept(i); + } + })).boxed().collect(Collectors.toList())); + }); + } @Test - void mapMultiToDouble() { testTerminal(s -> Java16StreamUtil.mapMultiToDouble(s, ((i, mapper) -> { + @EnabledForJreRange(min = JRE.JAVA_16) + void mapMultiToDouble16() { testTerminal(s -> Java16StreamUtil.mapMultiToDouble(s, ((i, mapper) -> { if (EVEN.test(i)) { mapper.accept(i); } })).boxed().collect(Collectors.toList())); } @Test - void mapMultiToLong() { testTerminal(s -> Java16StreamUtil.mapMultiToLong(s, ((i, mapper) -> { + @EnabledForJreRange(max = JRE.JAVA_15) + void mapMultiToDouble() { + Exception exception = assertThrows(UnsupportedOperationException.class, () -> { + testTerminal(s -> Java16StreamUtil.mapMultiToDouble(s, ((i, mapper) -> { + if (EVEN.test(i)) { + mapper.accept(i); + } + })).boxed().collect(Collectors.toList())); + }); + } + + @Test + @EnabledForJreRange(min = JRE.JAVA_16) + void mapMultiToLong16() { testTerminal(s -> Java16StreamUtil.mapMultiToLong(s, ((i, mapper) -> { if (EVEN.test(i)) { mapper.accept(i); } })).boxed().collect(Collectors.toList())); } + @Test + @EnabledForJreRange(max = JRE.JAVA_15) + void mapMultiToLong() { + Exception exception = assertThrows(UnsupportedOperationException.class, () -> { + testTerminal(s -> Java16StreamUtil.mapMultiToLong(s, ((i, mapper) -> { + if (EVEN.test(i)) { + mapper.accept(i); + } + })).boxed().collect(Collectors.toList())); + }); + } + } From 59dc5057086794df8c18f32f42c821b7533cffd8 Mon Sep 17 00:00:00 2001 From: Julia Gustafsson Date: Wed, 30 Aug 2023 13:03:43 +0200 Subject: [PATCH 15/16] Add script to run all integration tests --- integration-tests/run-integration-tests.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 integration-tests/run-integration-tests.sh diff --git a/integration-tests/run-integration-tests.sh b/integration-tests/run-integration-tests.sh new file mode 100644 index 00000000..65ffb494 --- /dev/null +++ b/integration-tests/run-integration-tests.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# Run sakila database +docker run --platform linux/amd64 -d --publish 3306:3306 --name mysqld restsql/mysql-sakila + +# Run inheritance test database +cd src/test/java/com/speedment/jpastreamer/integration/test/inheritance +docker-compose rm -v -f -s test-db && docker-compose up -d + +# Run second inheritance test database +cd ../inheritance2 +docker-compose rm -v -f -s test-db-2 && docker-compose up -d + +echo "Waiting for containers to start..." +sleep 10 + +# Run tests +cd ../../../../../../../../../ +mvn clean install From 541e8dfebf5df294caf69499ddb117fec66de831 Mon Sep 17 00:00:00 2001 From: Julia Gustafsson Date: Wed, 30 Aug 2023 13:04:03 +0200 Subject: [PATCH 16/16] Prepare for version bump to 3.0.4 --- integration-tests/run-integration-tests.sh | 13 +++++++++++++ .../test/inheritance/InheritanceTest.java | 12 ++++++++++++ .../integration/test/inheritance/docker-compose.yml | 13 +++++++++++++ .../test/inheritance/model/BlogPost.java | 12 ++++++++++++ .../integration/test/inheritance/model/Book.java | 12 ++++++++++++ .../test/inheritance/model/Publication.java | 12 ++++++++++++ .../integration/test/inheritance/run-test.sh | 13 +++++++++++++ .../integration/test/inheritance/scripts/data.sql | 13 +++++++++++++ .../integration/test/inheritance/scripts/schema.sql | 13 +++++++++++++ .../test/inheritance2/InheritanceTest2.java | 12 ++++++++++++ .../test/inheritance2/docker-compose.yml | 13 +++++++++++++ .../integration/test/inheritance2/model/Author.java | 12 ++++++++++++ .../test/inheritance2/model/BlogPost2.java | 12 ++++++++++++ .../integration/test/inheritance2/model/Book2.java | 12 ++++++++++++ .../test/inheritance2/model/Publication2.java | 12 ++++++++++++ .../integration/test/inheritance2/run-test.sh | 13 +++++++++++++ .../integration/test/inheritance2/scripts/data.sql | 13 +++++++++++++ .../test/inheritance2/scripts/schema.sql | 13 +++++++++++++ .../jpastreamer/fieldgenerator/test/BlogPost.java | 12 ++++++++++++ .../jpastreamer/fieldgenerator/test/Book.java | 12 ++++++++++++ .../fieldgenerator/test/Publication.java | 12 ++++++++++++ 21 files changed, 261 insertions(+) diff --git a/integration-tests/run-integration-tests.sh b/integration-tests/run-integration-tests.sh index 65ffb494..c9d2a01d 100644 --- a/integration-tests/run-integration-tests.sh +++ b/integration-tests/run-integration-tests.sh @@ -1,4 +1,17 @@ #!/bin/sh +# +# JPAstreamer - Express JPA queries with Java Streams +# Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. +# +# License: GNU Lesser General Public License (LGPL), version 2.1 or later. +# +# This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE +# + # Run sakila database docker run --platform linux/amd64 -d --publish 3306:3306 --name mysqld restsql/mysql-sakila diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/InheritanceTest.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/InheritanceTest.java index eb2ed928..5071285f 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/InheritanceTest.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/InheritanceTest.java @@ -1,3 +1,15 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ package com.speedment.jpastreamer.integration.test.inheritance; import com.speedment.jpastreamer.application.JPAStreamer; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/docker-compose.yml b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/docker-compose.yml index 05ae15e4..5473e2b9 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/docker-compose.yml +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/docker-compose.yml @@ -1,3 +1,16 @@ +# +# JPAstreamer - Express JPA queries with Java Streams +# Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. +# +# License: GNU Lesser General Public License (LGPL), version 2.1 or later. +# +# This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE +# + version: '3.8' services: diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/BlogPost.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/BlogPost.java index 3b7a05e0..100b9b4d 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/BlogPost.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/BlogPost.java @@ -1,3 +1,15 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ package com.speedment.jpastreamer.integration.test.inheritance.model; import jakarta.persistence.*; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Book.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Book.java index c70850b1..3f19c746 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Book.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Book.java @@ -1,3 +1,15 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ package com.speedment.jpastreamer.integration.test.inheritance.model; import jakarta.persistence.*; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Publication.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Publication.java index f8510655..1bbd627b 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Publication.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/model/Publication.java @@ -1,3 +1,15 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ package com.speedment.jpastreamer.integration.test.inheritance.model; import jakarta.persistence.*; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/run-test.sh b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/run-test.sh index 51baf5be..ab622526 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/run-test.sh +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/run-test.sh @@ -1,4 +1,17 @@ #!/bin/sh +# +# JPAstreamer - Express JPA queries with Java Streams +# Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. +# +# License: GNU Lesser General Public License (LGPL), version 2.1 or later. +# +# This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE +# + docker-compose rm -v -f -s test-db && docker-compose up -d mysql -h 127.0.0.1 -P 3305 -u speedment -ppassword publications diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/data.sql b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/data.sql index b7e0c7a5..ef169501 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/data.sql +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/data.sql @@ -1,3 +1,16 @@ +-- +-- JPAstreamer - Express JPA queries with Java Streams +-- Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. +-- +-- License: GNU Lesser General Public License (LGPL), version 2.1 or later. +-- +-- This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +-- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +-- See the GNU Lesser General Public License for more details. +-- +-- See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE +-- + INSERT INTO books (id, publishing_date, title, version, pages) VALUES (1, '2008-7-04', 'Book 1', 2, 213), (2, '2009-7-04', 'Book 2', 2, 234), diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/schema.sql b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/schema.sql index 90c3e24e..23801a3a 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/schema.sql +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance/scripts/schema.sql @@ -1,3 +1,16 @@ +-- +-- JPAstreamer - Express JPA queries with Java Streams +-- Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. +-- +-- License: GNU Lesser General Public License (LGPL), version 2.1 or later. +-- +-- This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +-- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +-- See the GNU Lesser General Public License for more details. +-- +-- See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE +-- + CREATE TABLE books ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, publishing_date DATE NOT NULL, diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/InheritanceTest2.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/InheritanceTest2.java index b9006629..31852707 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/InheritanceTest2.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/InheritanceTest2.java @@ -1,3 +1,15 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ package com.speedment.jpastreamer.integration.test.inheritance2; import com.speedment.jpastreamer.application.JPAStreamer; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/docker-compose.yml b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/docker-compose.yml index 719761c9..76f094e4 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/docker-compose.yml +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/docker-compose.yml @@ -1,3 +1,16 @@ +# +# JPAstreamer - Express JPA queries with Java Streams +# Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. +# +# License: GNU Lesser General Public License (LGPL), version 2.1 or later. +# +# This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE +# + version: '3.8' services: diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Author.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Author.java index 98c9a26a..f37250da 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Author.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Author.java @@ -1,3 +1,15 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ package com.speedment.jpastreamer.integration.test.inheritance2.model; import jakarta.persistence.*; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/BlogPost2.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/BlogPost2.java index b381949f..09005f97 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/BlogPost2.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/BlogPost2.java @@ -1,3 +1,15 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ package com.speedment.jpastreamer.integration.test.inheritance2.model; import jakarta.persistence.Column; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Book2.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Book2.java index 399c9bdf..59035ca4 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Book2.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Book2.java @@ -1,3 +1,15 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ package com.speedment.jpastreamer.integration.test.inheritance2.model; import jakarta.persistence.Column; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Publication2.java b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Publication2.java index b731e8a6..1405915f 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Publication2.java +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/model/Publication2.java @@ -1,3 +1,15 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ package com.speedment.jpastreamer.integration.test.inheritance2.model; import jakarta.persistence.*; diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/run-test.sh b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/run-test.sh index 4132d822..3d011f4a 100755 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/run-test.sh +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/run-test.sh @@ -1,4 +1,17 @@ #!/bin/sh +# +# JPAstreamer - Express JPA queries with Java Streams +# Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. +# +# License: GNU Lesser General Public License (LGPL), version 2.1 or later. +# +# This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU Lesser General Public License for more details. +# +# See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE +# + docker-compose rm -v -f -s test-db-2 && docker-compose up -d mysql -h 127.0.0.1 -P 3304 -u speedment -ppassword testdb2 diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/data.sql b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/data.sql index 130ddda3..9bd24c88 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/data.sql +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/data.sql @@ -1,3 +1,16 @@ +-- +-- JPAstreamer - Express JPA queries with Java Streams +-- Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. +-- +-- License: GNU Lesser General Public License (LGPL), version 2.1 or later. +-- +-- This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +-- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +-- See the GNU Lesser General Public License for more details. +-- +-- See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE +-- + INSERT INTO publication(id, publication_type, publishing_date, title, version, pages, url) VALUES (1, 'Book', '2008-7-04', 'Book 1', 2, 213, null), (2, 'Book', '2009-7-04', 'Book 2', 2, 234, null), diff --git a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/schema.sql b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/schema.sql index a63ae362..51a37af0 100644 --- a/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/schema.sql +++ b/integration-tests/src/test/java/com/speedment/jpastreamer/integration/test/inheritance2/scripts/schema.sql @@ -1,3 +1,16 @@ +-- +-- JPAstreamer - Express JPA queries with Java Streams +-- Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. +-- +-- License: GNU Lesser General Public License (LGPL), version 2.1 or later. +-- +-- This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; +-- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +-- See the GNU Lesser General Public License for more details. +-- +-- See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE +-- + CREATE TABLE publication ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, publication_type VARCHAR(31), diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/BlogPost.java b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/BlogPost.java index 3836fdf2..3b32b994 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/BlogPost.java +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/BlogPost.java @@ -1,3 +1,15 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ package com.speedment.jpastreamer.fieldgenerator.test; import jakarta.persistence.Column; diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Book.java b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Book.java index 044aa1d3..872d66b3 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Book.java +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Book.java @@ -1,3 +1,15 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ package com.speedment.jpastreamer.fieldgenerator.test; import jakarta.persistence.Column; diff --git a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Publication.java b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Publication.java index 36e74a23..4747e5c3 100644 --- a/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Publication.java +++ b/jpastreamer.fieldgenerator/jpastreamer.fieldgenerator.test/src/main/java/com/speedment/jpastreamer/fieldgenerator/test/Publication.java @@ -1,3 +1,15 @@ +/* + * JPAstreamer - Express JPA queries with Java Streams + * Copyright (c) 2020-2022, Speedment, Inc. All Rights Reserved. + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE + */ package com.speedment.jpastreamer.fieldgenerator.test; import jakarta.persistence.*;