[core] Templatizes class Generator.