diff --git a/src/main/java/org/springframework/data/repository/query/Parameters.java b/src/main/java/org/springframework/data/repository/query/Parameters.java index c3b996b1b..a2aaed681 100644 --- a/src/main/java/org/springframework/data/repository/query/Parameters.java +++ b/src/main/java/org/springframework/data/repository/query/Parameters.java @@ -42,7 +42,7 @@ public abstract class Parameters, T extends Parameter public static final List> TYPES = Arrays.asList(Pageable.class, Sort.class); - private static final String PARAM_ON_SPECIAL = format("You must not user @%s on a parameter typed %s or %s", + private static final String PARAM_ON_SPECIAL = format("You must not use @%s on a parameter typed %s or %s", Param.class.getSimpleName(), Pageable.class.getSimpleName(), Sort.class.getSimpleName()); private static final String ALL_OR_NOTHING = String.format( "Either use @%s on all parameters except %s and %s typed once, or none at all!", Param.class.getSimpleName(), @@ -301,8 +301,6 @@ public abstract class Parameters, T extends Parameter /** * Asserts that either all of the non special parameters ({@link Pageable}, {@link Sort}) are annotated with * {@link Param} or none of them is. - * - * @param method */ private void assertEitherAllParamAnnotatedOrNone() { diff --git a/src/main/java/org/springframework/data/repository/query/QueryMethod.java b/src/main/java/org/springframework/data/repository/query/QueryMethod.java index e7d9dd33a..4d2066c54 100644 --- a/src/main/java/org/springframework/data/repository/query/QueryMethod.java +++ b/src/main/java/org/springframework/data/repository/query/QueryMethod.java @@ -69,12 +69,12 @@ public class QueryMethod { Assert.notNull(metadata, "Repository metadata must not be null!"); Assert.notNull(factory, "ProjectionFactory must not be null!"); - Parameters.TYPES.stream()// - .filter(type -> getNumberOfOccurences(method, type) > 1)// + Parameters.TYPES.stream() + .filter(type -> getNumberOfOccurences(method, type) > 1) .findFirst().ifPresent(type -> { throw new IllegalStateException( - String.format("Method must only one argument of type %s! Offending method: %s", type.getSimpleName(), - method.toString())); + String.format("Method must have only one argument of type %s! Offending method: %s", + type.getSimpleName(), method)); }); this.method = method; @@ -89,8 +89,8 @@ public class QueryMethod { } if (hasParameterOfType(method, Sort.class)) { - throw new IllegalStateException(String.format("Method must not have Pageable *and* Sort parameter. " - + "Use sorting capabilities on Pageable instead! Offending method: %s", method.toString())); + throw new IllegalStateException(String.format("Method must not have Pageable *and* Sort parameters. " + + "Use sorting capabilities on Pageable instead! Offending method: %s", method)); } } @@ -99,7 +99,7 @@ public class QueryMethod { if (isPageQuery()) { Assert.isTrue(this.parameters.hasPageableParameter(), - String.format("Paging query needs to have a Pageable parameter! Offending method %s", method.toString())); + String.format("Paging query needs to have a Pageable parameter! Offending method: %s", method)); } this.domainClass = Lazy.of(() -> { @@ -311,6 +311,6 @@ public class QueryMethod { } } - throw new IllegalStateException("Method has to have one of the following return types! " + types.toString()); + throw new IllegalStateException("Method has to have one of the following return types! " + types); } }