protected String onItemSchema()

in johnzon-jsonschema/src/main/java/org/apache/johnzon/jsonschema/generator/PojoGenerator.java [492:581]


    protected String onItemSchema(final String javaName, final JsonObject schema) {
        final JsonValue ref = schema.get("$ref");
        if (ref != null && ref.getValueType() == JsonValue.ValueType.STRING) {
            final String name = onRef(new Ref(
                    JsonString.class.cast(ref).getString(), configuration.getClassName(),
                    imports, attributes, nested));
            if (name != null) {
                return name;
            }
        }

        final JsonValue propTypeValue = schema.get("type");
        if (propTypeValue != null && propTypeValue.getValueType() == JsonValue.ValueType.STRING) {
            String type = JsonString.class.cast(propTypeValue).getString();
            final JsonValue formatValue = schema.get("date-time");
            if (formatValue != null && formatValue.getValueType() == JsonValue.ValueType.STRING) {
                type = JsonString.class.cast(formatValue).getString();
            }
            switch (type) {
                case "array":
                    throw new IllegalStateException("Array of array unsupported");
                case "object":
                    final String className = configuration.getClassName() + Character.toUpperCase(javaName.charAt(0)) + javaName.substring(1);
                    nested.putAll(newSubPojoGenerator(new PojoConfiguration()
                            .setPackageName(configuration.getPackageName())
                            .setClassName(className)
                            .setAddJsonbProperty(configuration.isAddJsonbProperty())
                            .setAddAllArgsConstructor(configuration.isAddAllArgsConstructor())
                            .setOnRef(configuration.getOnRef()), schema)
                            .visitSchema(schema)
                            .generate());
                    return className;
                case "null":
                    imports.add(JsonValue.class.getName());
                    return JsonValue.class.getSimpleName();
                case "boolean":
                    return "Boolean";
                case "uuid":
                case "hostname":
                case "idn-hostname":
                case "email":
                case "idn-email":
                case "ipv4":
                case "ipv6":
                case "uri":
                case "uri-reference":
                case "iri":
                case "iri-reference":
                case "uri-template":
                case "json-pointer":
                case "relative-json-pointer":
                case "regex":
                case "string":
                case "binary":
                case "password":
                    return "String";
                case "number":
                case "double":
                    return "Double";
                case "int":
                case "int32":
                case "integer":
                    return "Integer";
                case "int64":
                case "long":
                    return "Long";
                case "float":
                    return "Float";
                case "date":
                    imports.add(LocalDate.class.getName());
                    return LocalDate.class.getSimpleName();
                case "dateTime":
                    imports.add(OffsetDateTime.class.getName());
                    return OffsetDateTime.class.getSimpleName();
                case "duration":
                    imports.add(Duration.class.getName());
                    return Duration.class.getSimpleName();
                case "time":
                    imports.add(LocalTime.class.getName());
                    return LocalTime.class.getSimpleName();
                case "byte":
                    return "byte[]";
                default:
                    throw new IllegalArgumentException("Unsupported type: " + type);
            }
        }

        imports.add(JsonValue.class.getName());
        return JsonValue.class.getSimpleName();
    }