Refactored some generic functions into TypeUtil class.  Added support for generating writeMap method also so that datamappers can do round-trip.