Migrate the field declarations to java

Also add type parameters to represent embedded records and typesafe ids.