slightly simplify generated code for pagination using static imports
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
5d611e63b7
commit
82ef400705
|
@ -374,8 +374,8 @@ public abstract class AbstractQueryMethod extends AbstractAnnotatedMethod {
|
||||||
"\t\t\t\t\t\t.collect(toList());\n" +
|
"\t\t\t\t\t\t.collect(toList());\n" +
|
||||||
//SHOULD BE new CursoredPageRecord<>
|
//SHOULD BE new CursoredPageRecord<>
|
||||||
"\t\treturn new CursoredPageRecord(_results.getResultList(), _cursors, _totalResults, pageRequest,\n" +
|
"\t\treturn new CursoredPageRecord(_results.getResultList(), _cursors, _totalResults, pageRequest,\n" +
|
||||||
"\t\t\t\t_results.isLastPage() ? null : PageRequest.afterCursor(_cursors.get(_cursors.size()-1), pageRequest.page()+1, pageRequest.size(), pageRequest.requestTotal()),\n" +
|
"\t\t\t\t_results.isLastPage() ? null : afterCursor(_cursors.get(_cursors.size()-1), pageRequest.page()+1, pageRequest.size(), pageRequest.requestTotal()),\n" +
|
||||||
"\t\t\t\t_results.isFirstPage() ? null : PageRequest.beforeCursor(_cursors.get(0), pageRequest.page()-1, pageRequest.size(), pageRequest.requestTotal()));";
|
"\t\t\t\t_results.isFirstPage() ? null : beforeCursor(_cursors.get(0), pageRequest.page()-1, pageRequest.size(), pageRequest.requestTotal()));";
|
||||||
|
|
||||||
static final String MAKE_KEYED_PAGE
|
static final String MAKE_KEYED_PAGE
|
||||||
= "\tvar _unkeyedPage =\n" +
|
= "\tvar _unkeyedPage =\n" +
|
||||||
|
@ -667,9 +667,11 @@ public abstract class AbstractQueryMethod extends AbstractAnnotatedMethod {
|
||||||
unwrapQuery(declaration, unwrapped);
|
unwrapQuery(declaration, unwrapped);
|
||||||
declaration
|
declaration
|
||||||
.append("\t\t\t.getKeyedResultList(_keyedPage);\n");
|
.append("\t\t\t.getKeyedResultList(_keyedPage);\n");
|
||||||
annotationMetaEntity.importType("jakarta.data.page.PageRequest");
|
annotationMetaEntity.importType(JD_PAGE_REQUEST);
|
||||||
annotationMetaEntity.importType("jakarta.data.page.PageRequest.Cursor");
|
annotationMetaEntity.importType(JD_PAGE_REQUEST + ".Cursor");
|
||||||
annotationMetaEntity.importType("jakarta.data.page.impl.CursoredPageRecord");
|
annotationMetaEntity.importType("jakarta.data.page.impl.CursoredPageRecord");
|
||||||
|
annotationMetaEntity.staticImport(JD_PAGE_REQUEST, "beforeCursor");
|
||||||
|
annotationMetaEntity.staticImport(JD_PAGE_REQUEST, "afterCursor");
|
||||||
String fragment = MAKE_KEYED_SLICE
|
String fragment = MAKE_KEYED_SLICE
|
||||||
.replace("pageRequest",
|
.replace("pageRequest",
|
||||||
parameterName(JD_PAGE_REQUEST, paramTypes, paramNames))
|
parameterName(JD_PAGE_REQUEST, paramTypes, paramNames))
|
||||||
|
|
Loading…
Reference in New Issue