Typesafe serialization of data for Java