Annotation Interface ApiMapper


@Retention(RUNTIME) @Target({TYPE,METHOD}) public @interface ApiMapper
Specifies the MapStruct (or any bean) mapper class and optional method name to use for converting query results before returning them from a dynamic ApiFindController method.

When the interceptor has retrieved the list of entities from the JpaService, it looks for this annotation to determine whether to apply a transformation. If method() is blank, the framework uses the first compatible single-argument method found on the mapper class.

Example


 @ApiFindController
 public interface ProductController {

     @GetMapping("/products")
     @ApiFind(entity = Product.class, id = Long.class)
     @ApiMapper(value = ProductMapper.class, method = "toDto")
     List<ProductDto> search(@RequestBody ProductFilter filter);
 }
 
Author:
Francesco Baldi
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The mapper class whose method will be called on each result entity.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The name of the mapping method to invoke on the mapper.
  • Element Details

    • value

      Class<?> value
      The mapper class whose method will be called on each result entity. The class must be a Spring-managed bean (e.g., a MapStruct mapper annotated with @Mapper(componentModel = "spring")).
      Returns:
      the mapper class; must not be null
    • method

      String method
      The name of the mapping method to invoke on the mapper. If left blank (default), the framework resolves the method automatically by matching the entity type to the method's parameter type.
      Returns:
      the mapping method name, or "" for auto-resolution
      Default:
      ""