private static void addExtendedField(String className, Field f, Writer out, int ind) throws IOException {
        out.write(ind(ind)+ "ret.addField(new com.yahoo.document.ExtendedField(\""+f.getName()+"\", " + toJavaReference(f.getDataType()) + ",\n");
        out.write(ind(ind+1) + "new com.yahoo.document.ExtendedField.Extract() {\n");
        out.write(ind(ind+2) + "public Object get(com.yahoo.document.datatypes.StructuredFieldValue doc) {return ((" + className + ")doc)." + getter(f.getName()) + "(); }\n");
        out.write(ind(ind+2) + "public void set(com.yahoo.document.datatypes.StructuredFieldValue doc, Object value) { ((" + className + ")doc)." + setter(f.getName())+"((" + toJavaType(f.getDataType()) + ")value); }\n");
        out.write(ind(ind+1) + "}\n");
        out.write(ind(ind) + "));\n");
    }
\n"+
                ind(ind)+" * Constructs a "+className+" by taking a deep copy of the provided StructuredFieldValue.\n" +
                ind(ind)+"
vespa-documentgen-plugin/src/main/java/com/yahoo/vespa/DocumentGenMojo.java