Skip to content

Commit d8a0f45

Browse files
committed
Fix grammatical errors in Exception messages.
Closes #2599.
1 parent 72fdec7 commit d8a0f45

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/main/java/org/springframework/data/repository/query/Parameters.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public abstract class Parameters<S extends Parameters<S, T>, T extends Parameter
4242

4343
public static final List<Class<?>> TYPES = Arrays.asList(Pageable.class, Sort.class);
4444

45-
private static final String PARAM_ON_SPECIAL = format("You must not user @%s on a parameter typed %s or %s",
45+
private static final String PARAM_ON_SPECIAL = format("You must not use @%s on a parameter typed %s or %s",
4646
Param.class.getSimpleName(), Pageable.class.getSimpleName(), Sort.class.getSimpleName());
4747
private static final String ALL_OR_NOTHING = String.format(
4848
"Either use @%s on all parameters except %s and %s typed once, or none at all!", Param.class.getSimpleName(),
@@ -301,8 +301,6 @@ public T getBindableParameter(int bindableIndex) {
301301
/**
302302
* Asserts that either all of the non special parameters ({@link Pageable}, {@link Sort}) are annotated with
303303
* {@link Param} or none of them is.
304-
*
305-
* @param method
306304
*/
307305
private void assertEitherAllParamAnnotatedOrNone() {
308306

src/main/java/org/springframework/data/repository/query/QueryMethod.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ public QueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory
6969
Assert.notNull(metadata, "Repository metadata must not be null!");
7070
Assert.notNull(factory, "ProjectionFactory must not be null!");
7171

72-
Parameters.TYPES.stream()//
73-
.filter(type -> getNumberOfOccurences(method, type) > 1)//
72+
Parameters.TYPES.stream()
73+
.filter(type -> getNumberOfOccurences(method, type) > 1)
7474
.findFirst().ifPresent(type -> {
7575
throw new IllegalStateException(
76-
String.format("Method must only one argument of type %s! Offending method: %s", type.getSimpleName(),
77-
method.toString()));
76+
String.format("Method must have only one argument of type %s! Offending method: %s",
77+
type.getSimpleName(), method));
7878
});
7979

8080
this.method = method;
@@ -89,8 +89,8 @@ public QueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory
8989
}
9090

9191
if (hasParameterOfType(method, Sort.class)) {
92-
throw new IllegalStateException(String.format("Method must not have Pageable *and* Sort parameter. "
93-
+ "Use sorting capabilities on Pageable instead! Offending method: %s", method.toString()));
92+
throw new IllegalStateException(String.format("Method must not have Pageable *and* Sort parameters. "
93+
+ "Use sorting capabilities on Pageable instead! Offending method: %s", method));
9494
}
9595
}
9696

@@ -99,7 +99,7 @@ public QueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory
9999

100100
if (isPageQuery()) {
101101
Assert.isTrue(this.parameters.hasPageableParameter(),
102-
String.format("Paging query needs to have a Pageable parameter! Offending method %s", method.toString()));
102+
String.format("Paging query needs to have a Pageable parameter! Offending method: %s", method));
103103
}
104104

105105
this.domainClass = Lazy.of(() -> {
@@ -315,6 +315,6 @@ private static void assertReturnTypeAssignable(Method method, Set<Class<?>> type
315315
}
316316
}
317317

318-
throw new IllegalStateException("Method has to have one of the following return types! " + types.toString());
318+
throw new IllegalStateException("Method has to have one of the following return types! " + types);
319319
}
320320
}

0 commit comments

Comments
 (0)