Class ListMethodImplementor

    • Constructor Detail

      • ListMethodImplementor

        public ListMethodImplementor​(boolean isResteasyClassic)
    • Method Detail

      • implementInternal

        protected void implementInternal​(io.quarkus.gizmo.ClassCreator classCreator,
                                         ResourceMetadata resourceMetadata,
                                         ResourceProperties resourceProperties,
                                         io.quarkus.gizmo.FieldDescriptor resourceField)
        Generate JAX-RS GET method that exposes RestDataResource.list(Page, Sort). Generated pseudo-code with enabled pagination is shown below. If pagination is disabled pageIndex and pageSize query parameters are skipped and null Page instance is used.
         
             @GET
             @Path("")
             @Produces({"application/json"})
             @LinkResource(
                 rel = "list",
                 entityClassName = "com.example.Entity"
             )
             public Response list(@QueryParam("page") @DefaultValue("0") int pageIndex,
                     @QueryParam("size") @DefaultValue("20") int pageSize,
                     @QueryParam("sort") String sortQuery) {
                 Page page = Page.of(pageIndex, pageSize);
                 Sort sort = ...; // Build a sort instance by parsing a query param
                 try {
                     List<Entity> entities = resource.getAll(page, sort);
                     // Get the page count, and build first, last, next, previous page instances
                     Response.ResponseBuilder responseBuilder = Response.status(200);
                     responseBuilder.entity(entities);
                     // Add headers with first, last, next and previous page URIs if they exist
                     return responseBuilder.build();
                 } catch (Throwable t) {
                     throw new RestDataPanacheException(t);
                 }
             }
         
         
        Specified by:
        implementInternal in class StandardMethodImplementor