private static String validateArgument(DataType type, String variable, int ind) {
        if (type instanceof MapDataType mdt) {
            return validateWrapped(mdt.getKeyType(), variable, variable + ".keySet()", ind) +
                   validateWrapped(mdt.getValueType(), variable, variable + ".values()", ind);
        }
        else if (type instanceof CollectionDataType cdt) {
            String elements = cdt instanceof WeightedSetDataType ? variable + ".keySet()" : variable;
            return validateWrapped(cdt.getNestedType(), variable, elements, ind);
        }
        else if (   DataType.STRING.equals(type)
                 || DataType.URI.equals(type)
                 || type instanceof AnnotationReferenceDataType
                 || type instanceof NewDocumentReferenceDataType) {
            return ind(ind) + "if (" + variable + " != null) {\n" +
                   ind(ind+1) + toJavaReference(type) + ".createFieldValue(" + variable + ");\n" +
                   ind(ind) + "}\n";
        }
        else {
            return "";
        }
    }
Exports this set of fields with getters and setters
@param spanTrees If true, include a reference to the list of span trees for the string fields
vespa-documentgen-plugin/src/main/java/com/yahoo/vespa/DocumentGenMojo.java