private static String toJavaReference(DataType dt) {
        if (DataType.NONE.equals(dt)) return "com.yahoo.document.DataType.NONE";
        if (DataType.INT.equals(dt)) return "com.yahoo.document.DataType.INT";
        if (DataType.FLOAT.equals(dt)) return "com.yahoo.document.DataType.FLOAT";
        if (DataType.STRING.equals(dt)) return "com.yahoo.document.DataType.STRING";
        if (DataType.RAW.equals(dt)) return "com.yahoo.document.DataType.RAW";
        if (DataType.LONG.equals(dt)) return "com.yahoo.document.DataType.LONG";
        if (DataType.DOUBLE.equals(dt)) return "com.yahoo.document.DataType.DOUBLE";
        if (DataType.DOCUMENT.equals(dt)) return "com.yahoo.document.DataType.DOCUMENT";
        if (DataType.URI.equals(dt)) return "com.yahoo.document.DataType.URI";
        if (DataType.BYTE.equals(dt)) return "com.yahoo.document.DataType.BYTE";
        if (DataType.BOOL.equals(dt)) return "com.yahoo.document.DataType.BOOL";
        if (DataType.TAG.equals(dt)) return "com.yahoo.document.DataType.TAG";
        if (dt instanceof StructDataType) return  className(dt.getName()) +".type";
        if (dt instanceof WeightedSetDataType wdt) return "new com.yahoo.document.WeightedSetDataType("+toJavaReference(wdt.getNestedType())+", "+
            wdt.createIfNonExistent()+", "+ wdt.removeIfZero()+","+dt.getId()+")";
        if (dt instanceof ArrayDataType adt) return "new com.yahoo.document.ArrayDataType("+toJavaReference(adt.getNestedType())+")";
        if (dt instanceof MapDataType mdt) return "new com.yahoo.document.MapDataType("+toJavaReference(mdt.getKeyType())+", "+
            toJavaReference(mdt.getValueType())+", "+dt.getId()+")";
        // For annotation references and generated types, the references are to the actual objects of the correct types, so most likely this is never needed,
        // but there might be scenarios where we want to look up the AnnotationType in the AnnotationTypeRegistry here instead.
        if (dt instanceof AnnotationReferenceDataType adt) return "new com.yahoo.document.annotation.AnnotationReferenceDataType(new com.yahoo.document.annotation.AnnotationType(\""+adt.getAnnotationType().getName()+"\"))";
        if (dt instanceof NewDocumentReferenceDataType nrdt) {
            // All concrete document types have a public `type` constant with their DocumentType.
            return String.format("new com.yahoo.document.ReferenceDataType(%s.type, %d)",
                    className(nrdt.getTargetType().getName()), dt.getId());
        }
        if (dt instanceof TensorDataType tdt) {
            return String.format("new com.yahoo.document.TensorDataType(com.yahoo.tensor.TensorType.fromSpec(\"%s\"))",
                    tdt.getTensorType().toString());
        }
        return "com.yahoo.document.DataType.RAW";
    }
Returns spaces corresponding to 1 level of indentation
vespa-documentgen-plugin/src/main/java/com/yahoo/vespa/DocumentGenMojo.java