conjure-java
conjure-java copied to clipboard
[draft] Generate 'sealed interfaces' for Conjure unions (feature flagged)
Before this PR
For hackweek, I'm hoping to enable folks to use Java 17's pattern-matching-switch-expressions (https://openjdk.org/jeps/406) to visit the different possible variants of a Conjure union. My primary goal is to make code more readable, but I think it should come with a performance boost too.
After this PR
==COMMIT_MSG==
A new feature flag (--sealedUnions) allows users to opt-in to generating Java 17 sealed interfaces for their conjure unions.
==COMMIT_MSG==
Other related work is tracked on https://quip/3YEnAt26mmtE.
Outstanding TODOs:
- [ ] don't require conjure-java to build and publish using a java 17 JVM.
- [x] Generate a
throwOnKnownmethod- [ ] do we want to change from a
SafeIllegalArgumentExceptionnow?
- [ ] do we want to change from a
- [x] Generate a way to get the
Knowninterface (maybe just optional initially?) - [x] Name escaping of the 'Known' interface name
- [ ] Testing
- [ ] get
--enable-previewworking in Intellij (https://github.com/palantir/gradle-baseline/pull/2319) so I can write some tests - [ ] support switch expressions in palantir-java-format (maybe goethe 0.8.0 is all I need... pls mavencentral hurry up)
- [ ] exhaustive serialization tests, plus tostring tests, plus equality tests
- [ ] get