Generified asFunction0
Added helper methods to output to Java classes.