I was wondering if it would be possible to make an enum not have properties on a module but have them on another (I am using Gradle but should be the same on Maven). This is an example of what I mean:
“api” module: MyEnum.ELEMENT_1
. In this case, MyEnum.ELEMENT_1 shouldn’t have any property or method. However:
“main” module: MyEnum.ELEMENT_1.getData()
In this module, every property and method can be accessed.
Basically, I would like my “api” module’s MyEnum to look like this:
public enum MyEnum {
ELEMENT_1,
ELEMENT_2
}
while my “main” module’s MyEnum looks something like this but is compatible with the “api” module’s MyEnum:
public enum MyEnum {
ELEMENT_1(...),
ELEMENT_2(...)
private final Data data;
MyEnum(Data data) {
this.data = data;
}
public Data getData() {
return this.data;
}
}
How can I achieve this? “api” would be the exposed part of the library and I don’t want devs having access to the enum’s methods.