JayBee
JayBee

Reputation: 145

Kotlin: Access nested enum class from java

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

Answers (1)

s1m0nw1
s1m0nw1

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

Related Questions