private void generateNotStringsVisit(TrieNode node, String charRule, StringBuilder content) {
        var rejects = new ArrayList<String>();
        var first = true;

        for (var c : node.children.keySet().stream().sorted().toList()) {

            var child = node.children.get(c);
            rejects.add(c.toString());

            if (!first) {
                content.append(" | ");
            }

            content.append("[").append(c).append("]");

            if (!child.children.isEmpty()) {
                content.append(" (");
                generateNotStringsVisit(child, charRule, content);
                content.append(")");
            } else if (child.isEndOfString) {
                content.append(" ").append(charRule).append("+");
            }

            first = false;
        }

        if (!node.children.isEmpty()) {
            if (!first) {
                content.append(" | ");
            }

            content
                    .append("[^\"")
                    .append(String.join("", rejects))
                    .append("] ")
                    .append(charRule)
                    .append("*");
        }
    }
Converts a JSON Schema to a GBNF grammar to be used for structured output with llama.cpp.
It is a port of Python implementation from llama.cpp repository.
Current implementation doesn't support regex patterns, resolving $ref or fetching schemas from URLs.
The plan is to replace this with C++ implementation from llama.cpp though JNI.
model-integration/src/main/java/ai/vespa/llm/clients/JsonSchemaToGrammar.java