75
75
*/
76
76
public class QuerydslJpaPredicateExecutor <T > implements QuerydslPredicateExecutor <T >, JpaRepositoryConfigurationAware {
77
77
78
+ private static final String PREDICATE_MUST_NOT_BE_NULL = "Predicate must not be null" ;
79
+ private static final String ORDER_SPECIFIERS_MUST_NOT_BE_NULL = "Order specifiers must not be null" ;
80
+ private static final String SORT_MUST_NOT_BE_NULL = "Sort must not be null" ;
81
+ private static final String PAGEABLE_MUST_NOT_BE_NULL = "Pageable must not be null" ;
82
+ private static final String QUERY_FUNCTION_MUST_NOT_BE_NULL = "Query function must not be null" ;
83
+
78
84
private final JpaEntityInformation <T , ?> entityInformation ;
79
85
private final EntityPath <T > path ;
80
86
private final Querydsl querydsl ;
@@ -116,7 +122,7 @@ public void setProjectionFactory(ProjectionFactory projectionFactory) {
116
122
@ Override
117
123
public Optional <T > findOne (Predicate predicate ) {
118
124
119
- Assert .notNull (predicate , "Predicate must not be null" );
125
+ Assert .notNull (predicate , PREDICATE_MUST_NOT_BE_NULL );
120
126
121
127
try {
122
128
return Optional .ofNullable (createQuery (predicate ).select (path ).limit (2 ).fetchOne ());
@@ -128,42 +134,42 @@ public Optional<T> findOne(Predicate predicate) {
128
134
@ Override
129
135
public List <T > findAll (Predicate predicate ) {
130
136
131
- Assert .notNull (predicate , "Predicate must not be null" );
137
+ Assert .notNull (predicate , PREDICATE_MUST_NOT_BE_NULL );
132
138
133
139
return createQuery (predicate ).select (path ).fetch ();
134
140
}
135
141
136
142
@ Override
137
143
public List <T > findAll (Predicate predicate , OrderSpecifier <?>... orders ) {
138
144
139
- Assert .notNull (predicate , "Predicate must not be null" );
140
- Assert .notNull (orders , "Order specifiers must not be null" );
145
+ Assert .notNull (predicate , PREDICATE_MUST_NOT_BE_NULL );
146
+ Assert .notNull (orders , ORDER_SPECIFIERS_MUST_NOT_BE_NULL );
141
147
142
148
return executeSorted (createQuery (predicate ).select (path ), orders );
143
149
}
144
150
145
151
@ Override
146
152
public List <T > findAll (Predicate predicate , Sort sort ) {
147
153
148
- Assert .notNull (predicate , "Predicate must not be null" );
149
- Assert .notNull (sort , "Sort must not be null" );
154
+ Assert .notNull (predicate , PREDICATE_MUST_NOT_BE_NULL );
155
+ Assert .notNull (sort , SORT_MUST_NOT_BE_NULL );
150
156
151
157
return executeSorted (createQuery (predicate ).select (path ), sort );
152
158
}
153
159
154
160
@ Override
155
161
public List <T > findAll (OrderSpecifier <?>... orders ) {
156
162
157
- Assert .notNull (orders , "Order specifiers must not be null" );
163
+ Assert .notNull (orders , ORDER_SPECIFIERS_MUST_NOT_BE_NULL );
158
164
159
165
return executeSorted (createQuery (new Predicate [0 ]).select (path ), orders );
160
166
}
161
167
162
168
@ Override
163
169
public Page <T > findAll (Predicate predicate , Pageable pageable ) {
164
170
165
- Assert .notNull (predicate , "Predicate must not be null" );
166
- Assert .notNull (pageable , "Pageable must not be null" );
171
+ Assert .notNull (predicate , PREDICATE_MUST_NOT_BE_NULL );
172
+ Assert .notNull (pageable , PAGEABLE_MUST_NOT_BE_NULL );
167
173
168
174
final JPQLQuery <?> countQuery = createCountQuery (predicate );
169
175
JPQLQuery <T > query = querydsl .applyPagination (pageable , createQuery (predicate ).select (path ));
@@ -175,8 +181,8 @@ public Page<T> findAll(Predicate predicate, Pageable pageable) {
175
181
@ Override
176
182
public <S extends T , R > R findBy (Predicate predicate , Function <FetchableFluentQuery <S >, R > queryFunction ) {
177
183
178
- Assert .notNull (predicate , "Predicate must not be null" );
179
- Assert .notNull (queryFunction , "Query function must not be null" );
184
+ Assert .notNull (predicate , PREDICATE_MUST_NOT_BE_NULL );
185
+ Assert .notNull (queryFunction , QUERY_FUNCTION_MUST_NOT_BE_NULL );
180
186
181
187
Function <Sort , AbstractJPAQuery <?, ?>> finder = sort -> {
182
188
AbstractJPAQuery <?, ?> select = (AbstractJPAQuery <?, ?>) createQuery (predicate ).select (path );
@@ -260,7 +266,7 @@ public boolean exists(Predicate predicate) {
260
266
*/
261
267
protected AbstractJPAQuery <?, ?> createQuery (Predicate ... predicate ) {
262
268
263
- Assert .notNull (predicate , "Predicate must not be null" );
269
+ Assert .notNull (predicate , PREDICATE_MUST_NOT_BE_NULL );
264
270
265
271
AbstractJPAQuery <?, ?> query = doCreateQuery (getQueryHints ().withFetchGraphs (entityManager ), predicate );
266
272
CrudMethodMetadata metadata = getRepositoryMethodMetadata ();
0 commit comments