We will illustrate both how to deal with public static inner classes and enumerations at once.
The rules to deal with them in Golo are as follows.
$
sign. Hence, Thread.State
in Java is written Thread$State
in Golo.
Let us consider the following example:
module sample.EnumsThreadState import java.lang.Thread$State function main = |args| { # Call the enum entry like a function let new = Thread$State.NEW() println("name=" + new: name() + ", ordinal=" + new: ordinal()) # Walk through all enum entries foreach element in Thread$State.values() { println("name=" + element: name() + ", ordinal=" + element: ordinal()) } }
Running it yields the following console output:
$ golo golo --files samples/enums-thread-state.golo name=NEW, ordinal=0 name=NEW, ordinal=0 name=RUNNABLE, ordinal=1 name=BLOCKED, ordinal=2 name=WAITING, ordinal=3 name=TIMED_WAITING, ordinal=4 name=TERMINATED, ordinal=5 $