Skip to content
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

Propose inline java types #5546

Closed
wants to merge 2 commits into from
Closed

Conversation

ajgateno
Copy link
Member

@ajgateno ajgateno commented Jan 7, 2025

This is a proposal for how we could generate inline types in the Java SDK generator, similarly to what we do in TypeScript. For more information see the ticket: https://linear.app/buildwithfern/issue/FER-3805/[intercom-java]-add-support-for-inlined-types

Comment on lines 247 to 264
// Inline enums not available in Java 8
// public enum MyEnum {
// SUNNY("Sunny"),
// CLOUDY("Cloudy"),
// RAINING("Raining"),
// SNOWING("Snowing"),
// ;
//
// private final String value;
//
// MyEnum(String value) {
// this.value = value;
// }
//
// public String toString() {
// return this.value;
// }
// }
Copy link
Member Author

Choose a reason for hiding this comment

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

I've commented this out because the IntelliJ suggestion was saying this isn't available in Java 8 (which is apparently the compile target for our seed projects by default, judging from the fact that I copied the base gradle files for this from the generated java-inline-path-params fixture). Would it be reasonable/easy to require a certain version of java for the generator if the user enables the inline types feature, just to guarantee that they have access to inline enums? If not, I can come up with a workaround. I suppose this hinges on the version of Java that Intercom users are going to use this SDK on.

Copy link
Member

Choose a reason for hiding this comment

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

I think we'll need to support in-lined types for Java 8, so I wonder if we should continue to generate enums as long type names and in-line everything else (like it's already demonstrated here).

This is a good question for @dsinghvi, too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Spoke offline; it looks like Java allows us to declare enums within a top-level class but not within any deeper level of nesting. Our approach is going to be as follows;

  1. One PR that implements support for in-line object types and leaves enums at the top level always
  2. Another PR that implements support for in-line enums only if they're at the first level of nesting, and leaves them un-inlined otherwise.

@ajgateno ajgateno closed this Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants