Skip to content

Conversation

@SentryMan
Copy link
Collaborator

@SentryMan SentryMan commented Jan 28, 2023

Change JsonB Generation to use expanded short names for inner types. Fixes cases where inner types have conflicting short names.
Now can have a controller like this.

  @Post("/outer1/state")
  List<Outer1.State> testInnerClass(Outer1.State state) {

    return List.of(state);
  }

  @Get("/outer2/state")
  Outer2.State testInnerClass2() {

    return new Outer2.State();
  }

The generated route will now have the JSON type adapters look like this:

  private final JsonType<Outer1.State> outer1$StateJsonType;
  private final JsonType<Outer2.State> outer2$StateJsonType;

Related to avaje/avaje-jsonb#55

@SentryMan SentryMan changed the title Fix Inner Type short names Lengthen Inner Type Short Names Jan 28, 2023
@rbygrave rbygrave added this to the 1.24 milestone Jan 30, 2023
if (!type.startsWith("java.lang.") && type.indexOf('.') > -1) {
set.add(type.replace("[]", ""));
if (type.startsWith("java")) set.add(type.replace("[]", ""));
else set.add(innerTypesImport(type).replace("[]", ""));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self - add blocks

@rbygrave rbygrave merged commit 5b8566e into avaje:master Jan 31, 2023
@SentryMan SentryMan deleted the innerConflict branch January 31, 2023 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants