How do I access inner enum classes in another class? For example:
public class Foo {
enum Bar {
ONE, TWO, FOUR, EIGHT, SIXTEEN
}
// ...methods here
}
The class I am trying to access Foo.Bar
in:
public class FooTest {
private Foo f;
@Before
public void setUp() throws Exception {
f = new Foo();
}
public void testCase1() {
assertEquals(Bar.ONE, f.climbUp());
}
}
I've tried Foo.Bar.ONE
, Bar.ONE
as well as making a new variable using Foo.class.getDeclaredField("Bar")
but none of these seem to be working. getDeclaredClasses()
seems to get me $Bar
but I can't access anything from there.
Update: I'm not allowed to modify the class Foo