Class ListMethodImplementor

    • Constructor Detail

      • ListMethodImplementor

        public ListMethodImplementor​(io.quarkus.deployment.Capabilities capabilities)
    • 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. The RESTEasy Classic version exposes RestDataResource.list(Page, Sort) and the generated pseudocode 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,
                     &#64;QueryParam("sort") List<String> sortQuery) {
                 Page page = Page.of(pageIndex, pageSize);
                 Sort sort = ...; // Build a sort instance from String entries of sortQuery
                 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);
                 }
             }
         
         
        The RESTEasy Reactive version exposes ReactiveRestDataResource.list(Page, Sort) and the generated code looks more or less like this:
         
             &#64;GET
             &#64;Path("")
             &#64;Produces({"application/json"})
             &#64;LinkResource(
                 rel = "list",
                 entityClassName = "com.example.Entity"
             )
             public Uni<Response> list(&#64;QueryParam("page") &#64;DefaultValue("0") int pageIndex,
                     &#64;QueryParam("size") &#64;DefaultValue("20") int pageSize,
                     &#64;QueryParam("sort") List<String> sortQuery) {
                 Page page = Page.of(pageIndex, pageSize);
                 Sort sort = ...; // Build a sort instance from String entries of sortQuery
                 try {
                     return resource.getAll(page, sort).map(entities -> {
                        // 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
      • getMethodName

        protected String getMethodName()
      • returnValueWithLinks

        protected void returnValueWithLinks​(io.quarkus.gizmo.BytecodeCreator creator,
                                            ResourceMetadata resourceMetadata,
                                            ResourceProperties resourceProperties,
                                            io.quarkus.gizmo.ResultHandle value,
                                            io.quarkus.gizmo.ResultHandle links)
      • returnValue

        protected void returnValue​(io.quarkus.gizmo.BytecodeCreator creator,
                                   ResourceMetadata resourceMetadata,
                                   ResourceProperties resourceProperties,
                                   io.quarkus.gizmo.ResultHandle value)
      • list

        public io.quarkus.gizmo.ResultHandle list​(io.quarkus.gizmo.BytecodeCreator creator,
                                                  ResourceMetadata resourceMetadata,
                                                  io.quarkus.gizmo.ResultHandle resource,
                                                  io.quarkus.gizmo.ResultHandle page,
                                                  io.quarkus.gizmo.ResultHandle sort,
                                                  io.quarkus.gizmo.ResultHandle namedQuery,
                                                  Map<String,​io.quarkus.gizmo.ResultHandle> fieldValues)