From f87eca7d78196ea0bd717178e32a235d6752aa17 Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Fri, 2 Aug 2024 16:45:02 -0300 Subject: [PATCH 1/9] Preparing for java 17 prime time --- pom.xml | 6 +++--- querydsl-docs/pom.xml | 2 +- querydsl-examples/pom.xml | 6 +----- querydsl-examples/querydsl-example-jpa-guice/pom.xml | 2 +- querydsl-examples/querydsl-example-jpa-quarkus/pom.xml | 2 +- querydsl-examples/querydsl-example-jpa-spring/pom.xml | 2 +- querydsl-examples/querydsl-example-kotlin-codegen/pom.xml | 2 +- querydsl-examples/querydsl-example-kotlin-jpa/pom.xml | 2 +- querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml | 2 +- .../querydsl-example-r2dbc-sql-codegen/pom.xml | 2 +- querydsl-examples/querydsl-example-sql-guice/pom.xml | 2 +- querydsl-examples/querydsl-example-sql-spring/pom.xml | 2 +- querydsl-libraries/pom.xml | 2 +- querydsl-libraries/querydsl-collections/pom.xml | 2 +- querydsl-libraries/querydsl-core/pom.xml | 2 +- querydsl-libraries/querydsl-guava/pom.xml | 2 +- querydsl-libraries/querydsl-jpa-spring/pom.xml | 8 +------- querydsl-libraries/querydsl-jpa/pom.xml | 2 +- querydsl-libraries/querydsl-kotlin/pom.xml | 2 +- querydsl-libraries/querydsl-mongodb/pom.xml | 2 +- querydsl-libraries/querydsl-r2dbc/pom.xml | 2 +- querydsl-libraries/querydsl-scala/pom.xml | 2 +- querydsl-libraries/querydsl-spatial/pom.xml | 2 +- querydsl-libraries/querydsl-sql-json/pom.xml | 2 +- querydsl-libraries/querydsl-sql-spatial/pom.xml | 2 +- querydsl-libraries/querydsl-sql-spring/pom.xml | 7 +------ querydsl-libraries/querydsl-sql/pom.xml | 2 +- querydsl-tooling/pom.xml | 2 +- querydsl-tooling/querydsl-apt/pom.xml | 2 +- querydsl-tooling/querydsl-codegen-utils/pom.xml | 2 +- querydsl-tooling/querydsl-codegen/pom.xml | 2 +- querydsl-tooling/querydsl-jpa-codegen/pom.xml | 2 +- querydsl-tooling/querydsl-kotlin-codegen/pom.xml | 2 +- querydsl-tooling/querydsl-maven-plugin/pom.xml | 2 +- querydsl-tooling/querydsl-sql-codegen/pom.xml | 2 +- 35 files changed, 37 insertions(+), 52 deletions(-) diff --git a/pom.xml b/pom.xml index 9ccd0de207..787c26b9db 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.github.openfeign.querydsl querydsl-root - 6.9-SNAPSHOT + 7.0-SNAPSHOT pom Querydsl @@ -96,7 +96,7 @@ -Xms256m -Xmx512m - 11 + 17 21 5.3 @@ -1051,7 +1051,7 @@ true - org.openrewrite.java.migrate.Java8toJava11 + org.openrewrite.java.migrate.UpgradeToJava17 diff --git a/querydsl-docs/pom.xml b/querydsl-docs/pom.xml index f1b3bb3e68..66f4186a73 100644 --- a/querydsl-docs/pom.xml +++ b/querydsl-docs/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-root - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-docs diff --git a/querydsl-examples/pom.xml b/querydsl-examples/pom.xml index 173671edc4..e8118fc160 100644 --- a/querydsl-examples/pom.xml +++ b/querydsl-examples/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-root - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-examples @@ -27,10 +27,6 @@ querydsl-example-r2dbc-sql-codegen - - 17 - - diff --git a/querydsl-examples/querydsl-example-jpa-guice/pom.xml b/querydsl-examples/querydsl-example-jpa-guice/pom.xml index 644ccb821a..2fda34b5de 100644 --- a/querydsl-examples/querydsl-example-jpa-guice/pom.xml +++ b/querydsl-examples/querydsl-example-jpa-guice/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-example-jpa-guice diff --git a/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml b/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml index 9c1563c92a..5cbd7c7616 100644 --- a/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml +++ b/querydsl-examples/querydsl-example-jpa-quarkus/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-example-jpa-quarkus diff --git a/querydsl-examples/querydsl-example-jpa-spring/pom.xml b/querydsl-examples/querydsl-example-jpa-spring/pom.xml index 296fb7628a..fa0270708e 100755 --- a/querydsl-examples/querydsl-example-jpa-spring/pom.xml +++ b/querydsl-examples/querydsl-example-jpa-spring/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-example-jpa-spring diff --git a/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml b/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml index af793e4f4f..17dbbd0841 100644 --- a/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml +++ b/querydsl-examples/querydsl-example-kotlin-codegen/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-example-kotlin-codegen Querydsl example - Kotlin Codegen diff --git a/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml b/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml index 1b24f4eab4..29cf1084d6 100644 --- a/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml +++ b/querydsl-examples/querydsl-example-kotlin-jpa/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-example-kotlin Querydsl example - Kotlin JPA diff --git a/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml b/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml index f0ed2d3fd4..cf737af589 100644 --- a/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml +++ b/querydsl-examples/querydsl-example-kotlin-mongodb/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-example-kotlin-mongodb Querydsl example - Kotlin MongoDB diff --git a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml index fc7d818e24..0978f297aa 100644 --- a/querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml +++ b/querydsl-examples/querydsl-example-r2dbc-sql-codegen/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-example-r2dbc-sql-codegen diff --git a/querydsl-examples/querydsl-example-sql-guice/pom.xml b/querydsl-examples/querydsl-example-sql-guice/pom.xml index 35d9b5303d..2e59bf51be 100644 --- a/querydsl-examples/querydsl-example-sql-guice/pom.xml +++ b/querydsl-examples/querydsl-example-sql-guice/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-example-sql-guice diff --git a/querydsl-examples/querydsl-example-sql-spring/pom.xml b/querydsl-examples/querydsl-example-sql-spring/pom.xml index 4105531ad4..41fbc8fa1f 100644 --- a/querydsl-examples/querydsl-example-sql-spring/pom.xml +++ b/querydsl-examples/querydsl-example-sql-spring/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-examples - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-example-sql-spring diff --git a/querydsl-libraries/pom.xml b/querydsl-libraries/pom.xml index 7f8c1cf615..af9fc1c636 100644 --- a/querydsl-libraries/pom.xml +++ b/querydsl-libraries/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-root - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-libraries diff --git a/querydsl-libraries/querydsl-collections/pom.xml b/querydsl-libraries/querydsl-collections/pom.xml index bd6cc150fe..87c3304c49 100644 --- a/querydsl-libraries/querydsl-collections/pom.xml +++ b/querydsl-libraries/querydsl-collections/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT io.github.openfeign.querydsl diff --git a/querydsl-libraries/querydsl-core/pom.xml b/querydsl-libraries/querydsl-core/pom.xml index f68be92c20..d2a2984917 100644 --- a/querydsl-libraries/querydsl-core/pom.xml +++ b/querydsl-libraries/querydsl-core/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-core diff --git a/querydsl-libraries/querydsl-guava/pom.xml b/querydsl-libraries/querydsl-guava/pom.xml index ebe3049aaa..f272312a5d 100644 --- a/querydsl-libraries/querydsl-guava/pom.xml +++ b/querydsl-libraries/querydsl-guava/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-guava diff --git a/querydsl-libraries/querydsl-jpa-spring/pom.xml b/querydsl-libraries/querydsl-jpa-spring/pom.xml index a437acf305..786951bfbf 100644 --- a/querydsl-libraries/querydsl-jpa-spring/pom.xml +++ b/querydsl-libraries/querydsl-jpa-spring/pom.xml @@ -5,19 +5,13 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-jpa-spring Querydsl - JPA Spring support JPA Spring support for Querydsl - - - 17 - - - diff --git a/querydsl-libraries/querydsl-jpa/pom.xml b/querydsl-libraries/querydsl-jpa/pom.xml index 6094e649df..84aeb1f222 100644 --- a/querydsl-libraries/querydsl-jpa/pom.xml +++ b/querydsl-libraries/querydsl-jpa/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-jpa diff --git a/querydsl-libraries/querydsl-kotlin/pom.xml b/querydsl-libraries/querydsl-kotlin/pom.xml index 93b12bdd34..0285803835 100644 --- a/querydsl-libraries/querydsl-kotlin/pom.xml +++ b/querydsl-libraries/querydsl-kotlin/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-kotlin diff --git a/querydsl-libraries/querydsl-mongodb/pom.xml b/querydsl-libraries/querydsl-mongodb/pom.xml index fef9df00ed..2115bebac1 100644 --- a/querydsl-libraries/querydsl-mongodb/pom.xml +++ b/querydsl-libraries/querydsl-mongodb/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-mongodb diff --git a/querydsl-libraries/querydsl-r2dbc/pom.xml b/querydsl-libraries/querydsl-r2dbc/pom.xml index 2ff7c49313..3de9d9b75b 100644 --- a/querydsl-libraries/querydsl-r2dbc/pom.xml +++ b/querydsl-libraries/querydsl-r2dbc/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-r2dbc diff --git a/querydsl-libraries/querydsl-scala/pom.xml b/querydsl-libraries/querydsl-scala/pom.xml index 8ed3f09895..4b62e6b8db 100644 --- a/querydsl-libraries/querydsl-scala/pom.xml +++ b/querydsl-libraries/querydsl-scala/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-scala diff --git a/querydsl-libraries/querydsl-spatial/pom.xml b/querydsl-libraries/querydsl-spatial/pom.xml index 0bf27ce2da..8e02ca46f1 100644 --- a/querydsl-libraries/querydsl-spatial/pom.xml +++ b/querydsl-libraries/querydsl-spatial/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-spatial diff --git a/querydsl-libraries/querydsl-sql-json/pom.xml b/querydsl-libraries/querydsl-sql-json/pom.xml index bce38e9248..2158e7ccdc 100644 --- a/querydsl-libraries/querydsl-sql-json/pom.xml +++ b/querydsl-libraries/querydsl-sql-json/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-sql-json diff --git a/querydsl-libraries/querydsl-sql-spatial/pom.xml b/querydsl-libraries/querydsl-sql-spatial/pom.xml index fb419f078e..6b2df06926 100644 --- a/querydsl-libraries/querydsl-sql-spatial/pom.xml +++ b/querydsl-libraries/querydsl-sql-spatial/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-sql-spatial diff --git a/querydsl-libraries/querydsl-sql-spring/pom.xml b/querydsl-libraries/querydsl-sql-spring/pom.xml index 928bdfd890..ad7a6607c1 100644 --- a/querydsl-libraries/querydsl-sql-spring/pom.xml +++ b/querydsl-libraries/querydsl-sql-spring/pom.xml @@ -5,18 +5,13 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-sql-spring Querydsl - SQL Spring support SQL Spring support for Querydsl - - - 17 - - org.jetbrains diff --git a/querydsl-libraries/querydsl-sql/pom.xml b/querydsl-libraries/querydsl-sql/pom.xml index d2d17105ff..5e873c3c59 100644 --- a/querydsl-libraries/querydsl-sql/pom.xml +++ b/querydsl-libraries/querydsl-sql/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-libraries - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-sql diff --git a/querydsl-tooling/pom.xml b/querydsl-tooling/pom.xml index 36397f6744..51ab75db2b 100644 --- a/querydsl-tooling/pom.xml +++ b/querydsl-tooling/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-root - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-tooling diff --git a/querydsl-tooling/querydsl-apt/pom.xml b/querydsl-tooling/querydsl-apt/pom.xml index fcb9ba1d33..1e52ac6943 100644 --- a/querydsl-tooling/querydsl-apt/pom.xml +++ b/querydsl-tooling/querydsl-apt/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-apt diff --git a/querydsl-tooling/querydsl-codegen-utils/pom.xml b/querydsl-tooling/querydsl-codegen-utils/pom.xml index 77afab2631..327867b47d 100644 --- a/querydsl-tooling/querydsl-codegen-utils/pom.xml +++ b/querydsl-tooling/querydsl-codegen-utils/pom.xml @@ -6,7 +6,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-codegen-utils diff --git a/querydsl-tooling/querydsl-codegen/pom.xml b/querydsl-tooling/querydsl-codegen/pom.xml index 22497ab939..4730893479 100644 --- a/querydsl-tooling/querydsl-codegen/pom.xml +++ b/querydsl-tooling/querydsl-codegen/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-codegen diff --git a/querydsl-tooling/querydsl-jpa-codegen/pom.xml b/querydsl-tooling/querydsl-jpa-codegen/pom.xml index 4f4f39a443..a18eaefc4e 100644 --- a/querydsl-tooling/querydsl-jpa-codegen/pom.xml +++ b/querydsl-tooling/querydsl-jpa-codegen/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-jpa-codegen diff --git a/querydsl-tooling/querydsl-kotlin-codegen/pom.xml b/querydsl-tooling/querydsl-kotlin-codegen/pom.xml index eb4be9d3b0..5ccdde0180 100644 --- a/querydsl-tooling/querydsl-kotlin-codegen/pom.xml +++ b/querydsl-tooling/querydsl-kotlin-codegen/pom.xml @@ -4,7 +4,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-kotlin-codegen diff --git a/querydsl-tooling/querydsl-maven-plugin/pom.xml b/querydsl-tooling/querydsl-maven-plugin/pom.xml index 85920a34f4..861f20ccd3 100644 --- a/querydsl-tooling/querydsl-maven-plugin/pom.xml +++ b/querydsl-tooling/querydsl-maven-plugin/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-maven-plugin diff --git a/querydsl-tooling/querydsl-sql-codegen/pom.xml b/querydsl-tooling/querydsl-sql-codegen/pom.xml index 9bcd317838..e87ad44d8e 100644 --- a/querydsl-tooling/querydsl-sql-codegen/pom.xml +++ b/querydsl-tooling/querydsl-sql-codegen/pom.xml @@ -5,7 +5,7 @@ io.github.openfeign.querydsl querydsl-tooling - 6.9-SNAPSHOT + 7.0-SNAPSHOT querydsl-sql-codegen From c5d52980cb481923b7237f1e7e6b89abbe3af180 Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Fri, 2 Aug 2024 17:25:41 -0300 Subject: [PATCH 2/9] Apply java 17 best praticles --- .../collections/DefaultQueryEngine.java | 4 +- .../querydsl/collections/MultiComparator.java | 4 +- .../com/querydsl/core/BooleanBuilder.java | 4 +- .../querydsl/core/DefaultQueryMetadata.java | 5 +-- .../com/querydsl/core/JoinExpression.java | 3 +- .../main/java/com/querydsl/core/JoinFlag.java | 4 +- .../java/com/querydsl/core/QueryFlag.java | 3 +- .../com/querydsl/core/QueryModifiers.java | 3 +- .../java/com/querydsl/core/alias/Alias.java | 28 ++++++------ .../group/AbstractGroupByTransformer.java | 13 +++--- .../com/querydsl/core/group/GroupImpl.java | 5 +-- .../core/support/CollectionAnyVisitor.java | 3 +- .../support/ConstantHidingExpression.java | 8 ++-- .../querydsl/core/support/EnumConversion.java | 4 +- .../core/support/FetchableQueryBase.java | 3 +- .../core/support/NumberConversions.java | 14 +++--- .../querydsl/core/support/PathsExtractor.java | 4 +- .../com/querydsl/core/support/QueryBase.java | 3 +- .../com/querydsl/core/support/QueryMixin.java | 11 +++-- .../support/ReactiveFetchableQueryBase.java | 3 +- .../querydsl/core/support/ReplaceVisitor.java | 8 ++-- .../querydsl/core/support/SerializerBase.java | 20 ++++----- .../types/ArrayConstructorExpression.java | 3 +- .../com/querydsl/core/types/ConstantImpl.java | 4 +- .../core/types/ConstructorExpression.java | 3 +- .../querydsl/core/types/ExpressionUtils.java | 10 ++--- .../core/types/FactoryExpressionBase.java | 8 ++-- .../core/types/FactoryExpressionUtils.java | 30 ++++++------- .../querydsl/core/types/OperationImpl.java | 3 +- .../querydsl/core/types/OrderSpecifier.java | 3 +- .../core/types/ParamExpressionImpl.java | 3 +- .../querydsl/core/types/ParamsVisitor.java | 4 +- .../querydsl/core/types/PathExtractor.java | 4 +- .../com/querydsl/core/types/PathImpl.java | 4 +- .../com/querydsl/core/types/PathMetadata.java | 3 +- .../java/com/querydsl/core/types/QBean.java | 9 ++-- .../java/com/querydsl/core/types/QList.java | 3 +- .../java/com/querydsl/core/types/QMap.java | 3 +- .../java/com/querydsl/core/types/QTuple.java | 11 +++-- .../com/querydsl/core/types/Template.java | 38 ++++++++-------- .../core/types/TemplateExpressionImpl.java | 3 +- .../querydsl/core/types/TemplateFactory.java | 32 +++++++------- .../querydsl/core/types/ToStringVisitor.java | 18 ++++---- .../core/types/ValidatingVisitor.java | 8 ++-- .../querydsl/core/types/dsl/CaseBuilder.java | 28 ++++++------ .../core/types/dsl/CaseForEqBuilder.java | 28 ++++++------ .../com/querydsl/core/types/dsl/Coalesce.java | 3 +- .../querydsl/core/types/dsl/Expressions.java | 23 ++++------ .../com/querydsl/core/util/MathUtils.java | 10 ++--- .../querydsl/core/util/ReflectionUtils.java | 43 +++++++++---------- .../com/querydsl/core/util/TupleUtils.java | 10 ++--- .../java/com/querydsl/jpa/JPQLSerializer.java | 4 +- .../java/com/querydsl/jpa/JPQLTemplates.java | 4 +- .../com/querydsl/jpa/NativeSQLSerializer.java | 4 +- .../querydsl/jpa/TransformingIterator.java | 2 +- .../querydsl/jpa/hibernate/HibernateUtil.java | 8 ++-- .../java/com/querydsl/jpa/impl/JPAUtil.java | 4 +- .../com/querydsl/r2dbc/SQLSerializer.java | 10 ++--- .../querydsl/r2dbc/types/CharacterType.java | 4 +- .../com/querydsl/r2dbc/types/DateType.java | 8 ++-- .../r2dbc/types/StringAsObjectType.java | 4 +- .../com/querydsl/sql/AbstractSQLQuery.java | 4 +- .../java/com/querydsl/sql/ColumnMetadata.java | 11 +++-- .../com/querydsl/sql/RelationalPathBase.java | 16 +++---- .../querydsl/sql/RelationalPathExtractor.java | 4 +- .../com/querydsl/sql/SQLListenerAdapter.java | 3 +- .../java/com/querydsl/sql/SQLListeners.java | 8 ++-- .../java/com/querydsl/sql/SQLSerializer.java | 22 +++++----- .../java/com/querydsl/sql/SchemaAndTable.java | 3 +- .../java/com/querydsl/sql/WindowFunction.java | 3 +- .../sql/types/StringAsObjectType.java | 7 ++- .../apt/AbstractQuerydslProcessor.java | 16 +++---- .../querydsl/apt/DefaultConfiguration.java | 6 +-- .../com/querydsl/apt/ExtendedTypeFactory.java | 12 +++--- .../querydsl/apt/jpa/JPAConfiguration.java | 4 +- .../codegen/utils/ECJEvaluatorFactory.java | 4 +- .../querydsl/codegen/utils/JavaWriter.java | 7 ++- .../codegen/utils/LocationAndKind.java | 3 +- .../querydsl/codegen/utils/ScalaWriter.java | 7 ++- .../codegen/utils/model/ClassType.java | 3 +- .../codegen/utils/model/Constructor.java | 4 +- .../codegen/utils/model/Parameter.java | 3 +- .../codegen/utils/model/SimpleType.java | 3 +- .../codegen/utils/model/TypeExtends.java | 5 +-- .../codegen/utils/model/TypeSuper.java | 5 +-- .../java/com/querydsl/codegen/Delegate.java | 3 +- .../com/querydsl/codegen/GenericExporter.java | 4 +- .../codegen/ParameterizedTypeImpl.java | 3 +- .../java/com/querydsl/codegen/Property.java | 3 +- .../java/com/querydsl/codegen/Supertype.java | 4 +- .../com/querydsl/codegen/TypeFactory.java | 16 +++---- .../com/querydsl/codegen/TypeResolver.java | 8 ++-- 92 files changed, 352 insertions(+), 413 deletions(-) diff --git a/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/DefaultQueryEngine.java b/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/DefaultQueryEngine.java index 4630999185..9a5cd30f46 100644 --- a/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/DefaultQueryEngine.java +++ b/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/DefaultQueryEngine.java @@ -163,8 +163,8 @@ private List evaluateSingleSource( final List> sources = Collections.>singletonList(source); final Iterable iterable = iterables.values().iterator().next(); List list; - if (iterable instanceof List) { - list = (List) iterable; + if (iterable instanceof List list1) { + list = list1; } else { list = IteratorAdapter.asList(iterable.iterator()); } diff --git a/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/MultiComparator.java b/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/MultiComparator.java index b973dcfca2..f7bc2ba881 100644 --- a/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/MultiComparator.java +++ b/querydsl-libraries/querydsl-collections/src/main/java/com/querydsl/collections/MultiComparator.java @@ -45,8 +45,8 @@ public MultiComparator(Evaluator ev, boolean[] directions, boolean[] n @Override public int compare(T o1, T o2) { - if (o1 instanceof Object[]) { - return innerCompare(ev.evaluate((Object[]) o1), ev.evaluate((Object[]) o2)); + if (o1 instanceof Object[] objects) { + return innerCompare(ev.evaluate(objects), ev.evaluate((Object[]) o2)); } else { return innerCompare(ev.evaluate(o1), ev.evaluate(o2)); } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/BooleanBuilder.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/BooleanBuilder.java index a7b1d3edc4..681619cd8a 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/BooleanBuilder.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/BooleanBuilder.java @@ -113,8 +113,8 @@ public BooleanBuilder clone() throws CloneNotSupportedException { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof BooleanBuilder) { - return Objects.equals(((BooleanBuilder) o).getValue(), predicate); + } else if (o instanceof BooleanBuilder builder) { + return Objects.equals(builder.getValue(), predicate); } else { return false; } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/DefaultQueryMetadata.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/DefaultQueryMetadata.java index bd5cefe480..5af7598765 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/DefaultQueryMetadata.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/DefaultQueryMetadata.java @@ -158,7 +158,7 @@ private void addLastJoin() { public void addJoin(JoinType joinType, Expression expr) { addLastJoin(); if (!exprInJoins.contains(expr)) { - if (expr instanceof Path && ((Path) expr).getMetadata().isRoot()) { + if (expr instanceof Path path && path.getMetadata().isRoot()) { exprInJoins.add(expr); } else { validate(expr); @@ -378,8 +378,7 @@ public void setValidatingVisitor(ValidatingVisitor visitor) { @Override public boolean equals(Object o) { - if (o instanceof QueryMetadata) { - var q = (QueryMetadata) o; + if (o instanceof QueryMetadata q) { return q.getFlags().equals(flags) && q.getGroupBy().equals(groupBy) && Objects.equals(q.getHaving(), having) diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/JoinExpression.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/JoinExpression.java index 975521d1c2..3e817b31ed 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/JoinExpression.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/JoinExpression.java @@ -107,8 +107,7 @@ public int hashCode() { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof JoinExpression) { - var j = (JoinExpression) o; + } else if (o instanceof JoinExpression j) { return Objects.equals(condition, j.condition) && Objects.equals(target, j.target) && Objects.equals(type, j.type); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/JoinFlag.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/JoinFlag.java index c24348edd7..cd9ece7a0f 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/JoinFlag.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/JoinFlag.java @@ -106,8 +106,8 @@ public int hashCode() { public boolean equals(Object obj) { if (obj == this) { return true; - } else if (obj instanceof JoinFlag) { - return ((JoinFlag) obj).flag.equals(flag); + } else if (obj instanceof JoinFlag joinFlag) { + return joinFlag.flag.equals(flag); } else { return false; } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/QueryFlag.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/QueryFlag.java index 4ae16e0031..9e7e396c4a 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/QueryFlag.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/QueryFlag.java @@ -103,8 +103,7 @@ public int hashCode() { public boolean equals(Object obj) { if (obj == this) { return true; - } else if (obj instanceof QueryFlag) { - var other = (QueryFlag) obj; + } else if (obj instanceof QueryFlag other) { return other.position.equals(position) && other.flag.equals(flag); } else { return false; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/QueryModifiers.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/QueryModifiers.java index 536141911e..ad03f9ca81 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/QueryModifiers.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/QueryModifiers.java @@ -120,8 +120,7 @@ public List subList(List list) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof QueryModifiers) { - var qm = (QueryModifiers) o; + } else if (o instanceof QueryModifiers qm) { return Objects.equals(qm.getLimit(), limit) && Objects.equals(qm.getOffset(), offset); } else { return false; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/alias/Alias.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/alias/Alias.java index c17418e84f..0165678fce 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/alias/Alias.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/alias/Alias.java @@ -162,8 +162,8 @@ public final class Alias { final Object current = aliasFactory.getCurrentAndReset(); if (arg instanceof CollectionPath) { return (CollectionPath>) arg; // NOSONAR - } else if (arg instanceof ManagedObject) { - return (CollectionPath>) ((ManagedObject) arg).__mappedPath(); + } else if (arg instanceof ManagedObject object) { + return (CollectionPath>) object.__mappedPath(); } else { return (CollectionPath>) current; } @@ -242,8 +242,8 @@ public final class Alias { final Object current = aliasFactory.getCurrentAndReset(); if (arg instanceof ListPath) { return (ListPath>) arg; // NOSONAR - } else if (arg instanceof ManagedObject) { - return (ListPath>) ((ManagedObject) arg).__mappedPath(); + } else if (arg instanceof ManagedObject object) { + return (ListPath>) object.__mappedPath(); } else { return (ListPath>) current; } @@ -272,8 +272,8 @@ public final class Alias { final Object current = aliasFactory.getCurrentAndReset(); if (arg instanceof MapPath) { return (MapPath>) arg; // NOSONAR - } else if (arg instanceof ManagedObject) { - return (MapPath>) ((ManagedObject) arg).__mappedPath(); + } else if (arg instanceof ManagedObject object) { + return (MapPath>) object.__mappedPath(); } else { return (MapPath>) current; } @@ -291,8 +291,8 @@ public final class Alias { final Object current = aliasFactory.getCurrentAndReset(); if (arg instanceof SetPath) { return (SetPath>) arg; // NOSONAR - } else if (arg instanceof ManagedObject) { - return (SetPath>) ((ManagedObject) arg).__mappedPath(); + } else if (arg instanceof ManagedObject object) { + return (SetPath>) object.__mappedPath(); } else { return (SetPath>) current; } @@ -351,8 +351,8 @@ public final class Alias { final Object current = aliasFactory.getCurrentAndReset(); if (arg instanceof EntityPath) { return (EntityPathBase) arg; // NOSONAR - } else if (arg instanceof ManagedObject) { - return (EntityPathBase) ((ManagedObject) arg).__mappedPath(); + } else if (arg instanceof ManagedObject object) { + return (EntityPathBase) object.__mappedPath(); } else { return (EntityPathBase) current; } @@ -364,8 +364,8 @@ private static > P getPath(D arg) { final Object current = aliasFactory.getCurrentAndReset(); if (arg instanceof Path) { return (P) arg; - } else if (arg instanceof ManagedObject) { - return (P) ((ManagedObject) arg).__mappedPath(); + } else if (arg instanceof ManagedObject object) { + return (P) object.__mappedPath(); } else { return (P) current; } @@ -415,8 +415,8 @@ public static A alias(Class cl, String var) { @SuppressWarnings("unchecked") public static Expression getAny(D arg) { Object current = aliasFactory.getCurrentAndReset(); - if (arg instanceof ManagedObject) { - return (Expression) ((ManagedObject) arg).__mappedPath(); + if (arg instanceof ManagedObject object) { + return (Expression) object.__mappedPath(); } else if (current != null) { return (Expression) current; } else { diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/AbstractGroupByTransformer.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/AbstractGroupByTransformer.java index 63d9785695..834a8b825d 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/AbstractGroupByTransformer.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/AbstractGroupByTransformer.java @@ -74,13 +74,12 @@ protected AbstractGroupByTransformer(Expression key, Expression... express projection.add(key); for (Expression expr : expressions) { - if (expr instanceof GroupExpression) { - GroupExpression groupExpr = (GroupExpression) expr; + if (expr instanceof GroupExpression groupExpr) { groupExpressions.add(groupExpr); Expression colExpression = groupExpr.getExpression(); - if (colExpression instanceof Operation - && ((Operation) colExpression).getOperator() == Ops.ALIAS) { - projection.add(((Operation) colExpression).getArg(0)); + if (colExpression instanceof Operation operation + && operation.getOperator() == Ops.ALIAS) { + projection.add(operation.getArg(0)); } else { projection.add(colExpression); } @@ -100,8 +99,8 @@ protected static FactoryExpression withoutGroupExpressions( final FactoryExpression expr) { List> args = new ArrayList<>(expr.getArgs().size()); for (Expression arg : expr.getArgs()) { - if (arg instanceof GroupExpression) { - args.add(((GroupExpression) arg).getExpression()); + if (arg instanceof GroupExpression expression) { + args.add(expression.getExpression()); } else { args.add(arg); } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupImpl.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupImpl.java index 9e813643ad..ff39e42244 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupImpl.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/group/GroupImpl.java @@ -50,9 +50,8 @@ public GroupImpl(List> columnDefinitions, List collector = coldef.createGroupCollector(); Expression coldefExpr = coldef.getExpression(); groupCollectorMap.put(coldefExpr, collector); - if (coldefExpr instanceof Operation - && ((Operation) coldefExpr).getOperator() == Ops.ALIAS) { - groupCollectorMap.put(((Operation) coldefExpr).getArg(1), collector); + if (coldefExpr instanceof Operation operation && operation.getOperator() == Ops.ALIAS) { + groupCollectorMap.put(operation.getArg(1), collector); } } groupCollectors.add(collector); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/CollectionAnyVisitor.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/CollectionAnyVisitor.java index 674b4d3725..3f8b172731 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/CollectionAnyVisitor.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/CollectionAnyVisitor.java @@ -48,8 +48,7 @@ public class CollectionAnyVisitor implements Visitor, Context> { private static Path replaceParent(Path path, Path parent) { var metadata = new PathMetadata(parent, path.getMetadata().getElement(), path.getMetadata().getPathType()); - if (path instanceof CollectionExpression) { - CollectionExpression col = (CollectionExpression) path; + if (path instanceof CollectionExpression col) { return Expressions.listPath(col.getParameter(0), SimplePath.class, metadata); } else { return ExpressionUtils.path(path.getType(), metadata); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ConstantHidingExpression.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ConstantHidingExpression.java index 93b572775d..848d428778 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ConstantHidingExpression.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ConstantHidingExpression.java @@ -50,8 +50,8 @@ public ConstantHidingExpression(FactoryExpression expr) { for (var i = 0; i < template.length; i++) { Expression arg = expr.getArgs().get(i); Expression unwrapped = unwrap(arg); - if (unwrapped instanceof Constant) { - template[i] = ((Constant) unwrapped).getConstant(); + if (unwrapped instanceof Constant constant) { + template[i] = constant.getConstant(); } else if (unwrapped.equals(Expressions.TRUE)) { template[i] = Boolean.TRUE; } else if (unwrapped.equals(Expressions.FALSE)) { @@ -64,8 +64,8 @@ public ConstantHidingExpression(FactoryExpression expr) { private static Expression unwrap(Expression expr) { expr = ExpressionUtils.extract(expr); - if (expr instanceof Operation && ((Operation) expr).getOperator() == Ops.ALIAS) { - return ((Operation) expr).getArg(0); + if (expr instanceof Operation operation && operation.getOperator() == Ops.ALIAS) { + return operation.getArg(0); } return expr; } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/EnumConversion.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/EnumConversion.java index 38c7f03723..f3f8fd1ff0 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/EnumConversion.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/EnumConversion.java @@ -61,8 +61,8 @@ public T newInstance(Object... args) { @SuppressWarnings("unchecked") // The expression type is an enum var rv = (T) Enum.valueOf(getType().asSubclass(Enum.class), args[0].toString()); return rv; - } else if (args[0] instanceof Number) { - return values[((Number) args[0]).intValue()]; + } else if (args[0] instanceof Number number) { + return values[number.intValue()]; } else { @SuppressWarnings("unchecked") var rv = (T) args[0]; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/FetchableQueryBase.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/FetchableQueryBase.java index c915a094c2..603a140f8e 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/FetchableQueryBase.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/FetchableQueryBase.java @@ -73,8 +73,7 @@ protected T uniqueResult(CloseableIterator it) { public final boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof SubQueryExpression) { - SubQueryExpression s = (SubQueryExpression) o; + } else if (o instanceof SubQueryExpression s) { return s.getMetadata().equals(queryMixin.getMetadata()); } else { return false; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/NumberConversions.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/NumberConversions.java index 527dc207c0..dfb5c1e12a 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/NumberConversions.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/NumberConversions.java @@ -68,16 +68,16 @@ public T newInstance(Object... args) { for (var i = 0; i < args.length; i++) { Class type = expr.getArgs().get(i).getType(); if (Enum.class.isAssignableFrom(type) && !type.isInstance(args[i])) { - if (args[i] instanceof String) { - args[i] = Enum.valueOf((Class) type, (String) args[i]); - } else if (args[i] instanceof Number) { - args[i] = getValues((Class) type)[((Number) args[i]).intValue()]; + if (args[i] instanceof String string) { + args[i] = Enum.valueOf((Class) type, string); + } else if (args[i] instanceof Number number) { + args[i] = getValues((Class) type)[number.intValue()]; } - } else if (args[i] instanceof Number && !type.isInstance(args[i])) { + } else if (args[i] instanceof Number number && !type.isInstance(args[i])) { if (type.equals(Boolean.class)) { - args[i] = ((Number) args[i]).intValue() > 0; + args[i] = number.intValue() > 0; } else if (Number.class.isAssignableFrom(type)) { - args[i] = MathUtils.cast((Number) args[i], (Class) type); + args[i] = MathUtils.cast(number, (Class) type); } } } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/PathsExtractor.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/PathsExtractor.java index 141cdd0aed..3df31f0361 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/PathsExtractor.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/PathsExtractor.java @@ -77,8 +77,8 @@ public Void visit(TemplateExpression expr, List> paths) { public Path visit(Collection exprs, List> paths) { for (Object e : exprs) { - if (e instanceof Expression) { - ((Expression) e).accept(this, paths); + if (e instanceof Expression expression) { + expression.accept(this, paths); } } return null; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/QueryBase.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/QueryBase.java index 67eb9fec17..5be6c4dd0e 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/QueryBase.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/QueryBase.java @@ -178,8 +178,7 @@ public

Q set(ParamExpression

param, P value) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof QueryBase) { - var q = (QueryBase) o; + } else if (o instanceof QueryBase q) { return q.queryMixin.equals(queryMixin); } else { return false; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/QueryMixin.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/QueryMixin.java index 0ad21f0fa2..e59b016f5b 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/QueryMixin.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/QueryMixin.java @@ -150,14 +150,14 @@ private Path normalizePath(Path expr) { @SuppressWarnings({"rawtypes", "unchecked"}) public Expression convert(Expression expr, Role role) { if (expandAnyPaths) { - if (expr instanceof Path) { - expr = (Expression) normalizePath((Path) expr); + if (expr instanceof Path path) { + expr = (Expression) normalizePath(path); } else if (expr != null) { expr = (Expression) expr.accept(replaceVisitor, null); } } - if (expr instanceof ProjectionRole) { - return convert(((ProjectionRole) expr).getProjection(), role); + if (expr instanceof ProjectionRole pr) { + return convert((pr).getProjection(), role); } else if (expr instanceof FactoryExpression && !(expr instanceof FactoryExpressionAdapter)) { return FactoryExpressionUtils.wrap((FactoryExpression) expr); @@ -437,8 +437,7 @@ public final T where(Predicate... o) { public final boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof QueryMixin) { - QueryMixin q = (QueryMixin) o; + } else if (o instanceof QueryMixin q) { return q.metadata.equals(metadata); } else { return false; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReactiveFetchableQueryBase.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReactiveFetchableQueryBase.java index 082a7e5430..0657a20470 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReactiveFetchableQueryBase.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReactiveFetchableQueryBase.java @@ -39,8 +39,7 @@ public Publisher transform(ReactiveResultTransformer transformer) { public final boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof SubQueryExpression) { - SubQueryExpression s = (SubQueryExpression) o; + } else if (o instanceof SubQueryExpression s) { return s.getMetadata().equals(queryMixin.getMetadata()); } else { return false; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReplaceVisitor.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReplaceVisitor.java index bd4664e235..8d293fbaf0 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReplaceVisitor.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/ReplaceVisitor.java @@ -88,8 +88,8 @@ public Expression visit(Path expr, C context) { var metadata = expr.getMetadata(); Path parent = (Path) metadata.getParent().accept(this, context); var element = metadata.getElement(); - if (element instanceof Expression) { - element = ((Expression) element).accept(this, context); + if (element instanceof Expression expression) { + element = expression.accept(this, context); } if (parent.equals(metadata.getParent()) && Objects.equals(element, metadata.getElement())) { return expr; @@ -155,8 +155,8 @@ public Expression visit(SubQueryExpression expr, C context) { public Expression visit(TemplateExpression expr, C context) { ArrayList args = new ArrayList<>(); for (Object arg : expr.getArgs()) { - if (arg instanceof Expression) { - args.add(((Expression) arg).accept(this, context)); + if (arg instanceof Expression expression) { + args.add(expression.accept(this, context)); } else { args.add(arg); } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/SerializerBase.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/SerializerBase.java index 616a92bb07..8af04c3ac4 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/SerializerBase.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/support/SerializerBase.java @@ -116,8 +116,8 @@ public final S handle(Expression expr) { } public final S handle(Object arg) { - if (arg instanceof Expression) { - ((Expression) arg).accept(this, null); + if (arg instanceof Expression expression) { + expression.accept(this, null); } else { visitConstant(arg); } @@ -146,8 +146,8 @@ public final S handle(final String sep, final List> expr protected void handleTemplate(final Template template, final List args) { for (final Template.Element element : template.getElements()) { final var rv = element.convert(args); - if (rv instanceof Expression) { - ((Expression) rv).accept(this, null); + if (rv instanceof Expression expression) { + expression.accept(this, null); } else if (element.isString()) { builder.append(rv.toString()); } else { @@ -304,10 +304,9 @@ protected void visitOperation( var first = true; for (final Template.Element element : template.getElements()) { final var rv = element.convert(args); - if (rv instanceof Expression) { - final Expression expr = (Expression) rv; - if (precedence > -1 && expr instanceof Operation) { - var op = ((Operation) expr).getOperator(); + if (rv instanceof Expression expr) { + if (precedence > -1 && expr instanceof Operation operation) { + var op = operation.getOperator(); var opPrecedence = templates.getPrecedence(op); if (precedence < opPrecedence) { append("(").handle(expr).append(")"); @@ -328,9 +327,8 @@ protected void visitOperation( } } else if (strict) { throw new IllegalArgumentException( - String.format( - "No pattern found for %s. Make sure to register any custom functions with %s.", - operator, templates.getClass())); + "No pattern found for %s. Make sure to register any custom functions with %s." + .formatted(operator, templates.getClass())); } else { append(operator.toString()); append("("); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ArrayConstructorExpression.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ArrayConstructorExpression.java index f322258b6c..2636397bd4 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ArrayConstructorExpression.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ArrayConstructorExpression.java @@ -79,8 +79,7 @@ public List> getArgs() { public boolean equals(Object obj) { if (obj == this) { return true; - } else if (obj instanceof FactoryExpression) { - FactoryExpression c = (FactoryExpression) obj; + } else if (obj instanceof FactoryExpression c) { return args.equals(c.getArgs()) && getType().equals(c.getType()); } else { return false; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ConstantImpl.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ConstantImpl.java index e0654d09f0..d5d4325139 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ConstantImpl.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ConstantImpl.java @@ -144,8 +144,8 @@ public R accept(Visitor v, C context) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof Constant) { - return ((Constant) o).getConstant().equals(constant); + } else if (o instanceof Constant constant1) { + return constant1.getConstant().equals(constant); } else { return false; } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ConstructorExpression.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ConstructorExpression.java index 61fe66bf3b..46014baf3e 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ConstructorExpression.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ConstructorExpression.java @@ -115,8 +115,7 @@ public R accept(Visitor v, C context) { public boolean equals(Object obj) { if (obj == this) { return true; - } else if (obj instanceof ConstructorExpression) { - ConstructorExpression c = (ConstructorExpression) obj; + } else if (obj instanceof ConstructorExpression c) { return Arrays.equals(parameterTypes, c.parameterTypes) && args.equals(c.args) && getType().equals(c.getType()); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java index 7daab4481b..32fa19d86f 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ExpressionUtils.java @@ -548,8 +548,7 @@ public static Expression likeToRegex(Expression expr, boolean ma if (!like.equals(rv.toString())) { return ConstantImpl.create(rv.toString()); } - } else if (expr instanceof Operation) { - Operation o = (Operation) expr; + } else if (expr instanceof Operation o) { if (o.getOperator() == Ops.CONCAT) { var lhs = likeToRegex((Expression) o.getArg(0), false); var rhs = likeToRegex((Expression) o.getArg(1), false); @@ -628,8 +627,7 @@ public static Expression regexToLike(Expression expr) { if (!rv.toString().equals(str)) { return ConstantImpl.create(rv.toString()); } - } else if (expr instanceof Operation) { - Operation o = (Operation) expr; + } else if (expr instanceof Operation o) { if (o.getOperator() == Ops.CONCAT) { var lhs = regexToLike((Expression) o.getArg(0)); var rhs = regexToLike((Expression) o.getArg(1)); @@ -820,8 +818,8 @@ public static String createRootVariable(Path path) { * @return converted argument */ public static Expression toExpression(Object o) { - if (o instanceof Expression) { - return (Expression) o; + if (o instanceof Expression expression) { + return expression; } else { return ConstantImpl.create(o); } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/FactoryExpressionBase.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/FactoryExpressionBase.java index d1f5d9e40b..d339ca6987 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/FactoryExpressionBase.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/FactoryExpressionBase.java @@ -61,8 +61,8 @@ public R accept(Visitor v, @Nullable C context) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof FactoryExpressionWrapper) { - return expr.equals(((FactoryExpressionWrapper) o).expr); + } else if (o instanceof FactoryExpressionWrapper wrapper) { + return expr.equals(wrapper.expr); } else { return false; } @@ -86,8 +86,8 @@ public FactoryExpression skipNulls() { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof FactoryExpression) { - return getClass().equals(o.getClass()) && getArgs().equals(((FactoryExpression) o).getArgs()); + } else if (o instanceof FactoryExpression expression) { + return getClass().equals(o.getClass()) && getArgs().equals(expression.getArgs()); } else { return false; } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/FactoryExpressionUtils.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/FactoryExpressionUtils.java index 4b5b495222..904e49e2da 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/FactoryExpressionUtils.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/FactoryExpressionUtils.java @@ -71,8 +71,7 @@ public R accept(Visitor v, C context) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof FactoryExpression) { - FactoryExpression e = (FactoryExpression) o; + } else if (o instanceof FactoryExpression e) { return args.equals(e.getArgs()) && getType().equals(e.getType()); } else { return false; @@ -99,8 +98,8 @@ public static FactoryExpression wrap( public static FactoryExpression wrap(FactoryExpression expr) { for (Expression arg : expr.getArgs()) { - if (arg instanceof ProjectionRole) { - arg = ((ProjectionRole) arg).getProjection(); + if (arg instanceof ProjectionRole role) { + arg = role.getProjection(); } if (arg instanceof FactoryExpression) { return new FactoryExpressionAdapter<>(expr); @@ -112,11 +111,11 @@ public static FactoryExpression wrap(FactoryExpression expr) { private static List> expand(List> exprs) { List> rv = new ArrayList<>(exprs.size()); for (Expression expr : exprs) { - if (expr instanceof ProjectionRole) { - expr = ((ProjectionRole) expr).getProjection(); + if (expr instanceof ProjectionRole role) { + expr = role.getProjection(); } - if (expr instanceof FactoryExpression) { - rv.addAll(expand(((FactoryExpression) expr).getArgs())); + if (expr instanceof FactoryExpression expression) { + rv.addAll(expand(expression.getArgs())); } else { rv.add(expr); } @@ -127,11 +126,11 @@ private static List> expand(List> exprs) { private static int countArguments(FactoryExpression expr) { var counter = 0; for (Expression arg : expr.getArgs()) { - if (arg instanceof ProjectionRole) { - arg = ((ProjectionRole) arg).getProjection(); + if (arg instanceof ProjectionRole role) { + arg = role.getProjection(); } - if (arg instanceof FactoryExpression) { - counter += countArguments((FactoryExpression) arg); + if (arg instanceof FactoryExpression expression) { + counter += countArguments(expression); } else { counter++; } @@ -144,11 +143,10 @@ private static Object[] compress(List> exprs, Object[] args) { var offset = 0; for (var i = 0; i < exprs.size(); i++) { Expression expr = exprs.get(i); - if (expr instanceof ProjectionRole) { - expr = ((ProjectionRole) expr).getProjection(); + if (expr instanceof ProjectionRole role) { + expr = role.getProjection(); } - if (expr instanceof FactoryExpression) { - FactoryExpression fe = (FactoryExpression) expr; + if (expr instanceof FactoryExpression fe) { var fullArgsLength = countArguments(fe); var compressed = compress(fe.getArgs(), ArrayUtils.subarray(args, offset, offset + fullArgsLength)); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/OperationImpl.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/OperationImpl.java index 88902cd8fe..cab09a78ce 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/OperationImpl.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/OperationImpl.java @@ -69,8 +69,7 @@ public final Operator getOperator() { public final boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof Operation) { - Operation op = (Operation) o; + } else if (o instanceof Operation op) { return op.getOperator() == operator && op.getArgs().equals(args) && op.getType().equals(getType()); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/OrderSpecifier.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/OrderSpecifier.java index 8d4b79eb79..bffb4bb3df 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/OrderSpecifier.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/OrderSpecifier.java @@ -113,8 +113,7 @@ public String toString() { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof OrderSpecifier) { - OrderSpecifier os = (OrderSpecifier) o; + } else if (o instanceof OrderSpecifier os) { return os.order.equals(order) && os.target.equals(target) && os.nullHandling.equals(nullHandling); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ParamExpressionImpl.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ParamExpressionImpl.java index 5a56220841..f679136431 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ParamExpressionImpl.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ParamExpressionImpl.java @@ -52,8 +52,7 @@ public final R accept(Visitor v, C context) { public final boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof ParamExpression) { - ParamExpression other = (ParamExpression) o; + } else if (o instanceof ParamExpression other) { return other.getType().equals(getType()) && other.getName().equals(name) && other.isAnon() == anon; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ParamsVisitor.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ParamsVisitor.java index 8e781dba8c..157327eb46 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ParamsVisitor.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ParamsVisitor.java @@ -78,8 +78,8 @@ public Void visit(SubQueryExpression expr, QueryMetadata context) { @Override public Void visit(TemplateExpression expr, QueryMetadata context) { for (Object arg : expr.getArgs()) { - if (arg instanceof Expression) { - ((Expression) arg).accept(this, context); + if (arg instanceof Expression expression) { + expression.accept(this, context); } } return null; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/PathExtractor.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/PathExtractor.java index 4407d026a2..11ddcd94f2 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/PathExtractor.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/PathExtractor.java @@ -63,8 +63,8 @@ public Path visit(TemplateExpression expr, Void context) { private Path visit(List exprs) { for (Object e : exprs) { - if (e instanceof Expression) { - Path path = ((Expression) e).accept(this, null); + if (e instanceof Expression expression) { + Path path = expression.accept(this, null); if (path != null) { return path; } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/PathImpl.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/PathImpl.java index d68598132d..404e45d52f 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/PathImpl.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/PathImpl.java @@ -53,8 +53,8 @@ protected PathImpl(Class type, Path parent, String property) { public final boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof Path) { - return ((Path) o).getMetadata().equals(metadata); + } else if (o instanceof Path path) { + return path.getMetadata().equals(metadata); } else { return false; } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/PathMetadata.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/PathMetadata.java index ecee9e0c86..aaf2df59f1 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/PathMetadata.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/PathMetadata.java @@ -48,8 +48,7 @@ public PathMetadata(@Nullable Path parent, Object element, PathType type) { public boolean equals(Object obj) { if (obj == this) { return true; - } else if (obj instanceof PathMetadata) { - var p = (PathMetadata) obj; + } else if (obj instanceof PathMetadata p) { return element.equals(p.element) && pathType == p.pathType && Objects.equals(parent, p.parent); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QBean.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QBean.java index 57d5b5eedf..728c9c9734 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QBean.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QBean.java @@ -50,11 +50,9 @@ public class QBean extends FactoryExpressionBase { private static Map> createBindings(Expression... args) { Map> rv = new LinkedHashMap<>(); for (Expression expr : args) { - if (expr instanceof Path) { - Path path = (Path) expr; + if (expr instanceof Path path) { rv.put(path.getMetadata().getName(), expr); - } else if (expr instanceof Operation) { - Operation operation = (Operation) expr; + } else if (expr instanceof Operation operation) { if (operation.getOperator() == Ops.ALIAS && operation.getArg(1) instanceof Path) { Path path = (Path) operation.getArg(1); if (isCompoundExpression(operation.getArg(0))) { @@ -275,8 +273,7 @@ public R accept(Visitor v, C context) { public boolean equals(Object obj) { if (obj == this) { return true; - } else if (obj instanceof QBean) { - QBean c = (QBean) obj; + } else if (obj instanceof QBean c) { return getArgs().equals(c.getArgs()) && getType().equals(c.getType()); } else { return false; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QList.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QList.java index ec82ca5cee..a45334860f 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QList.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QList.java @@ -85,8 +85,7 @@ public List> getArgs() { public boolean equals(Object obj) { if (obj == this) { return true; - } else if (obj instanceof FactoryExpression) { - FactoryExpression c = (FactoryExpression) obj; + } else if (obj instanceof FactoryExpression c) { return args.equals(c.getArgs()) && getType().equals(c.getType()); } else { return false; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QMap.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QMap.java index 6cec693164..2c1d95e466 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QMap.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QMap.java @@ -97,8 +97,7 @@ public List> getArgs() { public boolean equals(Object obj) { if (obj == this) { return true; - } else if (obj instanceof FactoryExpression) { - FactoryExpression c = (FactoryExpression) obj; + } else if (obj instanceof FactoryExpression c) { return args.equals(c.getArgs()) && getType().equals(c.getType()); } else { return false; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QTuple.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QTuple.java index 7e20b1ce5a..c5becc3463 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QTuple.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/QTuple.java @@ -58,8 +58,8 @@ private static Map, Integer> createBindings(List> ex Map, Integer> map = new LinkedHashMap<>(); for (var i = 0; i < exprs.size(); i++) { Expression e = exprs.get(i); - if (e instanceof Operation && ((Operation) e).getOperator() == Ops.ALIAS) { - map.put(((Operation) e).getArg(1), i); + if (e instanceof Operation operation && operation.getOperator() == Ops.ALIAS) { + map.put(operation.getArg(1), i); } map.put(e, i); } @@ -107,8 +107,8 @@ public Object[] toArray() { public boolean equals(Object obj) { if (obj == this) { return true; - } else if (obj instanceof Tuple) { - return Arrays.equals(a, ((Tuple) obj).toArray()); + } else if (obj instanceof Tuple tuple) { + return Arrays.equals(a, tuple.toArray()); } else { return false; } @@ -180,8 +180,7 @@ public R accept(Visitor v, C context) { public boolean equals(Object obj) { if (obj == this) { return true; - } else if (obj instanceof FactoryExpression) { - FactoryExpression c = (FactoryExpression) obj; + } else if (obj instanceof FactoryExpression c) { return args.equals(c.getArgs()) && getType().equals(c.getType()); } else { return false; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/Template.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/Template.java index 249ffddb1b..1965fb8e23 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/Template.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/Template.java @@ -173,8 +173,8 @@ public ByIndex(int index) { @Override public Object convert(final List args) { final Object arg = args.get(index); - if (arg instanceof Expression) { - return ExpressionUtils.extract((Expression) arg); + if (arg instanceof Expression expression) { + return ExpressionUtils.extract(expression); } else { return arg; } @@ -223,20 +223,19 @@ public Object convert(List args) { Expression expr1 = asExpression(arg1); Expression expr2 = asExpression(arg2); - if (arg2 instanceof Number) { + if (arg2 instanceof Number number) { if (CONVERTIBLES.contains(operator) - && expr1 instanceof com.querydsl.core.types.Operation) { - var operation = (com.querydsl.core.types.Operation) expr1; + && expr1 instanceof com.querydsl.core.types.Operation operation) { if (CONVERTIBLES.contains(operation.getOperator()) && operation.getArg(1) instanceof Constant) { var num1 = ((Constant) operation.getArg(1)).getConstant(); Number num2; if (operator == operation.getOperator()) { - num2 = MathUtils.result(num1, (Number) arg2, Ops.ADD); + num2 = MathUtils.result(num1, number, Ops.ADD); } else if (operator == Ops.ADD) { - num2 = MathUtils.result((Number) arg2, num1, Ops.SUB); + num2 = MathUtils.result(number, num1, Ops.SUB); } else { - num2 = MathUtils.result(num1, (Number) arg2, Ops.SUB); + num2 = MathUtils.result(num1, number, Ops.SUB); } return ExpressionUtils.operation( expr1.getType(), operator, operation.getArg(0), Expressions.constant(num2)); @@ -295,8 +294,8 @@ public Object convert(List args) { } else { Expression expr1 = asExpression(arg1); - if (CONVERTIBLES.contains(operator) && expr1 instanceof com.querydsl.core.types.Operation) { - var operation = (com.querydsl.core.types.Operation) expr1; + if (CONVERTIBLES.contains(operator) + && expr1 instanceof com.querydsl.core.types.Operation operation) { if (CONVERTIBLES.contains(operation.getOperator()) && operation.getArg(1) instanceof Constant) { var num1 = ((Constant) operation.getArg(1)).getConstant(); @@ -350,8 +349,8 @@ public String toString() { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof Template) { - return ((Template) o).template.equals(template); + } else if (o instanceof Template template1) { + return template1.template.equals(template); } else { return false; } @@ -363,23 +362,22 @@ public int hashCode() { } private static Number asNumber(Object arg) { - if (arg instanceof Number) { - return (Number) arg; - } else if (arg instanceof Constant) { - return (Number) ((Constant) arg).getConstant(); + if (arg instanceof Number number) { + return number; + } else if (arg instanceof Constant constant) { + return (Number) constant.getConstant(); } else { throw new IllegalArgumentException(arg.toString()); } } private static boolean isNumber(Object o) { - return o instanceof Number - || o instanceof Constant && ((Constant) o).getConstant() instanceof Number; + return o instanceof Number || o instanceof Constant c && c.getConstant() instanceof Number; } private static Expression asExpression(Object arg) { - if (arg instanceof Expression) { - return ExpressionUtils.extract((Expression) arg); + if (arg instanceof Expression expression) { + return ExpressionUtils.extract(expression); } else { return Expressions.constant(arg); } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateExpressionImpl.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateExpressionImpl.java index 6d48e69775..5032e1f093 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateExpressionImpl.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateExpressionImpl.java @@ -64,8 +64,7 @@ public final Template getTemplate() { public final boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof TemplateExpression) { - TemplateExpression c = (TemplateExpression) o; + } else if (o instanceof TemplateExpression c) { return c.getTemplate().equals(template) && c.getType().equals(getType()) && c.getArgs().equals(args); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java index 3e07b0b9db..298610663c 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java @@ -67,8 +67,8 @@ public class TemplateFactory { public Object apply(Object arg) { if (arg instanceof Constant) { return ConstantImpl.create(apply(arg.toString()).toString()); - } else if (arg instanceof Expression) { - return ExpressionUtils.operation(String.class, Ops.LOWER, (Expression) arg); + } else if (arg instanceof Expression expression) { + return ExpressionUtils.operation(String.class, Ops.LOWER, expression); } else { return String.valueOf(arg).toLowerCase(); } @@ -81,8 +81,8 @@ public Object apply(Object arg) { public Object apply(Object arg) { if (arg instanceof Constant) { return ConstantImpl.create(apply(arg.toString()).toString()); - } else if (arg instanceof Expression) { - return ExpressionUtils.operation(String.class, Ops.UPPER, (Expression) arg); + } else if (arg instanceof Expression expression) { + return ExpressionUtils.operation(String.class, Ops.UPPER, expression); } else { return String.valueOf(arg).toUpperCase(); } @@ -95,8 +95,8 @@ public Object apply(Object arg) { public Object apply(Object arg) { if (arg instanceof Constant) { return ConstantImpl.create(apply(arg.toString()).toString()); - } else if (arg instanceof Expression) { - return ExpressionUtils.operation(String.class, Ops.CONCAT, (Expression) arg, PERCENT); + } else if (arg instanceof Expression expression) { + return ExpressionUtils.operation(String.class, Ops.CONCAT, expression, PERCENT); } else { return escapeForLike(String.valueOf(arg)) + "%"; } @@ -109,9 +109,9 @@ public Object apply(Object arg) { public Object apply(Object arg) { if (arg instanceof Constant) { return ConstantImpl.create(apply(arg.toString()).toString()); - } else if (arg instanceof Expression) { + } else if (arg instanceof Expression expression) { Expression concatenated = - ExpressionUtils.operation(String.class, Ops.CONCAT, (Expression) arg, PERCENT); + ExpressionUtils.operation(String.class, Ops.CONCAT, expression, PERCENT); return ExpressionUtils.operation(String.class, Ops.LOWER, concatenated); } else { return escapeForLike(String.valueOf(arg).toLowerCase()) + "%"; @@ -125,8 +125,8 @@ public Object apply(Object arg) { public Object apply(Object arg) { if (arg instanceof Constant) { return ConstantImpl.create(apply(arg.toString()).toString()); - } else if (arg instanceof Expression) { - return ExpressionUtils.operation(String.class, Ops.CONCAT, PERCENT, (Expression) arg); + } else if (arg instanceof Expression expression) { + return ExpressionUtils.operation(String.class, Ops.CONCAT, PERCENT, expression); } else { return "%" + escapeForLike(String.valueOf(arg)); } @@ -139,9 +139,9 @@ public Object apply(Object arg) { public Object apply(Object arg) { if (arg instanceof Constant) { return ConstantImpl.create(apply(arg.toString()).toString()); - } else if (arg instanceof Expression) { + } else if (arg instanceof Expression expression) { Expression concatenated = - ExpressionUtils.operation(String.class, Ops.CONCAT, PERCENT, (Expression) arg); + ExpressionUtils.operation(String.class, Ops.CONCAT, PERCENT, expression); return ExpressionUtils.operation(String.class, Ops.LOWER, concatenated); } else { return "%" + escapeForLike(String.valueOf(arg).toLowerCase()); @@ -155,9 +155,9 @@ public Object apply(Object arg) { public Object apply(Object arg) { if (arg instanceof Constant) { return ConstantImpl.create(apply(arg.toString()).toString()); - } else if (arg instanceof Expression) { + } else if (arg instanceof Expression expression) { Expression concatenated = - ExpressionUtils.operation(String.class, Ops.CONCAT, PERCENT, (Expression) arg); + ExpressionUtils.operation(String.class, Ops.CONCAT, PERCENT, expression); return ExpressionUtils.operation(String.class, Ops.CONCAT, concatenated, PERCENT); } else { return "%" + escapeForLike(String.valueOf(arg)) + "%"; @@ -171,9 +171,9 @@ public Object apply(Object arg) { public Object apply(Object arg) { if (arg instanceof Constant) { return ConstantImpl.create(apply(arg.toString()).toString()); - } else if (arg instanceof Expression) { + } else if (arg instanceof Expression expression) { Expression concatenated = - ExpressionUtils.operation(String.class, Ops.CONCAT, PERCENT, (Expression) arg); + ExpressionUtils.operation(String.class, Ops.CONCAT, PERCENT, expression); concatenated = ExpressionUtils.operation(String.class, Ops.CONCAT, concatenated, PERCENT); return ExpressionUtils.operation(String.class, Ops.LOWER, concatenated); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ToStringVisitor.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ToStringVisitor.java index 4a5614c7c7..0e4713dbfe 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ToStringVisitor.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ToStringVisitor.java @@ -57,16 +57,16 @@ public String visit(Operation o, Templates templates) { final var builder = new StringBuilder(); for (Template.Element element : template.getElements()) { final var rv = element.convert(o.getArgs()); - if (rv instanceof Expression) { - if (precedence > -1 && rv instanceof Operation) { - if (precedence < templates.getPrecedence(((Operation) rv).getOperator())) { + if (rv instanceof Expression expression) { + if (precedence > -1 && rv instanceof Operation operation) { + if (precedence < templates.getPrecedence(operation.getOperator())) { builder.append("("); - builder.append(((Expression) rv).accept(this, templates)); + builder.append(operation.accept(this, templates)); builder.append(")"); continue; } } - builder.append(((Expression) rv).accept(this, templates)); + builder.append(expression.accept(this, templates)); } else { builder.append(rv.toString()); } @@ -96,8 +96,8 @@ public String visit(Path p, Templates templates) { final var builder = new StringBuilder(); for (Template.Element element : pattern.getElements()) { var rv = element.convert(args); - if (rv instanceof Expression) { - builder.append(((Expression) rv).accept(this, templates)); + if (rv instanceof Expression expression) { + builder.append(expression.accept(this, templates)); } else { builder.append(rv.toString()); } @@ -121,8 +121,8 @@ public String visit(TemplateExpression expr, Templates templates) { final var builder = new StringBuilder(); for (Template.Element element : expr.getTemplate().getElements()) { var rv = element.convert(expr.getArgs()); - if (rv instanceof Expression) { - builder.append(((Expression) rv).accept(this, templates)); + if (rv instanceof Expression expression) { + builder.append(expression.accept(this, templates)); } else { builder.append(rv.toString()); } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ValidatingVisitor.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ValidatingVisitor.java index a706b05d6b..29e01ba769 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ValidatingVisitor.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ValidatingVisitor.java @@ -74,7 +74,7 @@ public Set> visit(ParamExpression expr, Set> know @Override public Set> visit(Path expr, Set> known) { if (!known.contains(expr.getRoot())) { - throw new IllegalArgumentException(String.format(errorTemplate, expr.getRoot())); + throw new IllegalArgumentException(errorTemplate.formatted(expr.getRoot())); } return known; } @@ -105,8 +105,8 @@ public Set> visit(SubQueryExpression expr, Set> k @Override public Set> visit(TemplateExpression expr, Set> known) { for (Object arg : expr.getArgs()) { - if (arg instanceof Expression) { - known = ((Expression) arg).accept(this, known); + if (arg instanceof Expression expression) { + known = expression.accept(this, known); } } return known; @@ -115,7 +115,7 @@ public Set> visit(TemplateExpression expr, Set> k private Set> visitJoins(Iterable joins, Set> known) { for (JoinExpression j : joins) { final Expression expr = j.getTarget(); - if (expr instanceof Path && ((Path) expr).getMetadata().isRoot()) { + if (expr instanceof Path path && path.getMetadata().isRoot()) { known = add(known, expr); } else { known = expr.accept(this, known); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/CaseBuilder.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/CaseBuilder.java index a6b9ea83ed..78bea33593 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/CaseBuilder.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/CaseBuilder.java @@ -158,20 +158,20 @@ public Initial(Predicate b) { @SuppressWarnings("unchecked") public Cases> then(Expression expr) { - if (expr instanceof Predicate) { - return (Cases) then((Predicate) expr); - } else if (expr instanceof StringExpression) { - return (Cases) then((StringExpression) expr); - } else if (expr instanceof NumberExpression) { - return then((NumberExpression) expr); - } else if (expr instanceof DateExpression) { - return then((DateExpression) expr); - } else if (expr instanceof DateTimeExpression) { - return then((DateTimeExpression) expr); - } else if (expr instanceof TimeExpression) { - return then((TimeExpression) expr); - } else if (expr instanceof ComparableExpression) { - return then((ComparableExpression) expr); + if (expr instanceof Predicate predicate) { + return (Cases) then(predicate); + } else if (expr instanceof StringExpression se) { + return (Cases) then(se); + } else if (expr instanceof NumberExpression ne) { + return then(ne); + } else if (expr instanceof DateExpression de) { + return then(de); + } else if (expr instanceof DateTimeExpression dte) { + return then(dte); + } else if (expr instanceof TimeExpression te) { + return then(te); + } else if (expr instanceof ComparableExpression ce) { + return then(ce); } else { return thenSimple(expr); } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/CaseForEqBuilder.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/CaseForEqBuilder.java index 25ac608961..87adfe554f 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/CaseForEqBuilder.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/CaseForEqBuilder.java @@ -76,20 +76,20 @@ public CaseForEqBuilder(Expression base, Expression other) { } public Cases> then(Expression expr) { - if (expr instanceof Predicate) { - return (Cases) then((Predicate) expr); - } else if (expr instanceof StringExpression) { - return (Cases) then((StringExpression) expr); - } else if (expr instanceof NumberExpression) { - return then((NumberExpression) expr); - } else if (expr instanceof DateExpression) { - return then((DateExpression) expr); - } else if (expr instanceof DateTimeExpression) { - return then((DateTimeExpression) expr); - } else if (expr instanceof TimeExpression) { - return then((TimeExpression) expr); - } else if (expr instanceof ComparableExpression) { - return then((ComparableExpression) expr); + if (expr instanceof Predicate p) { + return (Cases) then(p); + } else if (expr instanceof StringExpression se) { + return (Cases) then(se); + } else if (expr instanceof NumberExpression ne) { + return then(ne); + } else if (expr instanceof DateExpression de) { + return then(de); + } else if (expr instanceof DateTimeExpression dte) { + return then(dte); + } else if (expr instanceof TimeExpression te) { + return then(te); + } else if (expr instanceof ComparableExpression ce) { + return then(ce); } else { return thenSimple(expr); } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Coalesce.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Coalesce.java index d423015dd8..7af91de5b5 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Coalesce.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Coalesce.java @@ -145,8 +145,7 @@ private Expression getExpressionList() { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof Coalesce) { - Coalesce c = (Coalesce) o; + } else if (o instanceof Coalesce c) { return c.exprs.equals(exprs); } else { return false; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java index f4f6e6507b..548f90a312 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java @@ -1580,10 +1580,10 @@ public static BooleanExpression asBoolean(Expression expr) { Expression underlyingMixin = ExpressionUtils.extract(expr); if (underlyingMixin instanceof PathImpl) { return new BooleanPath((PathImpl) underlyingMixin); - } else if (underlyingMixin instanceof PredicateOperation) { - return new BooleanOperation((PredicateOperation) underlyingMixin); - } else if (underlyingMixin instanceof PredicateTemplate) { - return new BooleanTemplate((PredicateTemplate) underlyingMixin); + } else if (underlyingMixin instanceof PredicateOperation operation) { + return new BooleanOperation(operation); + } else if (underlyingMixin instanceof PredicateTemplate template) { + return new BooleanTemplate(template); } else { return new BooleanExpression(underlyingMixin) { @@ -1598,8 +1598,7 @@ public R accept(Visitor v, C context) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof BooleanExpression) { - var other = (BooleanExpression) o; + } else if (o instanceof BooleanExpression other) { return (other.mixin.equals(this.mixin)); } else { return false; @@ -1647,8 +1646,7 @@ public R accept(Visitor v, C context) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof ComparableExpression) { - var other = (ComparableExpression) o; + } else if (o instanceof ComparableExpression other) { return (other.mixin.equals(this.mixin)); } else { return false; @@ -1807,8 +1805,7 @@ public R accept(Visitor v, C context) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof EnumExpression) { - var other = (EnumExpression) o; + } else if (o instanceof EnumExpression other) { return (other.mixin.equals(this.mixin)); } else { return false; @@ -1857,8 +1854,7 @@ public R accept(Visitor v, C context) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof NumberExpression) { - var other = (NumberExpression) o; + } else if (o instanceof NumberExpression other) { return (other.mixin.equals(this.mixin)); } else { return false; @@ -1906,8 +1902,7 @@ public R accept(Visitor v, C context) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof StringExpression) { - var other = (StringExpression) o; + } else if (o instanceof StringExpression other) { return (other.mixin.equals(this.mixin)); } else { return false; diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/MathUtils.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/MathUtils.java index d17416075b..c7b1cfadbd 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/MathUtils.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/MathUtils.java @@ -75,21 +75,21 @@ public static D cast(Number num, Class type) { } else if (type.equals(BigDecimal.class)) { rv = type.cast(new BigDecimal(num.toString())); } else if (type.equals(BigInteger.class)) { - if (num instanceof BigDecimal) { - rv = type.cast(((BigDecimal) num).toBigInteger()); + if (num instanceof BigDecimal decimal) { + rv = type.cast(decimal.toBigInteger()); } else { rv = type.cast(new BigInteger(num.toString())); } } else { throw new IllegalArgumentException( - String.format("Unsupported target type : %s", type.getSimpleName())); + "Unsupported target type : %s".formatted(type.getSimpleName())); } return rv; } private static BigDecimal toBigDecimal(Number num) { - if (num instanceof BigDecimal) { - return (BigDecimal) num; + if (num instanceof BigDecimal decimal) { + return decimal; } else { return new BigDecimal(num.toString()); } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/ReflectionUtils.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/ReflectionUtils.java index 32315f4226..f4266a5343 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/ReflectionUtils.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/ReflectionUtils.java @@ -92,10 +92,10 @@ public static Method getGetterOrNull(Class beanClass, String name, Class t } public static int getTypeParameterCount(java.lang.reflect.Type type) { - if (type instanceof ParameterizedType) { - return ((ParameterizedType) type).getActualTypeArguments().length; - } else if (type instanceof TypeVariable) { - return getTypeParameterCount(((TypeVariable) type).getBounds()[0]); + if (type instanceof ParameterizedType parameterizedType) { + return parameterizedType.getActualTypeArguments().length; + } else if (type instanceof TypeVariable variable) { + return getTypeParameterCount(variable.getBounds()[0]); } else { return 0; } @@ -112,34 +112,33 @@ public static Class getTypeParameterAsClass(java.lang.reflect.Type type, int @Nullable public static Type getTypeParameter(java.lang.reflect.Type type, int index) { - if (type instanceof ParameterizedType) { - return ((ParameterizedType) type).getActualTypeArguments()[index]; - } else if (type instanceof TypeVariable) { - return getTypeParameter(((TypeVariable) type).getBounds()[0], index); + if (type instanceof ParameterizedType parameterizedType) { + return parameterizedType.getActualTypeArguments()[index]; + } else if (type instanceof TypeVariable variable) { + return getTypeParameter(variable.getBounds()[0], index); } else { return null; } } private static Class asClass(Type type) { - if (type instanceof WildcardType) { - var wildcardType = (WildcardType) type; - if (wildcardType.getUpperBounds()[0] instanceof Class) { - return (Class) wildcardType.getUpperBounds()[0]; - } else if (wildcardType.getUpperBounds()[0] instanceof ParameterizedType) { - return (Class) ((ParameterizedType) wildcardType.getUpperBounds()[0]).getRawType(); + if (type instanceof WildcardType wildcardType) { + if (wildcardType.getUpperBounds()[0] instanceof Class class1) { + return class1; + } else if (wildcardType.getUpperBounds()[0] instanceof ParameterizedType parameterizedType) { + return (Class) parameterizedType.getRawType(); } else { return Object.class; } - } else if (type instanceof TypeVariable) { - return asClass(((TypeVariable) type).getBounds()[0]); - } else if (type instanceof ParameterizedType) { - return (Class) ((ParameterizedType) type).getRawType(); - } else if (type instanceof GenericArrayType) { - var component = ((GenericArrayType) type).getGenericComponentType(); + } else if (type instanceof TypeVariable variable) { + return asClass(variable.getBounds()[0]); + } else if (type instanceof ParameterizedType parameterizedType) { + return (Class) parameterizedType.getRawType(); + } else if (type instanceof GenericArrayType arrayType) { + var component = arrayType.getGenericComponentType(); return Array.newInstance(asClass(component), 0).getClass(); - } else if (type instanceof Class) { - return (Class) type; + } else if (type instanceof Class class1) { + return class1; } else { throw new IllegalArgumentException(type.getClass().toString()); } diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/TupleUtils.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/TupleUtils.java index 86ef005d21..5f133bb253 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/TupleUtils.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/TupleUtils.java @@ -10,12 +10,12 @@ public final class TupleUtils { public static Tuple toTuple(Object next, Expression[] expressions) { // workaround from https://github.com/querydsl/querydsl/issues/3264 Tuple tuple; - if (next instanceof Tuple) { - tuple = (Tuple) next; - } else if (next instanceof Object[]) { - tuple = Projections.tuple(expressions).newInstance((Object[]) next); + if (next instanceof Tuple tuple1) { + tuple = tuple1; + } else if (next instanceof Object[] objects) { + tuple = Projections.tuple(expressions).newInstance(objects); } else { - throw new IllegalArgumentException(String.format("Could not translate %s into tuple", next)); + throw new IllegalArgumentException("Could not translate %s into tuple".formatted(next)); } return tuple; } diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java index d780470bdd..b1c80c0bb8 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java @@ -384,10 +384,10 @@ private void serializeSources(boolean forCountRow, List joins) { @Override public void visitConstant(Object constant) { if (inCaseOperation && templates.isCaseWithLiterals()) { - if (constant instanceof Collection) { + if (constant instanceof Collection collection) { append("("); var first = true; - for (Object o : (Collection) constant) { + for (Object o : collection) { if (!first) { append(", "); } diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLTemplates.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLTemplates.java index 8f0d3e73b9..dbb89a0ff5 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLTemplates.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLTemplates.java @@ -212,8 +212,8 @@ public String asLiteral(Object constant) { return constant.toString(); } else if (constant instanceof String) { return "'" + escapeLiteral(constant.toString()) + "'"; - } else if (constant instanceof Enum) { - return constant.getClass().getName() + "." + ((Enum) constant).name(); + } else if (constant instanceof Enum enum1) { + return constant.getClass().getName() + "." + enum1.name(); } else { return "'" + constant.toString() + "'"; } diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/NativeSQLSerializer.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/NativeSQLSerializer.java index 5f6aa5c193..a97948db54 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/NativeSQLSerializer.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/NativeSQLSerializer.java @@ -205,10 +205,10 @@ private static ArrayList createArrayList(Object key) { @Override public void visitConstant(Object constant) { - if (constant instanceof Collection) { + if (constant instanceof Collection collection) { append("("); var first = true; - for (Object element : ((Collection) constant)) { + for (Object element : collection) { if (!first) { append(", "); } diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/TransformingIterator.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/TransformingIterator.java index b90fb534b2..76e013cf2f 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/TransformingIterator.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/TransformingIterator.java @@ -37,7 +37,7 @@ public class TransformingIterator implements CloseableIterator { public TransformingIterator(Iterator iterator, FactoryExpression projection) { this.iterator = iterator; this.projection = projection; - this.closeable = iterator instanceof Closeable ? (Closeable) iterator : null; + this.closeable = iterator instanceof Closeable c ? c : null; } public TransformingIterator( diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/HibernateUtil.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/HibernateUtil.java index f8eb6dea36..1f7007b790 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/HibernateUtil.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/hibernate/HibernateUtil.java @@ -108,10 +108,10 @@ public static void setConstants( private static void setValueWithNumberedLabel( org.hibernate.query.Query query, Integer key, Object val) { - if (val instanceof Collection) { - query.setParameterList(key, (Collection) val); - } else if (val instanceof Object[] && !BUILT_IN.contains(val.getClass())) { - query.setParameterList(key, (Object[]) val); + if (val instanceof Collection collection) { + query.setParameterList(key, collection); + } else if (val instanceof Object[] objects && !BUILT_IN.contains(val.getClass())) { + query.setParameterList(key, objects); } else if (val instanceof Number && TYPES.containsKey(val.getClass())) { query.setParameter(key, val, getType(val.getClass())); } else { diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/JPAUtil.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/JPAUtil.java index b3e4719f6b..adacb516c3 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/JPAUtil.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/JPAUtil.java @@ -50,8 +50,8 @@ public static void setConstants( Parameter parameter = query.getParameter(i + 1); var parameterType = parameter != null ? parameter.getParameterType() : null; if (parameterType != null && !parameterType.isInstance(val)) { - if (val instanceof Number && Number.class.isAssignableFrom(parameterType)) { - val = MathUtils.cast((Number) val, parameterType); + if (val instanceof Number number && Number.class.isAssignableFrom(parameterType)) { + val = MathUtils.cast(number, parameterType); } } } diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLSerializer.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLSerializer.java index d7fccd1bd3..cdc67e684e 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLSerializer.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLSerializer.java @@ -816,10 +816,10 @@ public void serializeUnion(Expression union, QueryMetadata metadata, boolean @Override public void visitConstant(Object constant) { if (useLiterals) { - if (constant instanceof Collection) { + if (constant instanceof Collection collection) { append("("); var first = true; - for (Object o : ((Collection) constant)) { + for (Object o : collection) { if (!first) { append(COMMA); } @@ -830,10 +830,10 @@ public void visitConstant(Object constant) { } else { append(configuration.asLiteral(constant)); } - } else if (constant instanceof Collection) { + } else if (constant instanceof Collection collection) { append("("); var first = true; - for (Object o : ((Collection) constant)) { + for (Object o : collection) { if (!first) { append(COMMA); } @@ -846,7 +846,7 @@ public void visitConstant(Object constant) { } append(")"); - var size = ((Collection) constant).size() - 1; + var size = collection.size() - 1; Path lastPath = constantPaths.peekLast(); for (var i = 0; i < size; i++) { constantPaths.add(lastPath); diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/types/CharacterType.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/types/CharacterType.java index 9520342060..905e31e9fb 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/types/CharacterType.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/types/CharacterType.java @@ -34,8 +34,8 @@ public CharacterType(int type) { @Override public Character getValue(Row row, int startIndex) { var val = row.get(startIndex); - if (val instanceof Character) { - return (Character) val; + if (val instanceof Character character) { + return character; } return val == null ? null : ((String) val).charAt(0); diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/types/DateType.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/types/DateType.java index 37565256ce..46280287d1 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/types/DateType.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/types/DateType.java @@ -58,12 +58,12 @@ protected LocalDate toDbValue(Date value) { @Override protected Date fromDbValue(Temporal value) { - if (value instanceof LocalDate) { - return Date.valueOf((LocalDate) value); + if (value instanceof LocalDate date) { + return Date.valueOf(date); } - if (value instanceof LocalDateTime) { - return Date.valueOf(((LocalDateTime) value).toLocalDate()); + if (value instanceof LocalDateTime time) { + return Date.valueOf(time.toLocalDate()); } // mysql // if (String.class.isAssignableFrom(value.getClass())) { diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/types/StringAsObjectType.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/types/StringAsObjectType.java index 0b84e8ed29..c874178e73 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/types/StringAsObjectType.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/types/StringAsObjectType.java @@ -38,8 +38,8 @@ public StringAsObjectType(int type) { @Override public String getValue(Row row, int startIndex) { var o = row.get(startIndex); - if (o instanceof String) { - return (String) o; + if (o instanceof String string) { + return string; // } else if (o instanceof Clob) { // Clob clob = (Clob) o; // return clob.stream(); diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java index 283abcfb51..16208d07f8 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/AbstractSQLQuery.java @@ -518,8 +518,8 @@ public QueryResults fetchResults() { } long total; if (!results.isEmpty()) { - if (lastCell instanceof Number) { - total = ((Number) lastCell).longValue(); + if (lastCell instanceof Number number) { + total = number.longValue(); } else { throw new IllegalStateException("Unsupported lastCell instance " + lastCell); } diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/ColumnMetadata.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/ColumnMetadata.java index b9b0af225f..16c0d8ace0 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/ColumnMetadata.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/ColumnMetadata.java @@ -31,8 +31,8 @@ public static ColumnMetadata getColumnMetadata(Path path) { Path parent = path.getMetadata().getParent(); if (parent instanceof EntityPath) { var columnMetadata = ((EntityPath) parent).getMetadata(path); - if (columnMetadata instanceof ColumnMetadata) { - return (ColumnMetadata) columnMetadata; + if (columnMetadata instanceof ColumnMetadata metadata) { + return metadata; } } return ColumnMetadata.named(path.getMetadata().getName()); @@ -49,8 +49,8 @@ public static String getName(Path path) { Path parent = path.getMetadata().getParent(); if (parent instanceof EntityPath) { var columnMetadata = ((EntityPath) parent).getMetadata(path); - if (columnMetadata instanceof ColumnMetadata) { - return ((ColumnMetadata) columnMetadata).getName(); + if (columnMetadata instanceof ColumnMetadata metadata) { + return metadata.getName(); } } return path.getMetadata().getName(); @@ -161,8 +161,7 @@ public ColumnMetadata withDigits(int decimalDigits) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof ColumnMetadata) { - var md = (ColumnMetadata) o; + } else if (o instanceof ColumnMetadata md) { return name.equals(md.name) && Objects.equals(jdbcType, md.jdbcType) && nullable == md.nullable diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/RelationalPathBase.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/RelationalPathBase.java index e096ca3051..f983a1339a 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/RelationalPathBase.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/RelationalPathBase.java @@ -142,8 +142,8 @@ public NumberExpression countDistinct() { */ @Override public BooleanExpression eq(T right) { - if (right instanceof RelationalPath) { - return primaryKeyOperation(Ops.EQ, primaryKey, ((RelationalPath) right).getPrimaryKey()); + if (right instanceof RelationalPath path) { + return primaryKeyOperation(Ops.EQ, primaryKey, path.getPrimaryKey()); } else { return super.eq(right); } @@ -157,8 +157,8 @@ public BooleanExpression eq(T right) { */ @Override public BooleanExpression eq(Expression right) { - if (right instanceof RelationalPath) { - return primaryKeyOperation(Ops.EQ, primaryKey, ((RelationalPath) right).getPrimaryKey()); + if (right instanceof RelationalPath path) { + return primaryKeyOperation(Ops.EQ, primaryKey, path.getPrimaryKey()); } else { return super.eq(right); } @@ -172,8 +172,8 @@ public BooleanExpression eq(Expression right) { */ @Override public BooleanExpression ne(T right) { - if (right instanceof RelationalPath) { - return primaryKeyOperation(Ops.NE, primaryKey, ((RelationalPath) right).getPrimaryKey()); + if (right instanceof RelationalPath path) { + return primaryKeyOperation(Ops.NE, primaryKey, path.getPrimaryKey()); } else { return super.ne(right); } @@ -187,8 +187,8 @@ public BooleanExpression ne(T right) { */ @Override public BooleanExpression ne(Expression right) { - if (right instanceof RelationalPath) { - return primaryKeyOperation(Ops.NE, primaryKey, ((RelationalPath) right).getPrimaryKey()); + if (right instanceof RelationalPath path) { + return primaryKeyOperation(Ops.NE, primaryKey, path.getPrimaryKey()); } else { return super.ne(right); } diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/RelationalPathExtractor.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/RelationalPathExtractor.java index efb9eacdc3..a624addc04 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/RelationalPathExtractor.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/RelationalPathExtractor.java @@ -95,8 +95,8 @@ public Set> visit(ParamExpression expr, Set> visit(Path expr, Set> known) { if (expr.getMetadata().isRoot()) { - if (expr instanceof RelationalPath) { - known = add(known, (RelationalPath) expr); + if (expr instanceof RelationalPath path) { + known = add(known, path); } } else { known = expr.getMetadata().getParent().accept(this, known); diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLListenerAdapter.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLListenerAdapter.java index 762ac694fd..2a7e443676 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLListenerAdapter.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLListenerAdapter.java @@ -35,8 +35,7 @@ class SQLListenerAdapter implements SQLDetailedListener { private final SQLDetailedListener detailedListener; SQLListenerAdapter(final SQLListener sqlListener) { - this.detailedListener = - sqlListener instanceof SQLDetailedListener ? (SQLDetailedListener) sqlListener : null; + this.detailedListener = sqlListener instanceof SQLDetailedListener sqldl ? sqldl : null; this.sqlListener = sqlListener; } diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLListeners.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLListeners.java index 40dc389869..3a40677157 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLListeners.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLListeners.java @@ -50,12 +50,12 @@ public SQLListeners() { } public void add(SQLListener listener) { - if (listener instanceof SQLListeners) { - for (SQLListener l : ((SQLListeners) listener).listeners) { + if (listener instanceof SQLListeners lListeners) { + for (SQLListener l : lListeners.listeners) { add(l); } - } else if (listener instanceof SQLDetailedListener) { - listeners.add((SQLDetailedListener) listener); + } else if (listener instanceof SQLDetailedListener detailedListener) { + listeners.add(detailedListener); } else { listeners.add(new SQLListenerAdapter(listener)); } diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLSerializer.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLSerializer.java index 033692a212..9672580677 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLSerializer.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLSerializer.java @@ -607,14 +607,12 @@ public void serializeForMergeUsing( append("\nusing "); // A hacky way to allow merging table to table directly - if (usingExpression instanceof RelationalPath) { + if (usingExpression instanceof RelationalPath path) { dmlWithSchema = true; // If table has an alias, handle both original table name and alias - if (!((RelationalPath) usingExpression) - .getTableName() - .equals(ColumnMetadata.getName((RelationalPath) usingExpression))) { + if (!path.getTableName().equals(ColumnMetadata.getName(path))) { RelationalPath originalEntity = this.entity; - this.entity = (RelationalPath) usingExpression; + this.entity = path; handle(usingExpression); append(" "); this.entity = originalEntity; @@ -936,10 +934,10 @@ public void serializeUnion(Expression union, QueryMetadata metadata, boolean @Override public void visitConstant(Object constant) { if (useLiterals) { - if (constant instanceof Collection) { + if (constant instanceof Collection collection) { append("("); var first = true; - for (Object o : ((Collection) constant)) { + for (Object o : collection) { if (!first) { append(COMMA); } @@ -950,10 +948,10 @@ public void visitConstant(Object constant) { } else { append(configuration.asLiteral(constant)); } - } else if (constant instanceof Collection) { + } else if (constant instanceof Collection collection) { append("("); var first = true; - for (Object o : ((Collection) constant)) { + for (Object o : collection) { if (!first) { append(COMMA); } @@ -966,7 +964,7 @@ public void visitConstant(Object constant) { } append(")"); - var size = ((Collection) constant).size() - 1; + var size = collection.size() - 1; Path lastPath = constantPaths.peekLast(); for (var i = 0; i < size; i++) { constantPaths.add(lastPath); @@ -1007,8 +1005,8 @@ protected void serializeConstant(int parameterIndex, String constantLabel) { @Override public Void visit(Path path, Void context) { if (dml) { - if (path.equals(entity) && path instanceof RelationalPath) { - var schemaAndTable = getSchemaAndTable((RelationalPath) path); + if (path.equals(entity) && path instanceof RelationalPath relationalPath) { + var schemaAndTable = getSchemaAndTable(relationalPath); boolean precededByDot; if (dmlWithSchema && templates.isPrintSchema()) { appendSchemaName(schemaAndTable.getSchema()); diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SchemaAndTable.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SchemaAndTable.java index 7907d5068e..b0f3a771a7 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SchemaAndTable.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SchemaAndTable.java @@ -38,8 +38,7 @@ public String getTable() { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof SchemaAndTable) { - var st = (SchemaAndTable) o; + } else if (o instanceof SchemaAndTable st) { return Objects.equals(st.schema, schema) && Objects.equals(st.table, table); } else { return false; diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/WindowFunction.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/WindowFunction.java index 91864c7843..bb9d11442d 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/WindowFunction.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/WindowFunction.java @@ -121,8 +121,7 @@ public R accept(Visitor v, C context) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof WindowFunction) { - WindowFunction so = (WindowFunction) o; + } else if (o instanceof WindowFunction so) { return so.target.equals(target) && so.partitionBy.equals(partitionBy) && so.orderBy.equals(orderBy); diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/types/StringAsObjectType.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/types/StringAsObjectType.java index a97b943a28..cb1268e928 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/types/StringAsObjectType.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/types/StringAsObjectType.java @@ -39,10 +39,9 @@ public StringAsObjectType(int type) { @Override public String getValue(ResultSet rs, int startIndex) throws SQLException { var o = rs.getObject(startIndex); - if (o instanceof String) { - return (String) o; - } else if (o instanceof Clob) { - var clob = (Clob) o; + if (o instanceof String string) { + return string; + } else if (o instanceof Clob clob) { return clob.getSubString(1, (int) clob.length()); } else if (o != null) { return o.toString(); diff --git a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/AbstractQuerydslProcessor.java b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/AbstractQuerydslProcessor.java index e03d74a4ce..c30ac82646 100644 --- a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/AbstractQuerydslProcessor.java +++ b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/AbstractQuerydslProcessor.java @@ -248,8 +248,8 @@ protected Set collectElements() { // from class annotations for (Class annotation : conf.getEntityAnnotations()) { for (Element element : getElements(annotation)) { - if (element instanceof TypeElement) { - elements.add((TypeElement) element); + if (element instanceof TypeElement typeElement) { + elements.add(typeElement); } } } @@ -402,8 +402,8 @@ private void handleEmbeddedType(Element element, Set elements) { private Set getTypeFromProperties(Set parents) { Set elements = new HashSet<>(); for (Element element : parents) { - if (element instanceof TypeElement) { - processFromProperties((TypeElement) element, elements); + if (element instanceof TypeElement typeElement) { + processFromProperties(typeElement, elements); } } @@ -470,10 +470,10 @@ private void addSupertypeFields(EntityType model, Set handled) { private void processExclusions() { for (Element element : getElements(QueryExclude.class)) { - if (element instanceof PackageElement) { - conf.addExcludedPackage(((PackageElement) element).getQualifiedName().toString()); - } else if (element instanceof TypeElement) { - conf.addExcludedClass(((TypeElement) element).getQualifiedName().toString()); + if (element instanceof PackageElement packageElement) { + conf.addExcludedPackage(packageElement.getQualifiedName().toString()); + } else if (element instanceof TypeElement typeElement) { + conf.addExcludedClass(typeElement.getQualifiedName().toString()); } else { throw new IllegalArgumentException(element.toString()); } diff --git a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/DefaultConfiguration.java b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/DefaultConfiguration.java index d1e4db7200..a8c0b56db4 100644 --- a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/DefaultConfiguration.java +++ b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/DefaultConfiguration.java @@ -222,11 +222,9 @@ public DefaultConfiguration( for (Element element : roundEnv.getElementsAnnotatedWith(Config.class)) { var querydslConfig = element.getAnnotation(Config.class); var config = SimpleSerializerConfig.getConfig(querydslConfig); - if (element instanceof PackageElement) { - var packageElement = (PackageElement) element; + if (element instanceof PackageElement packageElement) { packageToConfig.put(packageElement.getQualifiedName().toString(), config); - } else if (element instanceof TypeElement) { - var typeElement = (TypeElement) element; + } else if (element instanceof TypeElement typeElement) { typeToConfig.put(typeElement.getQualifiedName().toString(), config); } } diff --git a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/ExtendedTypeFactory.java b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/ExtendedTypeFactory.java index 5bd1e5c9ed..a7b4adc0ac 100644 --- a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/ExtendedTypeFactory.java +++ b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/ExtendedTypeFactory.java @@ -447,8 +447,8 @@ && isAssignable(typeElement.asType(), comparableType)) { } } typeElement = (TypeElement) env.getTypeUtils().asElement(type); - if (type instanceof DeclaredType) { - arguments = ((DeclaredType) type).getTypeArguments(); + if (type instanceof DeclaredType declaredType1) { + arguments = declaredType1.getTypeArguments(); } } @@ -456,8 +456,8 @@ && isAssignable(typeElement.asType(), comparableType)) { var superType = typeElement.getSuperclass(); TypeElement superTypeElement = null; - if (superType instanceof DeclaredType) { - superTypeElement = (TypeElement) ((DeclaredType) superType).asElement(); + if (superType instanceof DeclaredType declaredType1) { + superTypeElement = (TypeElement) declaredType1.asElement(); } // entity type @@ -624,8 +624,8 @@ private Set getSupertypes(TypeMirror typeMirror, boolean deep) { if (e.getKind() == ElementKind.CLASS) { if (e.getSuperclass().getKind() != TypeKind.NONE) { var supertype = normalize(e.getSuperclass()); - if (supertype instanceof DeclaredType - && ((DeclaredType) supertype).asElement().getAnnotation(QueryExclude.class) != null) { + if (supertype instanceof DeclaredType type + && type.asElement().getAnnotation(QueryExclude.class) != null) { return Collections.emptySet(); } else { Type superClass = getType(supertype, deep); diff --git a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jpa/JPAConfiguration.java b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jpa/JPAConfiguration.java index 88059338ef..6d0f98cbf5 100644 --- a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jpa/JPAConfiguration.java +++ b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/jpa/JPAConfiguration.java @@ -168,8 +168,8 @@ private TypeMirror getRealElementType(Element element) { if (mirror != null) { var typeArg = TypeUtils.getAnnotationValueAsTypeMirror(mirror, "targetEntity"); TypeMirror erasure; - if (element instanceof ExecutableElement) { - erasure = ((ExecutableElement) element).getReturnType(); + if (element instanceof ExecutableElement executableElement) { + erasure = executableElement.getReturnType(); } else { erasure = types.erasure(element.asType()); } diff --git a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/ECJEvaluatorFactory.java b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/ECJEvaluatorFactory.java index ab6fd14a5e..904ba0200c 100644 --- a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/ECJEvaluatorFactory.java +++ b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/ECJEvaluatorFactory.java @@ -309,8 +309,8 @@ public void acceptResult(CompilationResult result) { // not one of our checked exceptions boxed as unchecked; just rethrow var cause = ex.getCause(); if (cause != null) { - if (cause instanceof IOException) { - throw (IOException) cause; + if (cause instanceof IOException exception) { + throw exception; } else if (cause instanceof ClassFormatException) { throw new IOException(cause); } diff --git a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/JavaWriter.java b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/JavaWriter.java index 944b0068b8..a1fd8e57b1 100644 --- a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/JavaWriter.java +++ b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/JavaWriter.java @@ -144,12 +144,11 @@ private void annotationConstant(Object value) throws IOException { first = false; } append("}"); - } else if (value instanceof Class) { - appendType((Class) value).append(".class"); + } else if (value instanceof Class class1) { + appendType(class1).append(".class"); } else if (value instanceof Number || value instanceof Boolean) { append(value.toString()); - } else if (value instanceof Enum) { - Enum enumValue = (Enum) value; + } else if (value instanceof Enum enumValue) { if (classes.contains(enumValue.getClass().getName()) || packages.contains(enumValue.getClass().getPackage().getName())) { append(enumValue.name()); diff --git a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/LocationAndKind.java b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/LocationAndKind.java index 44e3142765..0a5ad65aa4 100644 --- a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/LocationAndKind.java +++ b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/LocationAndKind.java @@ -36,8 +36,7 @@ public LocationAndKind(Location location, Kind kind) { public boolean equals(Object obj) { if (obj == this) { return true; - } else if (obj instanceof LocationAndKind) { - var other = (LocationAndKind) obj; + } else if (obj instanceof LocationAndKind other) { return location.equals(other.location) && kind.equals(other.kind); } else { return false; diff --git a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/ScalaWriter.java b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/ScalaWriter.java index dcf7c06b03..2f6cee4ae6 100644 --- a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/ScalaWriter.java +++ b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/ScalaWriter.java @@ -168,14 +168,13 @@ private void annotationConstant(Object value) throws IOException { first = false; } append(")"); - } else if (value instanceof Class) { + } else if (value instanceof Class class1) { append("classOf["); - appendType((Class) value); + appendType(class1); append("]"); } else if (value instanceof Number || value instanceof Boolean) { append(value.toString()); - } else if (value instanceof Enum) { - Enum enumValue = (Enum) value; + } else if (value instanceof Enum enumValue) { if (classes.contains(enumValue.getClass().getName()) || packages.contains(enumValue.getClass().getPackage().getName())) { append(enumValue.name()); diff --git a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/ClassType.java b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/ClassType.java index f960a95e1a..a408aa0751 100644 --- a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/ClassType.java +++ b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/ClassType.java @@ -74,8 +74,7 @@ public Type asArrayType() { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof Type) { - var t = (Type) o; + } else if (o instanceof Type t) { return t.getFullName().equals(className) && t.getParameters().equals(parameters); } else { return false; diff --git a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/Constructor.java b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/Constructor.java index a30f086f17..aca49f4b7e 100644 --- a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/Constructor.java +++ b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/Constructor.java @@ -30,8 +30,8 @@ public Constructor(Collection params) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof Constructor) { - return ((Constructor) o).parameters.equals(parameters); + } else if (o instanceof Constructor constructor) { + return constructor.parameters.equals(parameters); } else { return false; } diff --git a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/Parameter.java b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/Parameter.java index 61bace5153..6b0426ad3d 100644 --- a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/Parameter.java +++ b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/Parameter.java @@ -33,8 +33,7 @@ public Parameter(String name, Type type) { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof Parameter) { - var t = (Parameter) o; + } else if (o instanceof Parameter t) { return type.equals(t.type) && name.equals(t.name); } else { return false; diff --git a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/SimpleType.java b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/SimpleType.java index be74b84277..cf8767bade 100644 --- a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/SimpleType.java +++ b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/SimpleType.java @@ -156,8 +156,7 @@ public Type asArrayType() { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof Type) { - var t = (Type) o; + } else if (o instanceof Type t) { return t.getFullName().equals(fullName) && t.getParameters().equals(parameters); } else { return false; diff --git a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/TypeExtends.java b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/TypeExtends.java index 18928094bf..e70d9a3d63 100644 --- a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/TypeExtends.java +++ b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/TypeExtends.java @@ -62,9 +62,8 @@ public String getVarName() { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof TypeExtends) { - return Objects.equals(((TypeExtends) o).varName, varName) - && ((TypeExtends) o).type.equals(type); + } else if (o instanceof TypeExtends extends1) { + return Objects.equals(extends1.varName, varName) && extends1.type.equals(type); } else { return false; } diff --git a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/TypeSuper.java b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/TypeSuper.java index 0890c16189..ca2728e68d 100644 --- a/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/TypeSuper.java +++ b/querydsl-tooling/querydsl-codegen-utils/src/main/java/com/querydsl/codegen/utils/model/TypeSuper.java @@ -68,9 +68,8 @@ public String getVarName() { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof TypeSuper) { - return Objects.equals(((TypeSuper) o).varName, varName) - && ((TypeSuper) o).superType.equals(superType); + } else if (o instanceof TypeSuper super1) { + return Objects.equals(super1.varName, varName) && super1.superType.equals(superType); } else { return false; } diff --git a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Delegate.java b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Delegate.java index 6b5fa15046..1d0d78d830 100644 --- a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Delegate.java +++ b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Delegate.java @@ -48,8 +48,7 @@ public Delegate( public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof Delegate) { - var m = (Delegate) o; + } else if (o instanceof Delegate m) { return m.name.equals(name) && m.parameters.equals(parameters); } else { return false; diff --git a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/GenericExporter.java b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/GenericExporter.java index 223ff9d9c5..5e7a0586ea 100644 --- a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/GenericExporter.java +++ b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/GenericExporter.java @@ -496,11 +496,11 @@ private Type getPropertyType( } if (propertyType == null) { propertyType = typeFactory.get(type, annotated, genericType); - if (propertyType instanceof EntityType + if (propertyType instanceof EntityType entityType && !allTypes.containsKey(ClassUtils.getFullName(type))) { var fullName = ClassUtils.getFullName(type); if (!allTypes.containsKey(fullName)) { - allTypes.put(fullName, (EntityType) propertyType); + allTypes.put(fullName, entityType); } } } diff --git a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/ParameterizedTypeImpl.java b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/ParameterizedTypeImpl.java index e9b1390287..e4208003cc 100644 --- a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/ParameterizedTypeImpl.java +++ b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/ParameterizedTypeImpl.java @@ -53,8 +53,7 @@ public Type getOwnerType() { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof ParameterizedTypeImpl) { - var other = (ParameterizedTypeImpl) o; + } else if (o instanceof ParameterizedTypeImpl other) { return other.rawType.equals(rawType) && Arrays.equals(other.arguments, arguments); } else { return false; diff --git a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Property.java b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Property.java index d1d3f95570..1415feee36 100644 --- a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Property.java +++ b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Property.java @@ -126,8 +126,7 @@ public int hashCode() { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof Property) { - var p = (Property) o; + } else if (o instanceof Property p) { return p.name.equals(name) && p.type.equals(type); } else { return false; diff --git a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Supertype.java b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Supertype.java index 82c744cda5..30b151d388 100644 --- a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Supertype.java +++ b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/Supertype.java @@ -59,8 +59,8 @@ public int hashCode() { public boolean equals(Object o) { if (o == this) { return true; - } else if (o instanceof Supertype) { - return ((Supertype) o).type.equals(type); + } else if (o instanceof Supertype supertype) { + return supertype.type.equals(type); } else { return false; } diff --git a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/TypeFactory.java b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/TypeFactory.java index 85c193f217..e4c7f83b4b 100644 --- a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/TypeFactory.java +++ b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/TypeFactory.java @@ -172,8 +172,7 @@ private Type create( value = createOther(cl, entity, annotationHelper, annotation, parameters); } - if (genericType instanceof TypeVariable) { - var tv = (TypeVariable) genericType; + if (genericType instanceof TypeVariable tv) { if (tv.getBounds().length == 1 && tv.getBounds()[0].equals(Object.class)) { value = new TypeSuper(tv.getName(), value); } else { @@ -248,13 +247,12 @@ private Type[] getGenericParameters( @SuppressWarnings("rawtypes") private Type getGenericParameter(Class cl, java.lang.reflect.Type genericType, int i) { java.lang.reflect.Type parameter = ReflectionUtils.getTypeParameter(genericType, i); - if (parameter instanceof TypeVariable) { - var variable = (TypeVariable) parameter; + if (parameter instanceof TypeVariable variable) { var rv = get(ReflectionUtils.getTypeParameterAsClass(genericType, i), null, parameter); return new TypeExtends(variable.getName(), rv); - } else if (parameter instanceof WildcardType - && ((WildcardType) parameter).getUpperBounds()[0].equals(Object.class) - && ((WildcardType) parameter).getLowerBounds().length == 0) { + } else if (parameter instanceof WildcardType type + && type.getUpperBounds()[0].equals(Object.class) + && type.getLowerBounds().length == 0) { return ANY; } else { var rv = get(ReflectionUtils.getTypeParameterAsClass(genericType, i), null, parameter); @@ -280,8 +278,8 @@ public void extendTypes() { var entityType = (EntityType) entry.getValue(); if (entityType.getProperties().isEmpty()) { for (Type type : cache.values()) { - if (type.getFullName().equals(entityType.getFullName()) && type instanceof EntityType) { - var base = (EntityType) type; + if (type.getFullName().equals(entityType.getFullName()) + && type instanceof EntityType base) { for (Property property : base.getProperties()) { entityType.addProperty(property); } diff --git a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/TypeResolver.java b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/TypeResolver.java index ae1c1ddd71..ee8c17eb3a 100644 --- a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/TypeResolver.java +++ b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/TypeResolver.java @@ -46,9 +46,9 @@ public static Type resolve(Type type, Type declaringType, EntityType context) { } // rewrap entity type - if (type instanceof EntityType) { + if (type instanceof EntityType entityType) { if (!unwrap(type).equals(resolved)) { - resolved = new EntityType(resolved, ((EntityType) type).getSuperTypes()); + resolved = new EntityType(resolved, entityType.getSuperTypes()); } else { // reset to original type resolved = type; @@ -116,8 +116,8 @@ private static String getVarName(Type type) { } private static Type unwrap(Type type) { - if (type instanceof EntityType) { - return ((EntityType) type).getInnerType(); + if (type instanceof EntityType entityType) { + return entityType.getInnerType(); } else { return type; } From e2bad2870b90105fb00e2df4c40994469fe713c9 Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Wed, 21 Aug 2024 16:59:32 -0300 Subject: [PATCH 3/9] Cleanup vars, switches, pattern matching and text blocks Signed-off-by: Marvin Froeder --- .../core/types/SimpleDTOProjection.java | 4 +- .../querydsl/core/types/TemplateFactory.java | 13 +-- .../querydsl/core/types/ToStringVisitor.java | 4 +- .../querydsl/core/util/CollectionUtils.java | 43 +++++----- .../java/com/querydsl/jpa/JPQLSerializer.java | 23 ++--- .../com/querydsl/jpa/JPQLSerializerTest.java | 10 ++- .../com/querydsl/r2dbc/MySQLTemplates.java | 22 ++--- .../querydsl/r2dbc/SQLServerTemplates.java | 18 ++-- .../java/com/querydsl/r2dbc/SQLTemplates.java | 85 ++++++++----------- .../querydsl/r2dbc/SQLTemplatesRegistry.java | 18 ++-- .../r2dbc/dml/AbstractR2DBCDeleteClause.java | 7 +- .../r2dbc/AbstractSQLTemplatesTest.java | 7 +- .../com/querydsl/r2dbc/JoinFlagsTest.java | 20 ++++- .../r2dbc/PostgreSQLTemplatesTest.java | 7 +- .../r2dbc/SQLServer2005TemplatesTest.java | 7 +- .../r2dbc/SQLServer2012TemplatesTest.java | 7 +- .../r2dbc/SQLServerTemplatesTest.java | 7 +- .../com/querydsl/r2dbc/UnionSubQueryTest.java | 5 +- .../com/querydsl/sql/CUBRIDTemplates.java | 16 ++-- .../java/com/querydsl/sql/DB2Templates.java | 10 +-- .../java/com/querydsl/sql/DerbyTemplates.java | 21 ++--- .../java/com/querydsl/sql/H2Templates.java | 13 ++- .../java/com/querydsl/sql/MySQLTemplates.java | 22 ++--- .../com/querydsl/sql/OracleTemplates.java | 31 +++---- .../com/querydsl/sql/SQLServerTemplates.java | 20 ++--- .../java/com/querydsl/sql/SQLTemplates.java | 85 ++++++++----------- .../com/querydsl/sql/SQLiteTemplates.java | 41 +++++---- .../com/querydsl/sql/TeradataTemplates.java | 10 +-- .../querydsl/sql/ddl/CreateTableClause.java | 2 +- .../sql/dml/AbstractSQLDeleteClause.java | 7 +- .../sql/AbstractSQLTemplatesTest.java | 7 +- .../java/com/querydsl/sql/JoinFlagsTest.java | 20 ++++- .../querydsl/sql/PostgreSQLTemplatesTest.java | 7 +- .../sql/SQLServer2005TemplatesTest.java | 7 +- .../sql/SQLServer2012TemplatesTest.java | 7 +- .../querydsl/sql/SQLServerTemplatesTest.java | 7 +- .../com/querydsl/sql/SQLiteTemplatesTest.java | 7 +- .../java/com/querydsl/sql/SelectBase.java | 18 ++-- .../com/querydsl/sql/UnionSubQueryTest.java | 5 +- .../com/querydsl/apt/ExtendedTypeFactory.java | 62 +++++--------- .../java/com/querydsl/apt/TypeExtractor.java | 17 ++-- .../codegen/DefaultEmbeddableSerializer.java | 40 +++------ .../codegen/DefaultEntitySerializer.java | 52 ++++-------- .../java/com/querydsl/codegen/EntityType.java | 2 +- .../com/querydsl/codegen/TypeResolver.java | 2 +- 45 files changed, 389 insertions(+), 456 deletions(-) diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/SimpleDTOProjection.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/SimpleDTOProjection.java index cb1e62ee61..a7c54d4981 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/SimpleDTOProjection.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/SimpleDTOProjection.java @@ -26,8 +26,8 @@ private List> generateExpressions( Field entityField = entity.getClass().getField(fieldName); if (entityField != null) { Object value = entityField.get(entity); - if (value instanceof Expression) { - expressions.add((Expression) value); + if (value instanceof Expression expression) { + expressions.add(expression); } } } catch (NoSuchFieldException | IllegalAccessException e) { diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java index 298610663c..6fbc8769d5 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java @@ -50,12 +50,13 @@ public class TemplateFactory { private static final Pattern elementPattern = Pattern.compile( - "\\{" - + "(%?%?)" - + "(\\d+)" - + "(?:([+-/*])(?:(\\d+)|'(-?\\d+(?:\\.\\d+)?)'))?" - + "([slu%]?%?)" - + "\\}"); + """ + \\{\ + (%?%?)\ + (\\d+)\ + (?:([+-/*])(?:(\\d+)|'(-?\\d+(?:\\.\\d+)?)'))?\ + ([slu%]?%?)\ + \\}"""); private final Map cache = Collections.synchronizedMap(new WeakHashMap<>()); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ToStringVisitor.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ToStringVisitor.java index 0e4713dbfe..af2ae936b5 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ToStringVisitor.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/ToStringVisitor.java @@ -51,7 +51,7 @@ public String visit(FactoryExpression e, Templates templates) { @Override public String visit(Operation o, Templates templates) { - final Template template = templates.getTemplate(o.getOperator()); + final var template = templates.getTemplate(o.getOperator()); if (template != null) { final var precedence = templates.getPrecedence(o.getOperator()); final var builder = new StringBuilder(); @@ -90,7 +90,7 @@ public String visit(Path p, Templates templates) { final Path parent = p.getMetadata().getParent(); final var elem = p.getMetadata().getElement(); if (parent != null) { - Template pattern = templates.getTemplate(p.getMetadata().getPathType()); + var pattern = templates.getTemplate(p.getMetadata().getPathType()); if (pattern != null) { final List args = Arrays.asList(parent, elem); final var builder = new StringBuilder(); diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/CollectionUtils.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/CollectionUtils.java index c02f9825df..654342fac7 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/CollectionUtils.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/util/CollectionUtils.java @@ -105,14 +105,11 @@ public static List unmodifiableList(List list) { if (isUnmodifiableType(list.getClass())) { return list; } - switch (list.size()) { - case 0: - return Collections.emptyList(); - case 1: - return Collections.singletonList(list.get(0)); - default: - return Collections.unmodifiableList(new ArrayList<>(list)); - } + return switch (list.size()) { + case 0 -> Collections.emptyList(); + case 1 -> Collections.singletonList(list.get(0)); + default -> Collections.unmodifiableList(new ArrayList<>(list)); + }; } /** @@ -127,22 +124,20 @@ public static Set unmodifiableSet(Set set) { if (isUnmodifiableType(set.getClass())) { return set; } - switch (set.size()) { - case 0: - return Collections.emptySet(); - case 1: - return Collections.singleton(set.iterator().next()); - default: - return Collections.unmodifiableSet( - (Set) - (set instanceof LinkedHashSet - ? ((LinkedHashSet) set).clone() - : set instanceof TreeSet - ? ((TreeSet) set).clone() - : set instanceof HashSet - ? ((HashSet) set).clone() - : new LinkedHashSet<>(set))); - } + return switch (set.size()) { + case 0 -> Collections.emptySet(); + case 1 -> Collections.singleton(set.iterator().next()); + default -> + Collections.unmodifiableSet( + (Set) + (set instanceof LinkedHashSet + ? ((LinkedHashSet) set).clone() + : set instanceof TreeSet + ? ((TreeSet) set).clone() + : set instanceof HashSet + ? ((HashSet) set).clone() + : new LinkedHashSet<>(set))); + }; } public static List> partition(List list, int batchSize) { diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java index b1c80c0bb8..9772964c10 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java @@ -517,17 +517,18 @@ protected void visitOperation( if (operator.getClass().getName().endsWith("SQLOps")) { throw new IllegalArgumentException( String.format( - "SQL Expressions like %s are not supported in JPQL - the query language for JPA." - + " SQLExpressions.* can only be used in JPQL queries when these functions" - + " are registered as custom function in your ORM.%n\tTo fix this issue, you" - + " have three options:%n\t1) If you do want to use advanced, dialect" - + " specific, SQL functions within JPQL, make sure to make these functions" - + " available to your ORM through custom functions and register these with" - + " your JPATemplates instance.%n\t2) Use JPASQLQuery instead. This allows" - + " you to generate a pure SQL query based on your JPA metamodel.%n\t3)" - + " Consider using the Blaze-Persistence QueryDSL integration." - + " Blaze-Persistence is an extension on top of JPA that makes various SQL" - + " specific functions like window functions available to JPQL.", + """ + SQL Expressions like %s are not supported in JPQL - the query language for JPA.\ + SQLExpressions.* can only be used in JPQL queries when these functions\ + are registered as custom function in your ORM.%n To fix this issue, you\ + have three options:%n 1) If you do want to use advanced, dialect\ + specific, SQL functions within JPQL, make sure to make these functions\ + available to your ORM through custom functions and register these with\ + your JPATemplates instance.%n 2) Use JPASQLQuery instead. This allows\ + you to generate a pure SQL query based on your JPA metamodel.%n 3)\ + Consider using the Blaze-Persistence QueryDSL integration.\ + Blaze-Persistence is an extension on top of JPA that makes various SQL\ + specific functions like window functions available to JPQL.""", operator.name()), e); } else { diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/JPQLSerializerTest.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/JPQLSerializerTest.java index 3040899b07..4a769c1a3e 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/JPQLSerializerTest.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/JPQLSerializerTest.java @@ -250,7 +250,10 @@ public void nullsFirst() { md.addOrderBy(cat.name.asc().nullsFirst()); serializer.serialize(md, false, null); assertThat(serializer.toString()) - .isEqualTo("select cat\n" + "from Cat cat\n" + "order by cat.name asc nulls first"); + .isEqualTo(""" + select cat + from Cat cat + order by cat.name asc nulls first"""); } @Test @@ -262,7 +265,10 @@ public void nullsLast() { md.addOrderBy(cat.name.asc().nullsLast()); serializer.serialize(md, false, null); assertThat(serializer.toString()) - .isEqualTo("select cat\n" + "from Cat cat\n" + "order by cat.name asc nulls last"); + .isEqualTo(""" + select cat + from Cat cat + order by cat.name asc nulls last"""); } @SuppressWarnings("unchecked") diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/MySQLTemplates.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/MySQLTemplates.java index 67b76973f8..dabffba8bd 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/MySQLTemplates.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/MySQLTemplates.java @@ -176,21 +176,11 @@ public String escapeLiteral(String str) { @Override public String getCastTypeNameForCode(int code) { - switch (code) { - case Types.TINYINT: - case Types.SMALLINT: - case Types.INTEGER: - case Types.BIGINT: - return "signed"; - case Types.FLOAT: - case Types.DOUBLE: - case Types.REAL: - case Types.DECIMAL: - return "decimal"; - case Types.VARCHAR: - return "char"; - default: - return super.getCastTypeNameForCode(code); - } + return switch (code) { + case Types.TINYINT, Types.SMALLINT, Types.INTEGER, Types.BIGINT -> "signed"; + case Types.FLOAT, Types.DOUBLE, Types.REAL, Types.DECIMAL -> "decimal"; + case Types.VARCHAR -> "char"; + default -> super.getCastTypeNameForCode(code); + }; } } diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLServerTemplates.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLServerTemplates.java index 07adae97d5..5d6a6e692f 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLServerTemplates.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLServerTemplates.java @@ -191,18 +191,12 @@ protected SQLServerTemplates(Set keywords, char escape, boolean quote) { @Override public String serialize(String literal, int jdbcType) { - switch (jdbcType) { - case Types.TIMESTAMP: - case TIMESTAMP_WITH_TIMEZONE: - return "{ts '" + literal + "'}"; - case Types.DATE: - return "{d '" + literal + "'}"; - case Types.TIME: - case TIME_WITH_TIMEZONE: - return "{t '" + literal + "'}"; - default: - return super.serialize(literal, jdbcType); - } + return switch (jdbcType) { + case Types.TIMESTAMP, TIMESTAMP_WITH_TIMEZONE -> "{ts '" + literal + "'}"; + case Types.DATE -> "{d '" + literal + "'}"; + case Types.TIME, TIME_WITH_TIMEZONE -> "{t '" + literal + "'}"; + default -> super.serialize(literal, jdbcType); + }; } @Override diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLTemplates.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLTemplates.java index 3fa2ba8004..ac995da80b 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLTemplates.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLTemplates.java @@ -450,41 +450,34 @@ protected SQLTemplates( } public String serialize(String literal, int jdbcType) { - switch (jdbcType) { - case Types.TIMESTAMP: - case TIMESTAMP_WITH_TIMEZONE: - return "(timestamp '" + literal + "')"; - case Types.DATE: - return "(date '" + literal + "')"; - case Types.TIME: - case TIME_WITH_TIMEZONE: - return "(time '" + literal + "')"; - case Types.CHAR: - case Types.CLOB: - case Types.LONGNVARCHAR: - case Types.LONGVARCHAR: - case Types.NCHAR: - case Types.NCLOB: - case Types.NVARCHAR: - case Types.VARCHAR: - return "'" + escapeLiteral(literal) + "'"; - case Types.BIGINT: - case Types.BIT: - case Types.BOOLEAN: - case Types.DECIMAL: - case Types.DOUBLE: - case Types.FLOAT: - case Types.INTEGER: - case Types.NULL: - case Types.NUMERIC: - case Types.SMALLINT: - case Types.TINYINT: - return literal; - default: - // for other JDBC types the Type instance is expected to provide - // the necessary quoting - return literal; - } + return switch (jdbcType) { + case Types.TIMESTAMP, TIMESTAMP_WITH_TIMEZONE -> "(timestamp '" + literal + "')"; + case Types.DATE -> "(date '" + literal + "')"; + case Types.TIME, TIME_WITH_TIMEZONE -> "(time '" + literal + "')"; + case Types.CHAR, + Types.CLOB, + Types.LONGNVARCHAR, + Types.LONGVARCHAR, + Types.NCHAR, + Types.NCLOB, + Types.NVARCHAR, + Types.VARCHAR -> + "'" + escapeLiteral(literal) + "'"; + case Types.BIGINT, + Types.BIT, + Types.BOOLEAN, + Types.DECIMAL, + Types.DOUBLE, + Types.FLOAT, + Types.INTEGER, + Types.NULL, + Types.NUMERIC, + Types.SMALLINT, + Types.TINYINT -> + literal; + default -> /* for other JDBC types the Type instance is expected to provide */ /* the necessary quoting */ + literal; + }; } public String escapeLiteral(String str) { @@ -593,20 +586,14 @@ public final String getJoin() { } public final String getJoinSymbol(JoinType joinType) { - switch (joinType) { - case JOIN: - return join; - case INNERJOIN: - return innerJoin; - case FULLJOIN: - return fullJoin; - case LEFTJOIN: - return leftJoin; - case RIGHTJOIN: - return rightJoin; - default: - return crossJoin; - } + return switch (joinType) { + case JOIN -> join; + case INNERJOIN -> innerJoin; + case FULLJOIN -> fullJoin; + case LEFTJOIN -> leftJoin; + case RIGHTJOIN -> rightJoin; + default -> crossJoin; + }; } public final String getKey() { diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLTemplatesRegistry.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLTemplatesRegistry.java index 434aa73d91..ae6fc90abd 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLTemplatesRegistry.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/SQLTemplatesRegistry.java @@ -48,18 +48,12 @@ public SQLTemplates.Builder getBuilder(DatabaseMetaData md) throws SQLException } else if (name.equals("postgresql")) { return PostgreSQLTemplates.builder(); } else if (name.equals("microsoft sql server")) { - switch (md.getDatabaseMajorVersion()) { - case 13: - case 12: - case 11: - return SQLServer2012Templates.builder(); - case 10: - return SQLServer2008Templates.builder(); - case 9: - return SQLServer2005Templates.builder(); - default: - return SQLServerTemplates.builder(); - } + return switch (md.getDatabaseMajorVersion()) { + case 13, 12, 11 -> SQLServer2012Templates.builder(); + case 10 -> SQLServer2008Templates.builder(); + case 9 -> SQLServer2005Templates.builder(); + default -> SQLServerTemplates.builder(); + }; } else { return new SQLTemplates.Builder() { @Override diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java index e8f14317cd..c88a2ffdc3 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java @@ -52,9 +52,10 @@ public abstract class AbstractR2DBCDeleteClause entity; diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/AbstractSQLTemplatesTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/AbstractSQLTemplatesTest.java index 0e10e7a6db..3eda879fba 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/AbstractSQLTemplatesTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/AbstractSQLTemplatesTest.java @@ -83,7 +83,12 @@ public void union() { """); } else { assertThat(union.toString()) - .isEqualTo("select 1 as col1)\n" + "union\n" + "select 2\n" + "union\n" + "select 3"); + .isEqualTo(""" + select 1 as col1) + union + select 2 + union + select 3"""); } } else { var dummyTable = templates.getDummyTable(); diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/JoinFlagsTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/JoinFlagsTest.java index 816a956c6f..4a63fef388 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/JoinFlagsTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/JoinFlagsTest.java @@ -50,7 +50,10 @@ public void joinFlags_beforeCondition() { query.addJoinFlag(" a ", JoinFlag.Position.BEFORE_CONDITION); assertThat(query.toString()) - .isEqualTo("from SURVEY s\n" + "inner join SURVEY s2 a \n" + "on s.ID = s2.ID"); + .isEqualTo(""" + from SURVEY s + inner join SURVEY s2 a\s + on s.ID = s2.ID"""); } @SuppressWarnings("unchecked") @@ -60,7 +63,10 @@ public void joinFlags_beforeTarget() { query.addJoinFlag(" b ", JoinFlag.Position.BEFORE_TARGET); assertThat(query.toString()) - .isEqualTo("from SURVEY s\n" + "inner join b SURVEY s3\n" + "on s.ID = s3.ID"); + .isEqualTo(""" + from SURVEY s + inner join b SURVEY s3 + on s.ID = s3.ID"""); } @SuppressWarnings("unchecked") @@ -70,7 +76,10 @@ public void joinFlags_end() { query.addJoinFlag(" c ", JoinFlag.Position.END); assertThat(query.toString()) - .isEqualTo("from SURVEY s\n" + "inner join SURVEY s4\n" + "on s.ID = s4.ID c"); + .isEqualTo(""" + from SURVEY s + inner join SURVEY s4 + on s.ID = s4.ID c"""); } @SuppressWarnings("unchecked") @@ -89,6 +98,9 @@ public void joinFlags_start() { query.addJoinFlag(" e ", JoinFlag.Position.START); assertThat(query.toString()) - .isEqualTo("from SURVEY s e \n" + "inner join SURVEY s6\n" + "on s.ID = s6.ID"); + .isEqualTo(""" + from SURVEY s e\s + inner join SURVEY s6 + on s.ID = s6.ID"""); } } diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/PostgreSQLTemplatesTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/PostgreSQLTemplatesTest.java index f65bd30cf7..057e1cca43 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/PostgreSQLTemplatesTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/PostgreSQLTemplatesTest.java @@ -48,7 +48,12 @@ public void union() { R2DBCExpressions.select(two), R2DBCExpressions.select(three)); assertThat(union.toString()) - .isEqualTo("(select 1 as col1)\n" + "union\n" + "(select 2)\n" + "union\n" + "(select 3)"); + .isEqualTo(""" + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2005TemplatesTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2005TemplatesTest.java index 615ef61e4b..3cf5bc6a6a 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2005TemplatesTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2005TemplatesTest.java @@ -52,7 +52,12 @@ public void union() { R2DBCExpressions.select(two), R2DBCExpressions.select(three)); assertThat(union.toString()) - .isEqualTo("(select 1 as col1)\n" + "union\n" + "(select 2)\n" + "union\n" + "(select 3)"); + .isEqualTo(""" + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2012TemplatesTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2012TemplatesTest.java index 5ed8d352c4..ba7e5c41e9 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2012TemplatesTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServer2012TemplatesTest.java @@ -53,7 +53,12 @@ public void union() { R2DBCExpressions.select(two), R2DBCExpressions.select(three)); assertThat(union.toString()) - .isEqualTo("(select 1 as col1)\n" + "union\n" + "(select 2)\n" + "union\n" + "(select 3)"); + .isEqualTo(""" + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServerTemplatesTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServerTemplatesTest.java index c3d524250c..9a672732bd 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServerTemplatesTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/SQLServerTemplatesTest.java @@ -51,7 +51,12 @@ public void union() { R2DBCExpressions.select(two), R2DBCExpressions.select(three)); assertThat(union.toString()) - .isEqualTo("(select 1 as col1)\n" + "union\n" + "(select 2)\n" + "union\n" + "(select 3)"); + .isEqualTo(""" + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/UnionSubQueryTest.java b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/UnionSubQueryTest.java index 990dcf46d7..ef9d90a86c 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/UnionSubQueryTest.java +++ b/querydsl-libraries/querydsl-r2dbc/src/test/java/com/querydsl/r2dbc/UnionSubQueryTest.java @@ -47,7 +47,10 @@ public void in_union() { serializer.handle(expr); assertThat(serializer.toString()) - .isEqualTo("intPath in ((select 1 from dual)\n" + "union\n" + "(select 2 from dual))"); + .isEqualTo(""" + intPath in ((select 1 from dual) + union + (select 2 from dual))"""); } @SuppressWarnings("unchecked") diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/CUBRIDTemplates.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/CUBRIDTemplates.java index 99aa0a157a..b7c9e51124 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/CUBRIDTemplates.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/CUBRIDTemplates.java @@ -118,16 +118,12 @@ public CUBRIDTemplates(char escape, boolean quote) { @Override public String serialize(String literal, int jdbcType) { - switch (jdbcType) { - case Types.TIMESTAMP: - return "timestamp'" + literal + "'"; - case Types.DATE: - return "date'" + literal + "'"; - case Types.TIME: - return "time'" + literal + "'"; - default: - return super.serialize(literal, jdbcType); - } + return switch (jdbcType) { + case Types.TIMESTAMP -> "timestamp'" + literal + "'"; + case Types.DATE -> "date'" + literal + "'"; + case Types.TIME -> "time'" + literal + "'"; + default -> super.serialize(literal, jdbcType); + }; } @Override diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/DB2Templates.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/DB2Templates.java index 788947cf50..445b87f6a2 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/DB2Templates.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/DB2Templates.java @@ -149,12 +149,10 @@ public DB2Templates(char escape, boolean quote) { @Override public String getCastTypeNameForCode(int code) { - switch (code) { - case Types.VARCHAR: - return "varchar(4000)"; - default: - return super.getCastTypeNameForCode(code); - } + return switch (code) { + case Types.VARCHAR -> "varchar(4000)"; + default -> super.getCastTypeNameForCode(code); + }; } @Override diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/DerbyTemplates.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/DerbyTemplates.java index 76757ea955..1f86cdaa28 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/DerbyTemplates.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/DerbyTemplates.java @@ -131,20 +131,13 @@ public DerbyTemplates(char escape, boolean quote) { @Override public String serialize(String literal, int jdbcType) { - switch (jdbcType) { - case Types.BOOLEAN: - return "1".equals(literal) ? "true" : "false"; - case Types.TIMESTAMP: - case TIMESTAMP_WITH_TIMEZONE: - return "{ts '" + literal + "'}"; - case Types.DATE: - return "{d '" + literal + "'}"; - case Types.TIME: - case TIME_WITH_TIMEZONE: - return "{t '" + literal + "'}"; - default: - return super.serialize(literal, jdbcType); - } + return switch (jdbcType) { + case Types.BOOLEAN -> "1".equals(literal) ? "true" : "false"; + case Types.TIMESTAMP, TIMESTAMP_WITH_TIMEZONE -> "{ts '" + literal + "'}"; + case Types.DATE -> "{d '" + literal + "'}"; + case Types.TIME, TIME_WITH_TIMEZONE -> "{t '" + literal + "'}"; + default -> super.serialize(literal, jdbcType); + }; } @Override diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/H2Templates.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/H2Templates.java index 0b22fcb152..117aaa2f0d 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/H2Templates.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/H2Templates.java @@ -89,13 +89,10 @@ public H2Templates(char escape, boolean quote) { @Override public String serialize(String literal, int jdbcType) { - switch (jdbcType) { - case TIMESTAMP_WITH_TIMEZONE: - return "(timestamp with time zone '" + literal + "')"; - case TIME_WITH_TIMEZONE: - return "(time with time zone '" + literal + "')"; - default: - return super.serialize(literal, jdbcType); - } + return switch (jdbcType) { + case TIMESTAMP_WITH_TIMEZONE -> "(timestamp with time zone '" + literal + "')"; + case TIME_WITH_TIMEZONE -> "(time with time zone '" + literal + "')"; + default -> super.serialize(literal, jdbcType); + }; } } diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/MySQLTemplates.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/MySQLTemplates.java index 8144d0bb19..9cd368ccb8 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/MySQLTemplates.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/MySQLTemplates.java @@ -174,21 +174,11 @@ public String escapeLiteral(String str) { @Override public String getCastTypeNameForCode(int code) { - switch (code) { - case Types.TINYINT: - case Types.SMALLINT: - case Types.INTEGER: - case Types.BIGINT: - return "signed"; - case Types.FLOAT: - case Types.DOUBLE: - case Types.REAL: - case Types.DECIMAL: - return "decimal"; - case Types.VARCHAR: - return "char"; - default: - return super.getCastTypeNameForCode(code); - } + return switch (code) { + case Types.TINYINT, Types.SMALLINT, Types.INTEGER, Types.BIGINT -> "signed"; + case Types.FLOAT, Types.DOUBLE, Types.REAL, Types.DECIMAL -> "decimal"; + case Types.VARCHAR -> "char"; + default -> super.getCastTypeNameForCode(code); + }; } } diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/OracleTemplates.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/OracleTemplates.java index 2c73604459..d5bb5357a1 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/OracleTemplates.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/OracleTemplates.java @@ -167,30 +167,21 @@ public OracleTemplates(char escape, boolean quote) { @Override public String getCastTypeNameForCode(int code) { - switch (code) { - case Types.DOUBLE: - return "double precision"; - case Types.VARCHAR: - return "varchar(4000 char)"; - default: - return super.getCastTypeNameForCode(code); - } + return switch (code) { + case Types.DOUBLE -> "double precision"; + case Types.VARCHAR -> "varchar(4000 char)"; + default -> super.getCastTypeNameForCode(code); + }; } @Override public String serialize(String literal, int jdbcType) { - switch (jdbcType) { - case Types.TIMESTAMP: - case TIMESTAMP_WITH_TIMEZONE: - return "timestamp '" + literal + "'"; - case Types.DATE: - return "date '" + literal + "'"; - case Types.TIME: - case TIME_WITH_TIMEZONE: - return "timestamp '1970-01-01 " + literal + "'"; - default: - return super.serialize(literal, jdbcType); - } + return switch (jdbcType) { + case Types.TIMESTAMP, TIMESTAMP_WITH_TIMEZONE -> "timestamp '" + literal + "'"; + case Types.DATE -> "date '" + literal + "'"; + case Types.TIME, TIME_WITH_TIMEZONE -> "timestamp '1970-01-01 " + literal + "'"; + default -> super.serialize(literal, jdbcType); + }; } @Override diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLServerTemplates.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLServerTemplates.java index a90aef7cce..3dde8ac213 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLServerTemplates.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLServerTemplates.java @@ -189,19 +189,13 @@ protected SQLServerTemplates(Set keywords, char escape, boolean quote) { @Override public String serialize(String literal, int jdbcType) { - switch (jdbcType) { - case Types.TIMESTAMP: - return "CAST('" + literal + "' AS DATETIME2)"; - case TIMESTAMP_WITH_TIMEZONE: - return "CAST('" + literal + "' AS DATETIMEOFFSET)"; - case Types.DATE: - return "CAST('" + literal + "' AS DATE)"; - case Types.TIME: - case TIME_WITH_TIMEZONE: - return "CAST('" + literal + "' AS TIME)"; - default: - return super.serialize(literal, jdbcType); - } + return switch (jdbcType) { + case Types.TIMESTAMP -> "CAST('" + literal + "' AS DATETIME2)"; + case TIMESTAMP_WITH_TIMEZONE -> "CAST('" + literal + "' AS DATETIMEOFFSET)"; + case Types.DATE -> "CAST('" + literal + "' AS DATE)"; + case Types.TIME, TIME_WITH_TIMEZONE -> "CAST('" + literal + "' AS TIME)"; + default -> super.serialize(literal, jdbcType); + }; } @Override diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLTemplates.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLTemplates.java index 09e13a82e3..6be096975f 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLTemplates.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLTemplates.java @@ -467,41 +467,34 @@ protected SQLTemplates( } public String serialize(String literal, int jdbcType) { - switch (jdbcType) { - case Types.TIMESTAMP: - case TIMESTAMP_WITH_TIMEZONE: - return "(timestamp '" + literal + "')"; - case Types.DATE: - return "(date '" + literal + "')"; - case Types.TIME: - case TIME_WITH_TIMEZONE: - return "(time '" + literal + "')"; - case Types.CHAR: - case Types.CLOB: - case Types.LONGNVARCHAR: - case Types.LONGVARCHAR: - case Types.NCHAR: - case Types.NCLOB: - case Types.NVARCHAR: - case Types.VARCHAR: - return "'" + escapeLiteral(literal) + "'"; - case Types.BIGINT: - case Types.BIT: - case Types.BOOLEAN: - case Types.DECIMAL: - case Types.DOUBLE: - case Types.FLOAT: - case Types.INTEGER: - case Types.NULL: - case Types.NUMERIC: - case Types.SMALLINT: - case Types.TINYINT: - return literal; - default: - // for other JDBC types the Type instance is expected to provide - // the necessary quoting - return literal; - } + return switch (jdbcType) { + case Types.TIMESTAMP, TIMESTAMP_WITH_TIMEZONE -> "(timestamp '" + literal + "')"; + case Types.DATE -> "(date '" + literal + "')"; + case Types.TIME, TIME_WITH_TIMEZONE -> "(time '" + literal + "')"; + case Types.CHAR, + Types.CLOB, + Types.LONGNVARCHAR, + Types.LONGVARCHAR, + Types.NCHAR, + Types.NCLOB, + Types.NVARCHAR, + Types.VARCHAR -> + "'" + escapeLiteral(literal) + "'"; + case Types.BIGINT, + Types.BIT, + Types.BOOLEAN, + Types.DECIMAL, + Types.DOUBLE, + Types.FLOAT, + Types.INTEGER, + Types.NULL, + Types.NUMERIC, + Types.SMALLINT, + Types.TINYINT -> + literal; + default -> /* for other JDBC types the Type instance is expected to provide */ /* the necessary quoting */ + literal; + }; } public String escapeLiteral(String str) { @@ -610,20 +603,14 @@ public final String getJoin() { } public final String getJoinSymbol(JoinType joinType) { - switch (joinType) { - case JOIN: - return join; - case INNERJOIN: - return innerJoin; - case FULLJOIN: - return fullJoin; - case LEFTJOIN: - return leftJoin; - case RIGHTJOIN: - return rightJoin; - default: - return crossJoin; - } + return switch (joinType) { + case JOIN -> join; + case INNERJOIN -> innerJoin; + case FULLJOIN -> fullJoin; + case LEFTJOIN -> leftJoin; + case RIGHTJOIN -> rightJoin; + default -> crossJoin; + }; } public final String getKey() { diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLiteTemplates.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLiteTemplates.java index db20254ebf..8fc80247d6 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLiteTemplates.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLiteTemplates.java @@ -140,27 +140,24 @@ public SQLiteTemplates(char escape, boolean quote) { @Override public String serialize(String literal, int jdbcType) { // XXX doesn't work with LocalDate, LocalDateTime and LocalTime - switch (jdbcType) { - case Types.TIMESTAMP: - case TIMESTAMP_WITH_TIMEZONE: - return String.valueOf( - dateTimeFormatter - .parse(literal, LocalDateTime::from) - .toInstant(ZoneOffset.UTC) - .toEpochMilli()); - case Types.DATE: - return String.valueOf( - dateFormatter - .parse(literal, LocalDate::from) - .atStartOfDay(ZoneOffset.UTC) - .toInstant() - .toEpochMilli()); - case Types.TIME: - case TIME_WITH_TIMEZONE: - return String.valueOf( - timeFormatter.parse(literal, LocalTime::from).get(ChronoField.MILLI_OF_DAY)); - default: - return super.serialize(literal, jdbcType); - } + return switch (jdbcType) { + case Types.TIMESTAMP, TIMESTAMP_WITH_TIMEZONE -> + String.valueOf( + dateTimeFormatter + .parse(literal, LocalDateTime::from) + .toInstant(ZoneOffset.UTC) + .toEpochMilli()); + case Types.DATE -> + String.valueOf( + dateFormatter + .parse(literal, LocalDate::from) + .atStartOfDay(ZoneOffset.UTC) + .toInstant() + .toEpochMilli()); + case Types.TIME, TIME_WITH_TIMEZONE -> + String.valueOf( + timeFormatter.parse(literal, LocalTime::from).get(ChronoField.MILLI_OF_DAY)); + default -> super.serialize(literal, jdbcType); + }; } } diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/TeradataTemplates.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/TeradataTemplates.java index 20fed92668..024fe0a2f0 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/TeradataTemplates.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/TeradataTemplates.java @@ -118,12 +118,10 @@ public TeradataTemplates(char escape, boolean quote) { @Override public String getCastTypeNameForCode(int code) { - switch (code) { - case Types.VARCHAR: - return "varchar(4000)"; - default: - return super.getCastTypeNameForCode(code); - } + return switch (code) { + case Types.VARCHAR -> "varchar(4000)"; + default -> super.getCastTypeNameForCode(code); + }; } @Override diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/ddl/CreateTableClause.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/ddl/CreateTableClause.java index 32c2f3e7c3..a138a2363f 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/ddl/CreateTableClause.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/ddl/CreateTableClause.java @@ -103,7 +103,7 @@ public CreateTableClause autoIncrement() { * @return */ public CreateTableClause primaryKey(String name, String... columns) { - for (int i = 0; i < columns.length; i++) { + for (var i = 0; i < columns.length; i++) { columns[i] = templates.quoteIdentifier(columns[i]); } primaryKey = new PrimaryKeyData(templates.quoteIdentifier(name), columns); diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/dml/AbstractSQLDeleteClause.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/dml/AbstractSQLDeleteClause.java index e6f3e3673e..d11cedbc87 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/dml/AbstractSQLDeleteClause.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/dml/AbstractSQLDeleteClause.java @@ -52,9 +52,10 @@ public abstract class AbstractSQLDeleteClause entity; diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/AbstractSQLTemplatesTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/AbstractSQLTemplatesTest.java index 998e98e25e..8b93fc18b1 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/AbstractSQLTemplatesTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/AbstractSQLTemplatesTest.java @@ -80,7 +80,12 @@ public void union() { """); } else { assertThat(union.toString()) - .isEqualTo("select 1 as col1)\n" + "union\n" + "select 2\n" + "union\n" + "select 3"); + .isEqualTo(""" + select 1 as col1) + union + select 2 + union + select 3"""); } } else { var dummyTable = templates.getDummyTable(); diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/JoinFlagsTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/JoinFlagsTest.java index 692a222194..23e0d2c332 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/JoinFlagsTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/JoinFlagsTest.java @@ -50,7 +50,10 @@ public void joinFlags_beforeCondition() { query.addJoinFlag(" a ", JoinFlag.Position.BEFORE_CONDITION); assertThat(query.toString()) - .isEqualTo("from SURVEY s\n" + "inner join SURVEY s2 a \n" + "on s.ID = s2.ID"); + .isEqualTo(""" + from SURVEY s + inner join SURVEY s2 a\s + on s.ID = s2.ID"""); } @SuppressWarnings("unchecked") @@ -60,7 +63,10 @@ public void joinFlags_beforeTarget() { query.addJoinFlag(" b ", JoinFlag.Position.BEFORE_TARGET); assertThat(query.toString()) - .isEqualTo("from SURVEY s\n" + "inner join b SURVEY s3\n" + "on s.ID = s3.ID"); + .isEqualTo(""" + from SURVEY s + inner join b SURVEY s3 + on s.ID = s3.ID"""); } @SuppressWarnings("unchecked") @@ -70,7 +76,10 @@ public void joinFlags_end() { query.addJoinFlag(" c ", JoinFlag.Position.END); assertThat(query.toString()) - .isEqualTo("from SURVEY s\n" + "inner join SURVEY s4\n" + "on s.ID = s4.ID c"); + .isEqualTo(""" + from SURVEY s + inner join SURVEY s4 + on s.ID = s4.ID c"""); } @SuppressWarnings("unchecked") @@ -89,6 +98,9 @@ public void joinFlags_start() { query.addJoinFlag(" e ", JoinFlag.Position.START); assertThat(query.toString()) - .isEqualTo("from SURVEY s e \n" + "inner join SURVEY s6\n" + "on s.ID = s6.ID"); + .isEqualTo(""" + from SURVEY s e\s + inner join SURVEY s6 + on s.ID = s6.ID"""); } } diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/PostgreSQLTemplatesTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/PostgreSQLTemplatesTest.java index f8d4107cc3..53ff4038e8 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/PostgreSQLTemplatesTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/PostgreSQLTemplatesTest.java @@ -45,7 +45,12 @@ public void union() { Path col1 = Expressions.path(Integer.class, "col1"); Union union = query.union(select(one.as(col1)), select(two), select(three)); assertThat(union.toString()) - .isEqualTo("(select 1 as col1)\n" + "union\n" + "(select 2)\n" + "union\n" + "(select 3)"); + .isEqualTo(""" + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2005TemplatesTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2005TemplatesTest.java index 27d06f41e7..6b7b5c6244 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2005TemplatesTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2005TemplatesTest.java @@ -48,7 +48,12 @@ public void union() { Path col1 = Expressions.path(Integer.class, "col1"); Union union = query.union(select(one.as(col1)), select(two), select(three)); assertThat(union.toString()) - .isEqualTo("(select 1 as col1)\n" + "union\n" + "(select 2)\n" + "union\n" + "(select 3)"); + .isEqualTo(""" + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2012TemplatesTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2012TemplatesTest.java index ec43169438..2b88ac50dd 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2012TemplatesTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServer2012TemplatesTest.java @@ -49,7 +49,12 @@ public void union() { Path col1 = Expressions.path(Integer.class, "col1"); Union union = query.union(select(one.as(col1)), select(two), select(three)); assertThat(union.toString()) - .isEqualTo("(select 1 as col1)\n" + "union\n" + "(select 2)\n" + "union\n" + "(select 3)"); + .isEqualTo(""" + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServerTemplatesTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServerTemplatesTest.java index 2346d981bd..d0a3be9d6d 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServerTemplatesTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLServerTemplatesTest.java @@ -47,7 +47,12 @@ public void union() { Path col1 = Expressions.path(Integer.class, "col1"); Union union = query.union(select(one.as(col1)), select(two), select(three)); assertThat(union.toString()) - .isEqualTo("(select 1 as col1)\n" + "union\n" + "(select 2)\n" + "union\n" + "(select 3)"); + .isEqualTo(""" + (select 1 as col1) + union + (select 2) + union + (select 3)"""); } @Test diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLiteTemplatesTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLiteTemplatesTest.java index 12a135774d..9baa1a0059 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLiteTemplatesTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SQLiteTemplatesTest.java @@ -38,7 +38,12 @@ public void union() { Union union = query.union(select(one.as(col1)), select(two), select(three)); assertThat(union.toString()) - .isEqualTo("select 1 as col1\n" + "union\n" + "select 2\n" + "union\n" + "select 3"); + .isEqualTo(""" + select 1 as col1 + union + select 2 + union + select 3"""); } @Test diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SelectBase.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SelectBase.java index 07f62de23e..8a115b2261 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SelectBase.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/SelectBase.java @@ -579,19 +579,11 @@ private void dates(boolean literals) throws SQLException { // have to explicitly list these // connection.getMetaData().getTypeInfo() is not helpful in this case for most drivers - boolean supportsTimeZones; - switch (target) { - case FIREBIRD: - case H2: - case HSQLDB: - case ORACLE: - case SQLSERVER: - supportsTimeZones = true; - break; - default: - supportsTimeZones = false; - break; - } + boolean supportsTimeZones = + switch (target) { + case FIREBIRD, H2, HSQLDB, ORACLE, SQLSERVER -> true; + default -> false; + }; if (supportsTimeZones) { // java.time.OffsetTime // SQL Server does not support TIME WITH TIME ZONE diff --git a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/UnionSubQueryTest.java b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/UnionSubQueryTest.java index 13669b373b..f4be522292 100644 --- a/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/UnionSubQueryTest.java +++ b/querydsl-libraries/querydsl-sql/src/test/java/com/querydsl/sql/UnionSubQueryTest.java @@ -48,7 +48,10 @@ public void in_union() { serializer.handle(expr); assertThat(serializer.toString()) - .isEqualTo("intPath in ((select 1 from dual)\n" + "union\n" + "(select 2 from dual))"); + .isEqualTo(""" + intPath in ((select 1 from dual) + union + (select 2 from dual))"""); } @SuppressWarnings("unchecked") diff --git a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/ExtendedTypeFactory.java b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/ExtendedTypeFactory.java index a7b4adc0ac..a95567f1c6 100644 --- a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/ExtendedTypeFactory.java +++ b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/ExtendedTypeFactory.java @@ -92,49 +92,31 @@ public class ExtendedTypeFactory { @Override public Type visitPrimitive(PrimitiveType primitiveType, Boolean p) { - switch (primitiveType.getKind()) { - case BOOLEAN: - return Types.BOOLEAN; - case BYTE: - return Types.BYTE; - case SHORT: - return Types.SHORT; - case INT: - return Types.INTEGER; - case LONG: - return Types.LONG; - case CHAR: - return Types.CHARACTER; - case FLOAT: - return Types.FLOAT; - case DOUBLE: - return Types.DOUBLE; - default: - return null; - } + return switch (primitiveType.getKind()) { + case BOOLEAN -> Types.BOOLEAN; + case BYTE -> Types.BYTE; + case SHORT -> Types.SHORT; + case INT -> Types.INTEGER; + case LONG -> Types.LONG; + case CHAR -> Types.CHARACTER; + case FLOAT -> Types.FLOAT; + case DOUBLE -> Types.DOUBLE; + default -> null; + }; } private Type getPrimitive(PrimitiveType primitiveType) { - switch (primitiveType.getKind()) { - case BOOLEAN: - return Types.BOOLEAN_P; - case BYTE: - return Types.BYTE_P; - case SHORT: - return Types.SHORT_P; - case INT: - return Types.INT; - case LONG: - return Types.LONG_P; - case CHAR: - return Types.CHAR; - case FLOAT: - return Types.FLOAT_P; - case DOUBLE: - return Types.DOUBLE_P; - default: - return null; - } + return switch (primitiveType.getKind()) { + case BOOLEAN -> Types.BOOLEAN_P; + case BYTE -> Types.BYTE_P; + case SHORT -> Types.SHORT_P; + case INT -> Types.INT; + case LONG -> Types.LONG_P; + case CHAR -> Types.CHAR; + case FLOAT -> Types.FLOAT_P; + case DOUBLE -> Types.DOUBLE_P; + default -> null; + }; } @Override diff --git a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/TypeExtractor.java b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/TypeExtractor.java index e8ee1db10a..6b7b11b2dd 100644 --- a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/TypeExtractor.java +++ b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/TypeExtractor.java @@ -57,17 +57,12 @@ public TypeElement visitArray(ArrayType t, Void p) { public TypeElement visitDeclared(DeclaredType t, Void p) { if (t.asElement() instanceof TypeElement) { var typeElement = (TypeElement) t.asElement(); - switch (typeElement.getKind().name()) { - case "ENUM": - return skipEnum ? null : typeElement; - case "RECORD": - case "CLASS": - return typeElement; - case "INTERFACE": - return visitInterface(t); - default: - throw new IllegalArgumentException("Illegal type: " + typeElement); - } + return switch (typeElement.getKind().name()) { + case "ENUM" -> skipEnum ? null : typeElement; + case "RECORD", "CLASS" -> typeElement; + case "INTERFACE" -> visitInterface(t); + default -> throw new IllegalArgumentException("Illegal type: " + typeElement); + }; } else { return null; } diff --git a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/DefaultEmbeddableSerializer.java b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/DefaultEmbeddableSerializer.java index f087932d28..cf9f3be3d3 100644 --- a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/DefaultEmbeddableSerializer.java +++ b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/DefaultEmbeddableSerializer.java @@ -82,34 +82,18 @@ protected void introClassHeader(CodeWriter writer, EntityType model) throws IOEx var category = model.getOriginalCategory(); Class pathType; if (model.getProperties().isEmpty()) { - switch (category) { - case COMPARABLE: - pathType = ComparablePath.class; - break; - case ENUM: - pathType = EnumPath.class; - break; - case DATE: - pathType = DatePath.class; - break; - case DATETIME: - pathType = DateTimePath.class; - break; - case TIME: - pathType = TimePath.class; - break; - case NUMERIC: - pathType = NumberPath.class; - break; - case STRING: - pathType = StringPath.class; - break; - case BOOLEAN: - pathType = BooleanPath.class; - break; - default: - pathType = BeanPath.class; - } + pathType = + switch (category) { + case COMPARABLE -> ComparablePath.class; + case ENUM -> EnumPath.class; + case DATE -> DatePath.class; + case DATETIME -> DateTimePath.class; + case TIME -> TimePath.class; + case NUMERIC -> NumberPath.class; + case STRING -> StringPath.class; + case BOOLEAN -> BooleanPath.class; + default -> BeanPath.class; + }; } else { pathType = BeanPath.class; } diff --git a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/DefaultEntitySerializer.java b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/DefaultEntitySerializer.java index 2de0a4e9b2..7affef987f 100644 --- a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/DefaultEntitySerializer.java +++ b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/DefaultEntitySerializer.java @@ -125,7 +125,7 @@ public DefaultEntitySerializer(TypeMappings mappings, Collection keyword } private boolean superTypeHasEntityFields(EntityType model) { - Supertype superType = model.getSuperType(); + var superType = model.getSuperType(); return null != superType && null != superType.getEntityType() && superType.getEntityType().hasEntityFields(); @@ -313,9 +313,9 @@ protected boolean hasOwnEntityProperties(EntityType model) { protected void initEntityFields(CodeWriter writer, SerializerConfig config, EntityType model) throws IOException { - Supertype superType = model.getSuperType(); + var superType = model.getSuperType(); if (superType != null) { - EntityType entityType = superType.getEntityType(); + var entityType = superType.getEntityType(); if (entityType != null && entityType.hasEntityFields()) { var superQueryType = typeMappings.getPathType(entityType, model, false); writer.line( @@ -383,34 +383,18 @@ protected void introClassHeader(CodeWriter writer, EntityType model) throws IOEx Class pathType; if (model.getProperties().isEmpty()) { - switch (category) { - case COMPARABLE: - pathType = ComparablePath.class; - break; - case ENUM: - pathType = EnumPath.class; - break; - case DATE: - pathType = DatePath.class; - break; - case DATETIME: - pathType = DateTimePath.class; - break; - case TIME: - pathType = TimePath.class; - break; - case NUMERIC: - pathType = NumberPath.class; - break; - case STRING: - pathType = StringPath.class; - break; - case BOOLEAN: - pathType = BooleanPath.class; - break; - default: - pathType = EntityPathBase.class; - } + pathType = + switch (category) { + case COMPARABLE -> ComparablePath.class; + case ENUM -> EnumPath.class; + case DATE -> DatePath.class; + case DATETIME -> DateTimePath.class; + case TIME -> TimePath.class; + case NUMERIC -> NumberPath.class; + case STRING -> StringPath.class; + case BOOLEAN -> BooleanPath.class; + default -> EntityPathBase.class; + }; } else { pathType = EntityPathBase.class; } @@ -647,7 +631,7 @@ protected void introPackage(CodeWriter writer, EntityType model) throws IOExcept } protected void introSuper(CodeWriter writer, EntityType model) throws IOException { - EntityType superType = model.getSuperType().getEntityType(); + var superType = model.getSuperType().getEntityType(); var superQueryType = typeMappings.getPathType(superType, model, false); if (!superType.hasEntityFields()) { writer.publicFinal( @@ -759,7 +743,7 @@ protected void serialize( String factoryMethod, String... args) throws IOException { - Supertype superType = model.getSuperType(); + var superType = model.getSuperType(); // construct value var value = new StringBuilder(); if (field.isInherited() && superType != null) { @@ -792,7 +776,7 @@ protected void customField( writer.line("// custom"); if (field.isInherited()) { writer.line("// inherited"); - Supertype superType = model.getSuperType(); + var superType = model.getSuperType(); if (!superType.getEntityType().hasEntityFields()) { var value = NEW + writer.getRawName(queryType) + "(_super." + field.getEscapedName() + ")"; writer.publicFinal(queryType, field.getEscapedName(), value); diff --git a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/EntityType.java b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/EntityType.java index cd9a7d8dc6..8db2939a18 100644 --- a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/EntityType.java +++ b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/EntityType.java @@ -253,7 +253,7 @@ private boolean hasPropertyWithType(TypeCategory category) { } public void include(Supertype supertype) { - EntityType entityType = supertype.getEntityType(); + var entityType = supertype.getEntityType(); for (Delegate delegate : entityType.getDelegates()) { addDelegate(delegate); } diff --git a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/TypeResolver.java b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/TypeResolver.java index ee8c17eb3a..d225bd30b4 100644 --- a/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/TypeResolver.java +++ b/querydsl-tooling/querydsl-codegen/src/main/java/com/querydsl/codegen/TypeResolver.java @@ -74,7 +74,7 @@ private static Type resolveVar( "Did not find type " + varName + " in " + declaringType + " for " + context); } - Supertype type = context.getSuperType(); + var type = context.getSuperType(); while (!type.getEntityType().equals(declaringType)) { type = type.getEntityType().getSuperType(); } From b0975528677c9589411c087c29123d16dadd11b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 31 May 2024 11:52:07 +0000 Subject: [PATCH 4/9] --- updated-dependencies: - dependency-name: jakarta.persistence:jakarta.persistence-api dependency-type: direct:development 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 787c26b9db..b54fa22758 100644 --- a/pom.xml +++ b/pom.xml @@ -128,7 +128,7 @@ 6.6.0.Final 8.0.1.Final 4.0.4 - 3.1.0 + 3.2.0 3.0.0 3.9.9 From 4c2dcefc7fc120c9de5cda44bab4ecd5ef9b4463 Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Fri, 31 May 2024 10:26:30 -0300 Subject: [PATCH 5/9] Bump hibernate version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b54fa22758..f3d19a7fa6 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ 1.0.0.RELEASE - 6.6.0.Final + 7.0.0.Alpha2 8.0.1.Final 4.0.4 3.2.0 From a9be4b6df49c428d3505d2793d05cad025ca2cb6 Mon Sep 17 00:00:00 2001 From: Marvin Date: Mon, 1 Jul 2024 23:20:45 -0300 Subject: [PATCH 6/9] bump eclipselink version to 5.0.0-B02 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f3d19a7fa6..2c182f43fd 100644 --- a/pom.xml +++ b/pom.xml @@ -127,7 +127,7 @@ 7.0.0.Alpha2 8.0.1.Final - 4.0.4 + 5.0.0-B02 3.2.0 3.0.0 From 7516c61e9790ac8bf1c29e887381489d69c857ea Mon Sep 17 00:00:00 2001 From: Marvin Date: Fri, 2 Aug 2024 12:49:44 -0300 Subject: [PATCH 7/9] Bump hibernate version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2c182f43fd..963cc8f031 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ 1.0.0.RELEASE - 7.0.0.Alpha2 + 7.0.0.Beta1 8.0.1.Final 5.0.0-B02 3.2.0 From d76f3774a813ed8cae1cb28b5587f9f9f5251b4e Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Fri, 2 Aug 2024 16:13:03 -0300 Subject: [PATCH 8/9] Fix code to work with hibernate 7 and eclipselink 5 --- .../querydsl/core/types/TemplateFactory.java | 13 +++++----- querydsl-libraries/querydsl-jpa/pom.xml | 7 ++++++ .../java/com/querydsl/jpa/JPQLSerializer.java | 23 +++++++++--------- .../querydsl/jpa/impl/AbstractJPAQuery.java | 12 ++++++---- .../querydsl/jpa/support/QDerbyDialect.java | 2 +- .../com/querydsl/jpa/AbstractJPATest.java | 1 + .../java/com/querydsl/jpa/HibernateBase.java | 2 +- .../com/querydsl/jpa/HibernateSQLBase.java | 12 +++++----- .../com/querydsl/jpa/IntegrationBase.java | 24 +++++++++---------- .../r2dbc/dml/AbstractR2DBCDeleteClause.java | 7 +++--- .../com/querydsl/sql/SQLiteTemplates.java | 6 +++-- .../sql/dml/AbstractSQLDeleteClause.java | 7 +++--- .../apt/hibernate/HibernateConfiguration.java | 2 +- .../apt/domain/InterfaceType2Test.java | 4 ---- 14 files changed, 68 insertions(+), 54 deletions(-) diff --git a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java index 6fbc8769d5..787cdb9dbd 100644 --- a/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java +++ b/querydsl-libraries/querydsl-core/src/main/java/com/querydsl/core/types/TemplateFactory.java @@ -51,12 +51,13 @@ public class TemplateFactory { private static final Pattern elementPattern = Pattern.compile( """ - \\{\ - (%?%?)\ - (\\d+)\ - (?:([+-/*])(?:(\\d+)|'(-?\\d+(?:\\.\\d+)?)'))?\ - ([slu%]?%?)\ - \\}"""); + \\{\ + (%?%?)\ + (\\d+)\ + (?:([+-/*])(?:(\\d+)|'(-?\\d+(?:\\.\\d+)?)'))?\ + ([slu%]?%?)\ + \\}\ + """); private final Map cache = Collections.synchronizedMap(new WeakHashMap<>()); diff --git a/querydsl-libraries/querydsl-jpa/pom.xml b/querydsl-libraries/querydsl-jpa/pom.xml index 84aeb1f222..9d5a93ca28 100644 --- a/querydsl-libraries/querydsl-jpa/pom.xml +++ b/querydsl-libraries/querydsl-jpa/pom.xml @@ -35,6 +35,13 @@ + + org.hibernate.orm + hibernate-community-dialects + ${hibernate.version} + provided + true + jakarta.persistence diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java index 9772964c10..f4971930e3 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/JPQLSerializer.java @@ -518,17 +518,18 @@ protected void visitOperation( throw new IllegalArgumentException( String.format( """ - SQL Expressions like %s are not supported in JPQL - the query language for JPA.\ - SQLExpressions.* can only be used in JPQL queries when these functions\ - are registered as custom function in your ORM.%n To fix this issue, you\ - have three options:%n 1) If you do want to use advanced, dialect\ - specific, SQL functions within JPQL, make sure to make these functions\ - available to your ORM through custom functions and register these with\ - your JPATemplates instance.%n 2) Use JPASQLQuery instead. This allows\ - you to generate a pure SQL query based on your JPA metamodel.%n 3)\ - Consider using the Blaze-Persistence QueryDSL integration.\ - Blaze-Persistence is an extension on top of JPA that makes various SQL\ - specific functions like window functions available to JPQL.""", + SQL Expressions like %s are not supported in JPQL - the query language for JPA.\ + SQLExpressions.* can only be used in JPQL queries when these functions\ + are registered as custom function in your ORM.%n To fix this issue, you\ + have three options:%n 1) If you do want to use advanced, dialect\ + specific, SQL functions within JPQL, make sure to make these functions\ + available to your ORM through custom functions and register these with\ + your JPATemplates instance.%n 2) Use JPASQLQuery instead. This allows\ + you to generate a pure SQL query based on your JPA metamodel.%n 3)\ + Consider using the Blaze-Persistence QueryDSL integration.\ + Blaze-Persistence is an extension on top of JPA that makes various SQL\ + specific functions like window functions available to JPQL.\ + """, operator.name()), e); } else { diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java index e7fa43851a..e491c8ce41 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/impl/AbstractJPAQuery.java @@ -107,8 +107,10 @@ public long fetchCount() { try { if (getMetadata().getGroupBy().size() > 1 || getMetadata().getHaving() != null) { logger.warning( - "Fetchable#fetchCount() was computed in memory! See the Javadoc for" - + " AbstractJPAQuery#fetchCount for more details."); + """ + Fetchable#fetchCount() was computed in memory! See the Javadoc for\ + AbstractJPAQuery#fetchCount for more details.\ + """); var query = createQuery(null, false); return query.getResultList().size(); } @@ -286,8 +288,10 @@ public QueryResults fetchResults() { var modifiers = getMetadata().getModifiers(); if (getMetadata().getGroupBy().size() > 1 || getMetadata().getHaving() != null) { logger.warning( - "Fetchable#fetchResults() was computed in memory! See the Javadoc for" - + " AbstractJPAQuery#fetchResults for more details."); + """ + Fetchable#fetchResults() was computed in memory! See the Javadoc for\ + AbstractJPAQuery#fetchResults for more details.\ + """); var query = createQuery(null, false); @SuppressWarnings("unchecked") List resultList = query.getResultList(); diff --git a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/QDerbyDialect.java b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/QDerbyDialect.java index 7e9c4572dc..8f8d62f9ba 100644 --- a/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/QDerbyDialect.java +++ b/querydsl-libraries/querydsl-jpa/src/main/java/com/querydsl/jpa/support/QDerbyDialect.java @@ -16,7 +16,7 @@ import com.querydsl.core.types.Ops; import com.querydsl.sql.DerbyTemplates; import org.hibernate.boot.model.FunctionContributions; -import org.hibernate.dialect.DerbyDialect; +import org.hibernate.community.dialect.DerbyDialect; /** {@code QDerbyDialect} extends {@code DerbyDialect} with additional functions */ public class QDerbyDialect extends DerbyDialect { diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java index 6f22696422..5d580ef643 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/AbstractJPATest.java @@ -283,6 +283,7 @@ public void aggregates_uniqueResult_min() { } @Test + @NoEclipseLink public void alias() { assertThat(query().from(cat).select(cat.id.as(cat.id)).fetch()).hasSize(6); } diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateBase.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateBase.java index 4b2871944d..bd21563335 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateBase.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateBase.java @@ -81,7 +81,7 @@ public void setSession(Session session) { @Override protected void save(Object entity) { - session.save(entity); + session.persist(entity); } @Test diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateSQLBase.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateSQLBase.java index e75c174210..acae720222 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateSQLBase.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/HibernateSQLBase.java @@ -56,12 +56,12 @@ public void setSession(Session session) { @Before public void setUp() { if (query().from(cat).fetchCount() == 0) { - session.save(new Cat("Beck", 1, Color.BLACK)); - session.save(new Cat("Kate", 2, Color.BLACK)); - session.save(new Cat("Kitty", 3, Color.BLACK)); - session.save(new Cat("Bobby", 4, Color.BLACK)); - session.save(new Cat("Harold", 5, Color.BLACK)); - session.save(new Cat("Tim", 6, Color.BLACK)); + session.persist(new Cat("Beck", 1, Color.BLACK)); + session.persist(new Cat("Kate", 2, Color.BLACK)); + session.persist(new Cat("Kitty", 3, Color.BLACK)); + session.persist(new Cat("Bobby", 4, Color.BLACK)); + session.persist(new Cat("Harold", 5, Color.BLACK)); + session.persist(new Cat("Tim", 6, Color.BLACK)); session.flush(); } } diff --git a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/IntegrationBase.java b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/IntegrationBase.java index 3aef7b0cb9..ec9c5b8cc7 100644 --- a/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/IntegrationBase.java +++ b/querydsl-libraries/querydsl-jpa/src/test/java/com/querydsl/jpa/IntegrationBase.java @@ -98,8 +98,8 @@ private HibernateInsertClause insert(EntityPath entity) { @Test public void scroll() { - session.save(new Cat("Bob", 10)); - session.save(new Cat("Steve", 11)); + session.persist(new Cat("Bob", 10)); + session.persist(new Cat("Steve", 11)); var cat = QCat.cat; HibernateQuery query = new HibernateQuery(session); @@ -112,7 +112,7 @@ public void scroll() { @Test public void insert() { - session.save(new Cat("Bob", 10)); + session.persist(new Cat("Bob", 10)); var cat = QCat.cat; var amount = insert(cat).set(cat.name, "Bobby").set(cat.alive, false).execute(); @@ -123,7 +123,7 @@ public void insert() { @Test public void insert2() { - session.save(new Cat("Bob", 10)); + session.persist(new Cat("Bob", 10)); var cat = QCat.cat; var amount = insert(cat).columns(cat.name, cat.alive).values("Bobby", false).execute(); @@ -134,7 +134,7 @@ public void insert2() { @Test public void insert3() { - session.save(new Cat("Bob", 10)); + session.persist(new Cat("Bob", 10)); var cat = QCat.cat; var bob = new QCat("Bob"); @@ -151,8 +151,8 @@ public void insert3() { @Test public void update() { - session.save(new Cat("Bob", 10)); - session.save(new Cat("Steve", 11)); + session.persist(new Cat("Bob", 10)); + session.persist(new Cat("Steve", 11)); var cat = QCat.cat; var amount = @@ -168,8 +168,8 @@ public void update() { @Test public void update_with_null() { - session.save(new Cat("Bob", 10)); - session.save(new Cat("Steve", 11)); + session.persist(new Cat("Bob", 10)); + session.persist(new Cat("Steve", 11)); var cat = QCat.cat; var amount = @@ -183,8 +183,8 @@ public void update_with_null() { @Test public void delete() { - session.save(new Cat("Bob", 10)); - session.save(new Cat("Steve", 11)); + session.persist(new Cat("Bob", 10)); + session.persist(new Cat("Steve", 11)); var cat = QCat.cat; var amount = delete(cat).where(cat.name.eq("Bob")).execute(); @@ -195,7 +195,7 @@ public void delete() { public void collection() throws Exception { List cats = Arrays.asList(new Cat("Bob", 10), new Cat("Steve", 11)); for (Cat cat : cats) { - session.save(cat); + session.persist(cat); } query().from(cat).innerJoin(cat.kittens, kitten).where(kitten.in(cats)).parse(); diff --git a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java index c88a2ffdc3..5ffe87e7a9 100644 --- a/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java +++ b/querydsl-libraries/querydsl-r2dbc/src/main/java/com/querydsl/r2dbc/dml/AbstractR2DBCDeleteClause.java @@ -53,9 +53,10 @@ public abstract class AbstractR2DBCDeleteClause entity; diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLiteTemplates.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLiteTemplates.java index 8fc80247d6..edc2a8cbdf 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLiteTemplates.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/SQLiteTemplates.java @@ -113,8 +113,10 @@ public SQLiteTemplates(char escape, boolean quote) { add( Ops.DateTimeOps.YEAR_MONTH, - "cast(strftime('%Y',{0} / 1000, 'unixepoch', 'localtime') * 100 + strftime('%m',{0} / 1000," - + " 'unixepoch', 'localtime') as integer)"); + """ + cast(strftime('%Y',{0} / 1000, 'unixepoch', 'localtime') * 100 + strftime('%m',{0} / 1000,\ + 'unixepoch', 'localtime') as integer)\ + """); add( Ops.DateTimeOps.YEAR_WEEK, "cast(strftime('%Y%W',{0} / 1000, 'unixepoch', 'localtime') as integer)"); diff --git a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/dml/AbstractSQLDeleteClause.java b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/dml/AbstractSQLDeleteClause.java index d11cedbc87..9cb702c1f7 100644 --- a/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/dml/AbstractSQLDeleteClause.java +++ b/querydsl-libraries/querydsl-sql/src/main/java/com/querydsl/sql/dml/AbstractSQLDeleteClause.java @@ -53,9 +53,10 @@ public abstract class AbstractSQLDeleteClause entity; diff --git a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/hibernate/HibernateConfiguration.java b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/hibernate/HibernateConfiguration.java index fb20ba2afe..4a7ec9eb2f 100644 --- a/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/hibernate/HibernateConfiguration.java +++ b/querydsl-tooling/querydsl-apt/src/main/java/com/querydsl/apt/hibernate/HibernateConfiguration.java @@ -47,7 +47,7 @@ public HibernateConfiguration( protected List> getAnnotations() { try { List> annotations = new ArrayList<>(super.getAnnotations()); - for (String simpleName : Arrays.asList("Type", "Cascade", "LazyCollection", "OnDelete")) { + for (String simpleName : Arrays.asList("Type", "Cascade", "OnDelete")) { annotations.add( (Class) Class.forName("org.hibernate.annotations." + simpleName)); } diff --git a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/InterfaceType2Test.java b/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/InterfaceType2Test.java index db2833b504..4a2079a244 100644 --- a/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/InterfaceType2Test.java +++ b/querydsl-tooling/querydsl-apt/src/test/java/com/querydsl/apt/domain/InterfaceType2Test.java @@ -49,8 +49,6 @@ public void setId(Long id) { @Entity @Table(name = "USERS") - // @org.hibernate.annotations.AccessType("field") - @org.hibernate.annotations.Proxy(proxyClass = User.class) public static class UserImpl extends EntityImpl implements User { @NaturalId(mutable = true) @@ -85,8 +83,6 @@ public void setParty(Party party) { @jakarta.persistence.Entity @Table(name = "PARTY") - // @org.hibernate.annotations.AccessType("field") - @org.hibernate.annotations.Proxy(proxyClass = Party.class) public abstract static class PartyImpl extends EntityImpl implements Party { @Column(name = "NAME", nullable = false) From 713f15f73ff40c2da556a27fff5fc5c996136a06 Mon Sep 17 00:00:00 2001 From: Marvin Date: Fri, 13 Sep 2024 18:10:26 +0000 Subject: [PATCH 9/9] Bump eclipselink to 5.0.0-B03 release Signed-off-by: Marvin Froeder --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 963cc8f031..1a2b7e7eaf 100644 --- a/pom.xml +++ b/pom.xml @@ -127,7 +127,7 @@ 7.0.0.Beta1 8.0.1.Final - 5.0.0-B02 + 5.0.0-B03 3.2.0 3.0.0