Skip to content

Commit 1b41ffb

Browse files
committed
Polishing.
Remove superfluous `this.`. Fix a broken test. See #2329
1 parent 1196a89 commit 1b41ffb

File tree

4 files changed

+36
-33
lines changed

4 files changed

+36
-33
lines changed

src/main/java/org/springframework/data/jpa/repository/support/FetchableFluentQueryByExample.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ public FetchableFluentQuery<R> sortBy(Sort sort) {
9494

9595
Assert.notNull(sort, "Sort must not be null!");
9696

97-
return new FetchableFluentQueryByExample<>(this.example, this.entityType, this.resultType, this.sort.and(sort),
98-
this.properties, this.finder, this.countOperation, this.existsOperation, this.context, this.entityManager,
99-
this.escapeCharacter, new TypedQueryProjector(entityManager));
97+
return new FetchableFluentQueryByExample<>(example, entityType, resultType, sort.and(sort), properties, finder,
98+
countOperation, existsOperation, context, entityManager, escapeCharacter,
99+
new TypedQueryProjector(entityManager));
100100
}
101101

102102
/*
@@ -111,8 +111,8 @@ public <NR> FetchableFluentQuery<NR> as(Class<NR> resultType) {
111111
throw new UnsupportedOperationException("Class-based DTOs are not yet supported.");
112112
}
113113

114-
return new FetchableFluentQueryByExample<>(this.example, this.entityType, resultType, this.sort, this.properties,
115-
this.finder, this.countOperation, this.existsOperation, this.context, this.entityManager, this.escapeCharacter,
114+
return new FetchableFluentQueryByExample<>(example, entityType, resultType, sort, properties, finder,
115+
countOperation, existsOperation, context, entityManager, escapeCharacter,
116116
new TypedQueryProjector(entityManager));
117117
}
118118

@@ -123,9 +123,9 @@ public <NR> FetchableFluentQuery<NR> as(Class<NR> resultType) {
123123
@Override
124124
public FetchableFluentQuery<R> project(Collection<String> properties) {
125125

126-
return new FetchableFluentQueryByExample<>(this.example, this.entityType, this.resultType, this.sort,
127-
mergeProperties(properties), this.finder, this.countOperation, this.existsOperation, this.context,
128-
this.entityManager, this.escapeCharacter, new TypedQueryProjector(entityManager));
126+
return new FetchableFluentQueryByExample<>(example, entityType, resultType, sort, mergeProperties(properties),
127+
finder, countOperation, existsOperation, context, entityManager, escapeCharacter,
128+
new TypedQueryProjector(entityManager));
129129
}
130130

131131
/*
@@ -201,7 +201,7 @@ public Stream<R> stream() {
201201
*/
202202
@Override
203203
public long count() {
204-
return this.countOperation.apply(example);
204+
return countOperation.apply(example);
205205
}
206206

207207
/*
@@ -210,7 +210,7 @@ public long count() {
210210
*/
211211
@Override
212212
public boolean exists() {
213-
return this.existsOperation.apply(example);
213+
return existsOperation.apply(example);
214214
}
215215

