private Object getEnum ( Class c , JsonObject jsonObj ) { try { return Enum . valueOf ( c , ( String ) jsonObj . get ( "name" ) ) ; } catch ( Exception e ) { // In case the enum class has it's own 'name' member variable (shadowing the 'name' variable on Enum) return Enum . valueOf ( c , ( String ) jsonObj . get ( "java.lang.Enum.name" ) ) ; } }
Fetch enum value ( may need to try twice due to potential name field shadowing by enum subclasses