Fixed the Serialization of Subclassed Enumerations

Certain enumerations like TimeUnit rely on subclassing the enclosing enumeration.
This fix makes sure we can correctly deal with these types of enumerations.