216216
private Page<R> readPage(Pageable pageable) {
@@ -224,12 +224,12 @@ private Page<R> readPage(Pageable pageable) {
224224

225225
List<R> paginatedResults = convert(pagedQuery.getResultList());
226226

227-
return PageableExecutionUtils.getPage(paginatedResults, pageable, () -> this.countOperation.apply(this.example));
227+
return PageableExecutionUtils.getPage(paginatedResults, pageable, () -> countOperation.apply(example));
228228
}
229229

230230
private TypedQuery<S> createSortedAndProjectedQuery() {
231231

232-
TypedQuery<S> query = this.finder.apply(this.sort);
232+
TypedQuery<S> query = finder.apply(sort);
233233
projector.apply(entityType, query, properties);
234234

235235
return query;
@@ -247,7 +247,7 @@ private List<R> convert(List<S> resultList) {
247247
}
248248

249249
private Function<Object, R> getConversionFunction() {
250-
return getConversionFunction(this.example.getProbeType(), this.resultType);
250+
return getConversionFunction(example.getProbeType(), resultType);
251251
}
252252

253253
}

src/main/java/org/springframework/data/jpa/repository/support/FetchableFluentQueryByPredicate.java

+12-15
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ public FetchableFluentQuery<R> sortBy(Sort sort) {
9292

9393
Assert.notNull(sort, "Sort must not be null!");
9494

95-
return new FetchableFluentQueryByPredicate<>(this.predicate, this.entityType, this.resultType, this.sort.and(sort),
96-
this.properties, this.finder, this.pagedFinder, this.countOperation, this.existsOperation, this.context,
97-
this.projector);
95+
return new FetchableFluentQueryByPredicate<>(predicate, entityType, resultType, sort.and(sort), properties, finder,
96+
pagedFinder, countOperation, existsOperation, context, projector);
9897
}
9998

10099
/*
@@ -110,9 +109,8 @@ public <NR> FetchableFluentQuery<NR> as(Class<NR> resultType) {
110109
throw new UnsupportedOperationException("Class-based DTOs are not yet supported.");
111110
}
112111

113-
return new FetchableFluentQueryByPredicate<>(this.predicate, this.entityType, resultType, this.sort,
114-
this.properties, this.finder, this.pagedFinder, this.countOperation, this.existsOperation, this.context,
115-
this.projector);
112+
return new FetchableFluentQueryByPredicate<>(predicate, entityType, resultType, sort, properties, finder,
113+
pagedFinder, countOperation, existsOperation, context, projector);
116114
}
117115

118116
/*
@@ -122,9 +120,8 @@ public <NR> FetchableFluentQuery<NR> as(Class<NR> resultType) {
122120
@Override
123121
public FetchableFluentQuery<R> project(Collection<String> properties) {
124122

125-
return new FetchableFluentQueryByPredicate<>(this.predicate, this.entityType, this.resultType, this.sort,
126-
mergeProperties(properties), this.finder, this.pagedFinder, this.countOperation, this.existsOperation,
127-
this.context, this.projector);
123+
return new FetchableFluentQueryByPredicate<>(predicate, entityType, resultType, sort, mergeProperties(properties),
124+
finder, pagedFinder, countOperation, existsOperation, context, projector);
128125
}
129126

130127
/*
@@ -195,7 +192,7 @@ public Stream<R> stream() {
195192
*/
196193
@Override
197194
public long count() {
198-
return this.countOperation.apply(this.predicate);
195+
return countOperation.apply(predicate);
199196
}
200197

201198
/*
@@ -204,22 +201,22 @@ public long count() {
204201
*/
205202
@Override
206203
public boolean exists() {
207-
return this.existsOperation.apply(this.predicate);
204+
return existsOperation.apply(predicate);
208205
}
209206

210207
private AbstractJPAQuery<?, ?> createSortedAndProjectedQuery() {
211208

212-
final AbstractJPAQuery<?, ?> query = this.finder.apply(this.sort);
209+
final AbstractJPAQuery<?, ?> query = finder.apply(sort);
213210
projector.apply(entityType, query, properties);
214211
return query;
215212
}
216213

217214
private Page<R> readPage(Pageable pageable) {
218215

219-
AbstractJPAQuery<?, ?> pagedQuery = this.pagedFinder.apply(this.sort, pageable);
216+
AbstractJPAQuery<?, ?> pagedQuery = pagedFinder.apply(sort, pageable);
220217
List<R> paginatedResults = convert(pagedQuery.fetch());
221218

222-
return PageableExecutionUtils.getPage(paginatedResults, pageable, () -> this.countOperation.apply(this.predicate));
219+
return PageableExecutionUtils.getPage(paginatedResults, pageable, () -> countOperation.apply(predicate));
223220
}
224221

225222
private List<R> convert(List<?> resultList) {
@@ -235,7 +232,7 @@ private List<R> convert(List<?> resultList) {
235232
}
236233

237234
private Function<Object, R> getConversionFunction() {
238-
return getConversionFunction(this.entityType, this.resultType);
235+
return getConversionFunction(entityType, resultType);
239236
}
240237

241238
}

src/main/java/org/springframework/data/jpa/repository/support/FluentQuerySupport.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ abstract class FluentQuerySupport<S, R> {
6767
final Collection<String> mergeProperties(Collection<String> additionalProperties) {
6868

6969
Set<String> newProperties = new HashSet<>();
70-
newProperties.addAll(this.properties);
70+
newProperties.addAll(properties);
7171
newProperties.addAll(additionalProperties);
7272
return Collections.unmodifiableCollection(newProperties);
7373
}

src/test/java/org/springframework/data/jpa/repository/support/QuerydslProjectorUnitTests.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ void emptySetOfPropertiesDoesNotCreateEntityGraph() {
5858
@Test
5959
void simpleSetOfPropertiesGetRegistered() {
6060

61-
final HashSet<String> properties = new HashSet<>(asList("alpha", "beta"));
61+
final HashSet<String> properties = new HashSet<>(asList("one", "two"));
6262

6363
new QuerydslProjector(em).apply(DummyEntity.class, jpaQuery, properties);
6464

6565
verify(jpaQuery).setHint("javax.persistence.fetchgraph", entityGraph);
66-
verify(entityGraph).addAttributeNodes("alpha");
67-
verify(entityGraph).addAttributeNodes("beta");
66+
verify(entityGraph).addAttributeNodes("one");
67+
verify(entityGraph).addAttributeNodes("two");
6868
}
6969

7070
// GH-2329
@@ -88,5 +88,11 @@ void setOfCompositePropertiesGetRegisteredPiecewise() {
8888
verify(zwei).addAttributeNodes("drei");
8989
}
9090

91-
private static class DummyEntity {}
91+
private static class DummyEntity {
92+
DummyEntity one;
93+
DummyEntity two;
94+
DummyEntity eins;
95+
DummyEntity zwei;
96+
DummyEntity drei;
97+
}
9298
}

0 commit comments

Comments
 (0)