Class ListMethodImplementor
java.lang.Object
io.quarkus.rest.data.panache.deployment.methods.StandardMethodImplementor
io.quarkus.rest.data.panache.deployment.methods.ListMethodImplementor
- All Implemented Interfaces:
MethodImplementor
- Direct Known Subclasses:
ListHalMethodImplementor
-
Field Summary
Fields inherited from class io.quarkus.rest.data.panache.deployment.methods.StandardMethodImplementor
responseImplementorFields inherited from interface io.quarkus.rest.data.panache.deployment.methods.MethodImplementor
APPLICATION_HAL_JSON, APPLICATION_JSON -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddProducesJsonAnnotation(io.quarkus.gizmo.AnnotatedElement element, ResourceProperties properties) protected Stringprotected StringGet a name of a method which this controller uses to access data.protected voidimplementInternal(io.quarkus.gizmo.ClassCreator classCreator, ResourceMetadata resourceMetadata, ResourceProperties resourceProperties, io.quarkus.gizmo.FieldDescriptor resourceField) Generate JAX-RS GET method.io.quarkus.gizmo.ResultHandlelist(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) protected voidreturnValue(io.quarkus.gizmo.BytecodeCreator creator, ResourceMetadata resourceMetadata, ResourceProperties resourceProperties, io.quarkus.gizmo.ResultHandle value) protected voidreturnValueWithLinks(io.quarkus.gizmo.BytecodeCreator creator, ResourceMetadata resourceMetadata, ResourceProperties resourceProperties, io.quarkus.gizmo.ResultHandle value, io.quarkus.gizmo.ResultHandle links) Methods inherited from class io.quarkus.rest.data.panache.deployment.methods.StandardMethodImplementor
addConsumesAnnotation, addContextAnnotation, addDefaultValueAnnotation, addDeleteAnnotation, addGetAnnotation, addLinksAnnotation, addMethodAnnotations, addOpenApiResponseAnnotation, addOpenApiResponseAnnotation, addOpenApiResponseAnnotation, addOpenApiResponseAnnotation, addPathAnnotation, addPathParamAnnotation, addPostAnnotation, addProducesAnnotation, addPutAnnotation, addQueryParamAnnotation, addSecurityAnnotations, addSortQueryParamValidatorAnnotation, appendToPath, hasSecurityCapability, hasValidatorCapability, implement, implementTryBlock, isNotReactivePanache, isResteasyClassic
-
Constructor Details
-
ListMethodImplementor
public ListMethodImplementor(io.quarkus.deployment.Capabilities capabilities)
-
-
Method Details
-
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 exposesRestDataResource.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 nullPageinstance is used.
The RESTEasy Reactive version exposes@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") 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); } }ReactiveRestDataResource.list(Page, Sort)and the generated code looks more or less like this:@GET @Path("") @Produces({"application/json"}) @LinkResource( rel = "list", entityClassName = "com.example.Entity" ) public Uni<Response> list(@QueryParam("page") @DefaultValue("0") int pageIndex, @QueryParam("size") @DefaultValue("20") int pageSize, @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:
implementInternalin classStandardMethodImplementor
-
getResourceMethodName
Description copied from class:StandardMethodImplementorGet a name of a method which this controller uses to access data.- Specified by:
getResourceMethodNamein classStandardMethodImplementor
-
getMethodName
-
addProducesJsonAnnotation
protected void addProducesJsonAnnotation(io.quarkus.gizmo.AnnotatedElement element, ResourceProperties properties) - Overrides:
addProducesJsonAnnotationin classStandardMethodImplementor
-
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)
-