@@ -117,8 +117,7 @@ String specificationType() {
117
117
118
118
@ Override
119
119
void createQuery (StringBuilder declaration ) {
120
- final boolean specification = isUsingSpecification ();
121
- if ( specification ) {
120
+ if ( isUsingSpecification () ) {
122
121
if ( isReactive () ) {
123
122
declaration
124
123
.append (localSessionName ())
@@ -226,9 +225,8 @@ else if ( BOOLEAN.equals(returnTypeName) ) {
226
225
@ Override
227
226
void setParameters (StringBuilder declaration , List <String > paramTypes , String indent ) {
228
227
for ( int i = 0 ; i < paramNames .size (); i ++ ) {
229
- final String paramName = paramNames .get (i );
230
- final String paramType = paramTypes .get (i );
231
- if ( !isSpecialParam (paramType ) ) {
228
+ if ( !isSpecialParam ( paramTypes .get (i ) ) ) {
229
+ final String paramName = paramNames .get (i );
232
230
final int ordinal = i +1 ;
233
231
if ( queryString .contains (":" + paramName ) ) {
234
232
declaration .append (indent );
@@ -291,8 +289,7 @@ private static void setNamedParameter(StringBuilder declaration, String paramNam
291
289
292
290
private void comment (StringBuilder declaration ) {
293
291
declaration
294
- .append ("\n /**" );
295
- declaration
292
+ .append ("\n /**" )
296
293
.append ("\n * Execute the query {@value #" )
297
294
.append (getConstantName ())
298
295
.append ("}." )
@@ -303,7 +300,8 @@ private void comment(StringBuilder declaration) {
303
300
}
304
301
305
302
private void modifiers (StringBuilder declaration , List <String > paramTypes ) {
306
- boolean hasVarargs = paramTypes .stream ().anyMatch (ptype -> ptype .endsWith ("..." ));
303
+ final boolean hasVarargs =
304
+ paramTypes .stream ().anyMatch (ptype -> ptype .endsWith ("..." ));
307
305
if ( hasVarargs ) {
308
306
declaration
309
307
.append ("@SafeVarargs\n " );
@@ -326,15 +324,16 @@ void nullChecks(StringBuilder declaration, List<String> paramTypes) {
326
324
for ( int i = 0 ; i <paramNames .size (); i ++ ) {
327
325
final String paramType = paramTypes .get ( i );
328
326
// we don't do null checks on query parameters
329
- if ( isSessionParameter ( paramType ) || isSpecialParam ( paramType ) ) {
327
+ if ( isSpecialParam (paramType ) ) {
330
328
nullCheck ( declaration , paramNames .get (i ) );
331
329
}
332
330
}
333
331
}
334
332
335
333
@ Override
336
334
public String getAttributeNameDeclarationString () {
337
- StringBuilder declaration = new StringBuilder ( queryString .length () + 200 );
335
+ final StringBuilder declaration =
336
+ new StringBuilder ( queryString .length () + 200 );
338
337
declaration
339
338
.append ("\n /**\n * @see " )
340
339
.append ("#" );
@@ -346,42 +345,33 @@ public String getAttributeNameDeclarationString() {
346
345
.append ( " = \" " );
347
346
for ( int i = 0 ; i < queryString .length (); i ++ ) {
348
347
final char c = queryString .charAt ( i );
349
- switch ( c ) {
350
- case '\r' :
351
- declaration .append ( "\\ r" );
352
- break ;
353
- case '\n' :
354
- declaration .append ( "\\ n" );
355
- break ;
356
- case '\\' :
357
- declaration .append ( "\\ \\ " );
358
- break ;
359
- case '"' :
360
- declaration .append ( "\\ \" " );
361
- break ;
362
- default :
363
- declaration .append ( c );
364
- break ;
365
- }
348
+ declaration .append (switch ( c ) {
349
+ case '\r' -> "\\ r" ;
350
+ case '\n' -> "\\ n" ;
351
+ case '\\' -> "\\ \\ " ;
352
+ case '"' -> "\\ \" " ;
353
+ default -> c ;
354
+ });
366
355
}
367
- return declaration .append ("\" ;" ).toString ();
356
+ return declaration
357
+ .append ("\" ;" )
358
+ .toString ();
368
359
}
369
360
370
361
private String getConstantName () {
371
362
final String stem = getUpperUnderscoreCaseFromLowerCamelCase (methodName );
372
- if ( paramTypes .isEmpty () ) {
373
- return stem ;
374
- }
375
- else {
376
- return stem + "_"
377
- + paramTypes .stream ()
378
- .filter (type -> !isSpecialParam (type ))
379
- .map (type -> type .indexOf ('<' )>0 ? type .substring (0 , type .indexOf ('<' )) : type )
380
- .map (StringHelper ::unqualify )
381
- .map (type -> type .replace ("[]" , "Array" ))
382
- .reduce ((x ,y ) -> x + '_' + y )
383
- .orElse ("" );
384
- }
363
+ return paramTypes .isEmpty ()
364
+ || paramTypes .stream ().allMatch (AbstractQueryMethod ::isSpecialParam )
365
+ ? stem
366
+ : stem + "_" + paramTypes .stream ()
367
+ .filter ( type -> !isSpecialParam (type ) )
368
+ .map ( type -> type .indexOf ('<' ) > 0
369
+ ? type .substring (0 , type .indexOf ('<' ))
370
+ : type )
371
+ .map ( StringHelper ::unqualify )
372
+ .map ( type -> type .replace ("[]" , "Array" ) )
373
+ .reduce ( (x , y ) -> x + '_' + y )
374
+ .orElseThrow ();
385
375
}
386
376
387
377
public String getTypeDeclaration () {
0 commit comments