Reputation: 145
I'm trying to access a data class with embedded enum from java
data class MyStatus( val status: Status ) {
enum class Status{ OK, ERROR }
}
Seems that Status is invisible if I use it from Java. Is there any way to achieve this ?
Upvotes: 1
Views: 1658
Reputation: 81879
No there's no problem, just do
MyStatus s = new MyStatus(MyStatus.Status.ERROR);
Here's what the compiler generates for your Enum
:
public static enum Status {
OK,
ERROR;
}
It's nested in MyStatus
.
Upvotes: 2