Skip to content

Commit d47020d

Browse files
committed
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.
1 parent f6eacf3 commit d47020d

22 files changed

+128
-114
lines changed

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/BindMarker.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
*/
1616
package org.springframework.data.relational.core.sql;
1717

18-
import org.springframework.lang.Nullable;
19-
2018
/**
2119
* Bind marker/parameter placeholder used to construct prepared statements with parameter substitution.
2220
*

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Column.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class Column extends AbstractSegment implements Expression, Named {
5656
* @param name column name, must not {@literal null} or empty.
5757
* @param table the table, must not be {@literal null}.
5858
* @return the new {@link Column}.
59+
* @since 2.3
5960
*/
6061
public static Column create(String name, TableLike table) {
6162

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Comparison.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@ public static Comparison create(Expression leftColumnOrExpression, String compar
6161

6262
/**
6363
* Creates a new {@link Comparison} from simple {@literal StringP} arguments
64-
* @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}.
64+
*
65+
* @param unqualifiedColumnName gets turned in a {@link Expressions#just(String)} and is expected to be an unqualified
66+
* unique column name but also could be an verbatim expression. Must not be {@literal null}.
6567
* @param comparator must not be {@literal null}.
6668
* @param rightValue is considered a {@link Literal}. Must not be {@literal null}.
67-
* @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}.
68-
*
69+
* @return a new {@literal Comparison} of the first with the third argument using the second argument as comparison
70+
* operator. Guaranteed to be not {@literal null}.
6971
* @since 2.3
7072
*/
7173
public static Comparison create(String unqualifiedColumnName, String comparator, Object rightValue) {

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/ConstantCondition.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
*/
2424
public class ConstantCondition extends AbstractSegment implements Condition {
2525

26-
private final String condition;
26+
private final String condition;
2727

28-
ConstantCondition(String condition) {
29-
this.condition = condition;
30-
}
28+
ConstantCondition(String condition) {
29+
this.condition = condition;
30+
}
3131

32-
@Override
33-
public String toString() {
34-
return condition;
35-
}
32+
@Override
33+
public String toString() {
34+
return condition;
35+
}
3636
}

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/DefaultSelectBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ public SelectLock lock(LockMode lockMode) {
285285
@Override
286286
public Select build() {
287287

288-
DefaultSelect select = new DefaultSelect(distinct, selectList, from, limit, offset, joins, where, orderBy, lockMode);
288+
DefaultSelect select = new DefaultSelect(distinct, selectList, from, limit, offset, joins, where, orderBy,
289+
lockMode);
289290
SelectValidator.validate(select);
290291
return select;
291292
}

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/InlineQuery.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
import org.springframework.util.Assert;
1919

2020
/**
21-
* Represents a inline query within a SQL statement. Typically used in {@code FROM} or {@code JOIN} clauses.
22-
* <p/>
23-
* Renders to: {@code (<SELECT>) AS <ALIAS>} in a from or join clause, and to {@code <ALIAS>} when used in an
24-
* expression.
25-
* <p/>
21+
* Represents a inline query within a SQL statement. Typically, used in {@code FROM} or {@code JOIN} clauses.
22+
* <p>
23+
* Renders to: {@code (&gt;SELECT&lt;) AS &gt;ALIAS&lt;} in a from or join clause, and to {@code &gt;ALIAS&lt;} when
24+
* used in an expression.
25+
* <p>
2626
* Note that this does not implement {@link Aliased} because the Alias is not optional but required and therefore more
2727
* like a name although the SQL term is "alias".
28-
*
28+
*
2929
* @author Jens Schauder
3030
* @since 2.3
3131
*/
@@ -68,13 +68,11 @@ public static InlineQuery create(Select select, String alias) {
6868
return create(select, SqlIdentifier.unquoted(alias));
6969
}
7070

71-
/**
72-
* @return the table name.
73-
*/
7471
/*
7572
* (non-Javadoc)
7673
* @see org.springframework.data.relational.core.sql.Named#getName()
7774
*/
75+
@Override
7876
public SqlIdentifier getName() {
7977
return alias;
8078
}
@@ -83,6 +81,7 @@ public SqlIdentifier getName() {
8381
* @return the table name as it is used in references. This can be the actual {@link #getName() name} or an
8482
* {@link Aliased#getAlias() alias}.
8583
*/
84+
@Override
8685
public SqlIdentifier getReferenceName() {
8786
return alias;
8887
}

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Select.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
*/
1616
package org.springframework.data.relational.core.sql;
1717

18-
import org.springframework.lang.Nullable;
19-
2018
import java.util.List;
2119
import java.util.OptionalLong;
2220

21+
import org.springframework.lang.Nullable;
22+
2323
/**
2424
* AST for a {@code SELECT} statement. Visiting order:
2525
* <ol>

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/SelectBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ interface SelectFromAndOrderBy extends SelectFrom, SelectOrdered, SelectLimitOff
251251
* Builder exposing {@code FROM}, {@code JOIN}, {@code WHERE}, {@code LIMIT/OFFSET} and {@code LOCK} methods.
252252
*/
253253
interface SelectFromAndJoin
254-
extends SelectFromAndOrderBy, BuildSelect, SelectJoin, SelectWhere, SelectLimitOffset, SelectLock {
254+
extends SelectFromAndOrderBy, BuildSelect, SelectJoin, SelectWhere, SelectLimitOffset, SelectLock {
255255

256256
/**
257257
* Declare a {@link Table} to {@code SELECT … FROM}. Multiple calls to this or other {@code from} methods keep
@@ -317,7 +317,8 @@ interface SelectFromAndJoin
317317
}
318318

319319
/**
320-
* Builder exposing {@code FROM}, {@code WHERE}, {@code LIMIT/OFFSET}, JOIN {@code AND} and {@code LOCK} continuation methods.
320+
* Builder exposing {@code FROM}, {@code WHERE}, {@code LIMIT/OFFSET}, JOIN {@code AND} and {@code LOCK} continuation
321+
* methods.
321322
*/
322323
interface SelectFromAndJoinCondition
323324
extends BuildSelect, SelectJoin, SelectWhere, SelectOnCondition, SelectLimitOffset, SelectLock {

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/Table.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,12 @@ public Table as(SqlIdentifier alias) {
107107
return new AliasedTable(name, alias);
108108
}
109109

110-
/**
111-
* @return the table name.
112-
*/
110+
113111
/*
114112
* (non-Javadoc)
115113
* @see org.springframework.data.relational.core.sql.Named#getName()
116114
*/
115+
@Override
117116
public SqlIdentifier getName() {
118117
return name;
119118
}
@@ -122,6 +121,7 @@ public SqlIdentifier getName() {
122121
* @return the table name as it is used in references. This can be the actual {@link #getName() name} or an
123122
* {@link Aliased#getAlias() alias}.
124123
*/
124+
@Override
125125
public SqlIdentifier getReferenceName() {
126126
return name;
127127
}

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/TableLike.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
*/
1616
package org.springframework.data.relational.core.sql;
1717

18-
import org.springframework.util.Assert;
19-
2018
import java.util.ArrayList;
2119
import java.util.Arrays;
2220
import java.util.Collection;
2321
import java.util.List;
2422

23+
import org.springframework.util.Assert;
24+
2525
/**
2626
* A segment that can be used as table in a query.
2727
*
@@ -61,6 +61,7 @@ default Column column(SqlIdentifier name) {
6161

6262
return new Column(name, this);
6363
}
64+
6465
/**
6566
* Creates a {@link List} of {@link Column}s associated with this {@link Table}.
6667
* <p/>
@@ -132,7 +133,14 @@ default AsteriskFromTable asterisk() {
132133
return new AsteriskFromTable(this);
133134
}
134135

136+
/**
137+
* @return the table name.
138+
*/
135139
SqlIdentifier getName();
136140

141+
/**
142+
* @return the table name as it is used in references. This can be the actual {@link #getName() name} or an
143+
* {@link Aliased#getAlias() alias}.
144+
*/
137145
SqlIdentifier getReferenceName();
138146
}

0 commit comments

Comments
 (0)