JavaPoet: Creating two enums in the same file

139 Views Asked by At

In Java you can create a single file and it may contain more than one enum\class, for example something like this:

Filename: Recorder.java

public enum Recorder {
  RECORDER_A, RECORDER_B;
};

enum Feature {
  FEATURE_A, FEATURE_B;
};

I'm able to create the "Recorder" enum using JavaPoet, but I can't figure out how to create the 2nd one... notice - they are not nested!

Thank you for any input :-)

1

There are 1 best solutions below

0
On

This is not possible in JavaPoet because it has caused certain problems with certain build tools. Work around by creating separate files for each top-level type.