Typesafe serializazion of data for Java