Skip to content

Lengthen Inner Type Short Names #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 31, 2023
Merged

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
@@ -202,12 +202,36 @@ public Set<String> importTypes() {
Set<String> set = new LinkedHashSet<>();
for (String type : allTypes) {
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