Skip to content

Commit 308f991

Browse files
committed
DATAJPA-1054 - Remove references to Assert single-arg methods.
Replace references to Assert single-arg methods with references to methods accepting the test object and message. Related ticket: SPR-15196.
1 parent f909a85 commit 308f991

18 files changed

+84
-70
lines changed

src/main/java/org/springframework/data/jpa/repository/cdi/JpaRepositoryBean.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011 the original author or authors.
2+
* Copyright 2011-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@
2525

2626
import org.springframework.data.jpa.repository.support.JpaRepositoryFactory;
2727
import org.springframework.data.repository.cdi.CdiRepositoryBean;
28-
import org.springframework.data.repository.config.CustomRepositoryImplementationDetector;
28+
import org.springframework.data.repository.config.CustomRepositoryImplementationDetector;
2929
import org.springframework.util.Assert;
3030

3131
/**
@@ -47,14 +47,14 @@ class JpaRepositoryBean<T> extends CdiRepositoryBean<T> {
4747
* @param entityManagerBean must not be {@literal null}.
4848
* @param qualifiers must not be {@literal null}.
4949
* @param repositoryType must not be {@literal null}.
50-
* @param detector can be {@literal null}.
50+
* @param detector can be {@literal null}.
5151
*/
5252
JpaRepositoryBean(BeanManager beanManager, Bean<EntityManager> entityManagerBean, Set<Annotation> qualifiers,
53-
Class<T> repositoryType, CustomRepositoryImplementationDetector detector) {
53+
Class<T> repositoryType, CustomRepositoryImplementationDetector detector) {
5454

55-
super(qualifiers, repositoryType, beanManager, detector);
55+
super(qualifiers, repositoryType, beanManager, detector);
5656

57-
Assert.notNull(entityManagerBean);
57+
Assert.notNull(entityManagerBean, "EntityManager bean must not be null!");
5858
this.entityManagerBean = entityManagerBean;
5959
}
6060

src/main/java/org/springframework/data/jpa/repository/query/AbstractJpaQuery.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2016 the original author or authors.
2+
* Copyright 2008-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,6 +48,7 @@
4848
*
4949
* @author Oliver Gierke
5050
* @author Thomas Darimont
51+
* @author Mark Paluch
5152
*/
5253
public abstract class AbstractJpaQuery implements RepositoryQuery {
5354

@@ -59,13 +60,12 @@ public abstract class AbstractJpaQuery implements RepositoryQuery {
5960
* Creates a new {@link AbstractJpaQuery} from the given {@link JpaQueryMethod}.
6061
*
6162
* @param method
62-
* @param resultFactory
6363
* @param em
6464
*/
6565
public AbstractJpaQuery(JpaQueryMethod method, EntityManager em) {
6666

67-
Assert.notNull(method);
68-
Assert.notNull(em);
67+
Assert.notNull(method, "JpaQueryMethod must not be null!");
68+
Assert.notNull(em, "EntityManager must not be null!");
6969

7070
this.method = method;
7171
this.em = em;

src/main/java/org/springframework/data/jpa/repository/query/CriteriaQueryParameterBinder.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2013 the original author or authors.
2+
* Copyright 2011-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
3232
*
3333
* @author Oliver Gierke
3434
* @author Thomas Darimont
35+
* @author Mark Paluch
3536
*/
3637
class CriteriaQueryParameterBinder extends ParameterBinder {
3738

@@ -41,14 +42,15 @@ class CriteriaQueryParameterBinder extends ParameterBinder {
4142
* Creates a new {@link CriteriaQueryParameterBinder} for the given {@link Parameters}, values and some
4243
* {@link javax.persistence.criteria.ParameterExpression}.
4344
*
44-
* @param parameters
45-
* @param values
46-
* @param expressions
45+
* @param parameters must not be {@literal null}.
46+
* @param values must not be {@literal null}.
47+
* @param expressions must not be {@literal null}.
4748
*/
4849
CriteriaQueryParameterBinder(JpaParameters parameters, Object[] values, Iterable<ParameterMetadata<?>> expressions) {
4950

5051
super(parameters, values);
51-
Assert.notNull(expressions);
52+
53+
Assert.notNull(expressions, "Iterable of ParameterMetadata must not be null!");
5254
this.expressions = expressions.iterator();
5355
}
5456

src/main/java/org/springframework/data/jpa/repository/query/JpaQueryCreator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2016 the original author or authors.
2+
* Copyright 2008-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -229,8 +229,8 @@ private class PredicateBuilder {
229229
*/
230230
public PredicateBuilder(Part part, Root<?> root) {
231231

232-
Assert.notNull(part);
233-
Assert.notNull(root);
232+
Assert.notNull(part, "Part must not be null!");
233+
Assert.notNull(root, "Root must not be null!");
234234
this.part = part;
235235
this.root = root;
236236
}

src/main/java/org/springframework/data/jpa/repository/query/JpaQueryExecution.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2016 the original author or authors.
2+
* Copyright 2008-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -71,13 +71,13 @@ public abstract class JpaQueryExecution {
7171
* Executes the given {@link AbstractStringBasedJpaQuery} with the given {@link ParameterBinder}.
7272
*
7373
* @param query must not be {@literal null}.
74-
* @param binder must not be {@literal null}.
74+
* @param values must not be {@literal null}.
7575
* @return
7676
*/
7777
public Object execute(AbstractJpaQuery query, Object[] values) {
7878

79-
Assert.notNull(query);
80-
Assert.notNull(values);
79+
Assert.notNull(query, "AbstractJpaQuery must not be null!");
80+
Assert.notNull(values, "Values must not be null!");
8181

8282
Object result;
8383

src/main/java/org/springframework/data/jpa/repository/query/ParameterBinder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2014 the original author or authors.
2+
* Copyright 2008-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@
3333
*
3434
* @author Oliver Gierke
3535
* @author Thomas Darimont
36+
* @author Mark Paluch
3637
*/
3738
public class ParameterBinder {
3839

@@ -48,8 +49,8 @@ public class ParameterBinder {
4849
*/
4950
public ParameterBinder(JpaParameters parameters, Object[] values) {
5051

51-
Assert.notNull(parameters);
52-
Assert.notNull(values);
52+
Assert.notNull(parameters, "JpaParameters must not be null!");
53+
Assert.notNull(values, "Values must not be null!");
5354

5455
Assert.isTrue(parameters.getNumberOfParameters() == values.length, "Invalid number of parameters given!");
5556

src/main/java/org/springframework/data/jpa/repository/query/ParameterMetadataProvider.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2016 the original author or authors.
2+
* Copyright 2011-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -41,6 +41,7 @@
4141
*
4242
* @author Oliver Gierke
4343
* @author Thomas Darimont
44+
* @author Mark Paluch
4445
*/
4546
class ParameterMetadataProvider {
4647

@@ -144,12 +145,12 @@ public <T> ParameterMetadata<? extends T> next(Part part, Class<T> type) {
144145
* @param <T>
145146
* @param part must not be {@literal null}.
146147
* @param type must not be {@literal null}.
147-
* @param name
148+
* @param parameter
148149
* @return
149150
*/
150151
private <T> ParameterMetadata<T> next(Part part, Class<T> type, Parameter parameter) {
151152

152-
Assert.notNull(type);
153+
Assert.notNull(type, "Type must not be null!");
153154

154155
/*
155156
* We treat Expression types as Object vales since the real value to be bound as a parameter is determined at query time.
@@ -221,7 +222,7 @@ public boolean isIsNullParameter() {
221222
*/
222223
public Object prepare(Object value) {
223224

224-
Assert.notNull(value);
225+
Assert.notNull(value, "Value must not be null!");
225226

226227
Class<? extends T> expressionType = expression.getJavaType();
227228

src/main/java/org/springframework/data/jpa/repository/query/QueryUtils.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2016 the original author or authors.
2+
* Copyright 2008-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,6 +69,7 @@
6969
* @author Thomas Darimont
7070
* @author Komi Innocent
7171
* @author Christoph Strobl
72+
* @author Mark Paluch
7273
*/
7374
public abstract class QueryUtils {
7475

@@ -221,14 +222,14 @@ public static String applySorting(String query, Sort sort) {
221222
/**
222223
* Adds {@literal order by} clause to the JPQL query.
223224
*
224-
* @param query
225+
* @param query must not be {@literal null} or empty.
225226
* @param sort
226227
* @param alias
227228
* @return
228229
*/
229230
public static String applySorting(String query, Sort sort, String alias) {
230231

231-
Assert.hasText(query);
232+
Assert.hasText(query, "Query must not be null or empty!");
232233

233234
if (null == sort || !sort.iterator().hasNext()) {
234235
return query;
@@ -356,16 +357,16 @@ public static String detectAlias(String query) {
356357
* entities to the query.
357358
*
358359
* @param <T>
359-
* @param queryString
360-
* @param entities
361-
* @param entityManager
360+
* @param queryString must not be {@literal null}.
361+
* @param entities must not be {@literal null}.
362+
* @param entityManager must not be {@literal null}.
362363
* @return
363364
*/
364365
public static <T> Query applyAndBind(String queryString, Iterable<T> entities, EntityManager entityManager) {
365366

366-
Assert.notNull(queryString);
367-
Assert.notNull(entities);
368-
Assert.notNull(entityManager);
367+
Assert.notNull(queryString, "Querystring must not be null!");
368+
Assert.notNull(entities, "Iterable of entities must not be null!");
369+
Assert.notNull(entityManager, "EntityManager must not be null!");
369370

370371
Iterator<T> iterator = entities.iterator();
371372

@@ -489,8 +490,8 @@ public static List<javax.persistence.criteria.Order> toOrders(Sort sort, Root<?>
489490
return orders;
490491
}
491492

492-
Assert.notNull(root);
493-
Assert.notNull(cb);
493+
Assert.notNull(root, "Root must not be null!");
494+
Assert.notNull(cb, "CriteriaBuilder must not be null!");
494495

495496
for (org.springframework.data.domain.Sort.Order order : sort) {
496497
orders.add(toJpaOrder(order, root, cb));

src/main/java/org/springframework/data/jpa/repository/query/StringQuery.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2016 the original author or authors.
2+
* Copyright 2013-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,6 +37,7 @@
3737
* @author Oliver Gierke
3838
* @author Thomas Darimont
3939
* @author Oliver Wehrens
40+
* @author Mark Paluch
4041
*/
4142
class StringQuery {
4243

@@ -729,7 +730,7 @@ public String toString() {
729730
*/
730731
private static Type getLikeTypeFrom(String expression) {
731732

732-
Assert.hasText(expression);
733+
Assert.hasText(expression, "Expression must not be null or empty!");
733734

734735
if (expression.matches("%.*%")) {
735736
return Type.CONTAINING;

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011 the original author or authors.
2+
* Copyright 2011-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
3030
* Base class for {@link JpaEntityInformation} implementations to share common method implementations.
3131
*
3232
* @author Oliver Gierke
33+
* @author Mark Paluch
3334
*/
3435
public abstract class JpaEntityInformationSupport<T, ID extends Serializable> extends AbstractEntityInformation<T, ID>
3536
implements JpaEntityInformation<T, ID> {
@@ -56,8 +57,8 @@ public JpaEntityInformationSupport(Class<T> domainClass) {
5657
@SuppressWarnings({ "rawtypes", "unchecked" })
5758
public static <T> JpaEntityInformation<T, ?> getEntityInformation(Class<T> domainClass, EntityManager em) {
5859

59-
Assert.notNull(domainClass);
60-
Assert.notNull(em);
60+
Assert.notNull(domainClass, "Domain class must not be null!");
61+
Assert.notNull(em, "EntityManager must not be null!");
6162

6263
Metamodel metamodel = em.getMetamodel();
6364

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2016 the original author or authors.
2+
* Copyright 2011-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@ public JpaMetamodelEntityInformation(Class<T> domainClass, Metamodel metamodel)
6464

6565
super(domainClass);
6666

67-
Assert.notNull(metamodel);
67+
Assert.notNull(metamodel, "Metamodel must not be null!");
6868
this.metamodel = metamodel;
6969

7070
ManagedType<T> type = metamodel.managedType(domainClass);
@@ -210,7 +210,9 @@ public Iterable<String> getIdAttributeNames() {
210210
* @see org.springframework.data.jpa.repository.support.JpaEntityInformation#getCompositeIdAttributeValue(java.io.Serializable, java.lang.String)
211211
*/
212212
public Object getCompositeIdAttributeValue(Serializable id, String idAttribute) {
213-
Assert.isTrue(hasCompositeId());
213+
214+
Assert.isTrue(hasCompositeId(), "Model must have a composite Id!");
215+
214216
return new DirectFieldAccessFallbackBeanWrapper(id).getPropertyValue(idAttribute);
215217
}
216218

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2015 the original author or authors.
2+
* Copyright 2008-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@
3838
* JPA specific generic repository factory.
3939
*
4040
* @author Oliver Gierke
41+
* @author Mark Paluch
4142
*/
4243
public class JpaRepositoryFactory extends RepositoryFactorySupport {
4344

@@ -52,7 +53,7 @@ public class JpaRepositoryFactory extends RepositoryFactorySupport {
5253
*/
5354
public JpaRepositoryFactory(EntityManager entityManager) {
5455

55-
Assert.notNull(entityManager);
56+
Assert.notNull(entityManager, "EntityManager must not be null!");
5657

5758
this.entityManager = entityManager;
5859
this.extractor = PersistenceProvider.fromEntityManager(entityManager);

0 commit comments

Comments
 (0)