From d47020d868770004f6adc74e146e6c439b581391 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Tue, 28 Sep 2021 10:50:16 +0200 Subject: [PATCH] Polishing. Reformat code. Remove duplicate, lingering Javadoc. Add override annotations. Use entities instead of < and >. Reduce method/class visibility in tests. See #1003 Original pull request: #1018. --- .../data/relational/core/sql/BindMarker.java | 2 - .../data/relational/core/sql/Column.java | 1 + .../data/relational/core/sql/Comparison.java | 8 +-- .../core/sql/ConstantCondition.java | 16 +++--- .../core/sql/DefaultSelectBuilder.java | 3 +- .../data/relational/core/sql/InlineQuery.java | 17 +++--- .../data/relational/core/sql/Select.java | 4 +- .../relational/core/sql/SelectBuilder.java | 5 +- .../data/relational/core/sql/Table.java | 6 +-- .../data/relational/core/sql/TableLike.java | 12 ++++- .../core/sql/render/ColumnVisitor.java | 5 +- .../core/sql/render/ComparisonVisitor.java | 1 - .../sql/render/ConstantConditionVisitor.java | 2 +- .../core/sql/render/ExpressionVisitor.java | 2 + .../core/sql/render/FromTableVisitor.java | 6 +-- .../core/sql/render/SelectListVisitor.java | 6 ++- .../core/sql/render/SelectRenderContext.java | 3 +- .../core/sql/render/SimpleRenderContext.java | 4 +- .../render/FromClauseVisitorUnitTests.java | 17 +++--- .../sql/render/JoinVisitorTestsUnitTest.java | 20 ++++--- .../sql/render/SelectRendererUnitTests.java | 54 +++++++++---------- .../render/TypedSubtreeVisitorUnitTests.java | 48 ++++++++--------- 22 files changed, 128 insertions(+), 114 deletions(-) diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/BindMarker.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/BindMarker.java index 16f3b65e..2a550196 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/BindMarker.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/BindMarker.java @@ -15,8 +15,6 @@ */ package org.springframework.data.relational.core.sql; -import org.springframework.lang.Nullable; - /** * Bind marker/parameter placeholder used to construct prepared statements with parameter substitution. * diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Column.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Column.java index 29ce325d..71f3ab2d 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Column.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Column.java @@ -56,6 +56,7 @@ public class Column extends AbstractSegment implements Expression, Named { * @param name column name, must not {@literal null} or empty. * @param table the table, must not be {@literal null}. * @return the new {@link Column}. + * @since 2.3 */ public static Column create(String name, TableLike table) { diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Comparison.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Comparison.java index 60b9e875..c04ecb49 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Comparison.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Comparison.java @@ -61,11 +61,13 @@ public class Comparison extends AbstractSegment implements Condition { /** * Creates a new {@link Comparison} from simple {@literal StringP} arguments - * @param unqualifiedColumnName gets turned in a {@link Expressions#just(String)} and is expected to be an unqualified unique column name but also could be an verbatim expression. Must not be {@literal null}. + * + * @param unqualifiedColumnName gets turned in a {@link Expressions#just(String)} and is expected to be an unqualified + * unique column name but also could be an verbatim expression. Must not be {@literal null}. * @param comparator must not be {@literal null}. * @param rightValue is considered a {@link Literal}. Must not be {@literal null}. - * @return a new {@literal Comparison} of the first with the third argument using the second argument as comparison operator. Guaranteed to be not {@literal null}. - * + * @return a new {@literal Comparison} of the first with the third argument using the second argument as comparison + * operator. Guaranteed to be not {@literal null}. * @since 2.3 */ public static Comparison create(String unqualifiedColumnName, String comparator, Object rightValue) { diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/ConstantCondition.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/ConstantCondition.java index f11e7036..f8f1baf3 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/ConstantCondition.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/ConstantCondition.java @@ -23,14 +23,14 @@ package org.springframework.data.relational.core.sql; */ public class ConstantCondition extends AbstractSegment implements Condition { - private final String condition; + private final String condition; - ConstantCondition(String condition) { - this.condition = condition; - } + ConstantCondition(String condition) { + this.condition = condition; + } - @Override - public String toString() { - return condition; - } + @Override + public String toString() { + return condition; + } } diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/DefaultSelectBuilder.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/DefaultSelectBuilder.java index 1e071744..49ff3a2a 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/DefaultSelectBuilder.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/DefaultSelectBuilder.java @@ -285,7 +285,8 @@ class DefaultSelectBuilder implements SelectBuilder, SelectAndFrom, SelectFromAn @Override public Select build() { - DefaultSelect select = new DefaultSelect(distinct, selectList, from, limit, offset, joins, where, orderBy, lockMode); + DefaultSelect select = new DefaultSelect(distinct, selectList, from, limit, offset, joins, where, orderBy, + lockMode); SelectValidator.validate(select); return select; } diff --git a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/InlineQuery.java b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/InlineQuery.java index 88c083af..02b3354a 100644 --- a/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/InlineQuery.java +++ b/spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/InlineQuery.java @@ -18,14 +18,14 @@ package org.springframework.data.relational.core.sql; import org.springframework.util.Assert; /** - * Represents a inline query within a SQL statement. Typically used in {@code FROM} or {@code JOIN} clauses. - *

- * Renders to: {@code (