public Optional<String> maybeVisit(JsonNode schema, String baseName, String name) {
            if (schema.has("enum")) {
                var content = new StringBuilder();
                content.append("(");

                for (var i = 0; i < schema.get("enum").size(); i++) {
                    if (i > 0) {
                        content.append(" | ");
                    }

                    content.append(generateConstant(schema.get("enum").get(i)));
                }

                content.append(") space");
                var rule = addRule(name, content.toString());
                return Optional.of(rule);
            }

            return Optional.empty();
        }
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