Importing an inner class

Is there a way to import inner classes? I am using the import

from import RecordAndContinue

and I would also like to use

from import RecordAndContinue$Event

but this is not valid python because of the dollar sign. The reason I need the inner class is because of Java generics and type erasure. RecordAndContinue and RecordAndContinue.Event are generified by the EventDetector type. If eventHandler is the instance of RecordAndContinue, when I do

events = eventHandler.getEvents()
event = events.get(0)

the first is a java.util.List and the second is a java.lang.Object. The second should be castable to a RecordAndContinue$Event using the .cast_ method. But I can’t figure out how to import that class, and without that import I have no way of accessing the event data.

Let me check. I think it is doable.


The inner class can be accessed via the RecordAndContinue class, i do not see a way to access it directly via the import statement

from import RecordAndContinue

and then the inner class is at:



I was sure I had tried that! It works, thank you.

A good example of something that should be in the documentation :slight_smile: