Skip to content

Conversation

SentryMan
Copy link
Collaborator

Adds a new annotation to register/import type handlers for custom types.

I'm not sure about the annotation name.

  • adds new annotation for mapping
  • if the type has no mapping and we know it is not a body (it's annotated by @Header or something) and it also have a constructor that takes a string, a mapping is generated
  • you can import external types
  • you can use static factory methods

you can use it like:

  @MappedParam
  @MappedParam.Import(Simple2.class)
  record Simple(String name) {}

  record Simple2(String name) {}

  @Form
  @Get("/typeForm")
  String typeForm(Simple s, Simple2 type) {
    return type.name();
  }

  @MappedParam(factoryMethod = "build")
  record Static(String name) {
    static Static build(String name) {
      return null;
    }
  }

  @Get("/typeFormParam")
  String typeFormParam(@FormParam String s, @FormParam Static type) {
    return type.name();
  }

  @Get("/typeQuery2")
  String typeMultiQuery(@QueryParam @Default({"FFA", "PROXY"}) Set<Simple> type) {
    return type.toString();
  }

  record Implied(String name) {}

  @Post("/typeQueryImplied")
  String typeQueryImplied(String s, @QueryParam Implied type) {
    return type.name();
  }

resolves #640 and #539

@SentryMan SentryMan requested a review from rbygrave September 25, 2025 03:22
@SentryMan SentryMan self-assigned this Sep 25, 2025
@SentryMan SentryMan added the enhancement New feature or request label Sep 25, 2025
@SentryMan SentryMan enabled auto-merge September 25, 2025 03:22
@SentryMan SentryMan disabled auto-merge September 30, 2025 04:23
@SentryMan SentryMan enabled auto-merge (squash) September 30, 2025 04:23
@SentryMan SentryMan merged commit 6916132 into avaje:master Oct 6, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom path and query parameter type conversion
2 participants