add toEnum method for converting object enum to enum value