in johnzon-jsonschema/src/main/java/org/apache/johnzon/jsonschema/generator/PojoGenerator.java [395:486]
protected String onObjectAttribute(final String javaName, final JsonObject schema) {
final JsonValue additionalProperties = schema.get("additionalProperties");
final JsonValue properties = schema.get("properties");
final boolean hasProperties = properties != null && properties.getValueType() == JsonValue.ValueType.OBJECT;
if (!hasProperties &&
additionalProperties != null &&
additionalProperties.getValueType() == JsonValue.ValueType.OBJECT) {
final JsonObject propSchema = additionalProperties.asJsonObject();
final JsonValue propTypeValue = propSchema.get("type");
if (propTypeValue != null && propTypeValue.getValueType() == JsonValue.ValueType.STRING) {
String propType = JsonString.class.cast(propTypeValue).getString();
final JsonValue formatValue = schema.get("date-time");
if (formatValue != null && formatValue.getValueType() == JsonValue.ValueType.STRING) {
propType = JsonString.class.cast(formatValue).getString();
}
switch (propType) {
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":
imports.add(Map.class.getName());
return "Map<String, String>";
case "boolean":
imports.add(Map.class.getName());
return "Map<String, Boolean>";
case "number":
case "double":
imports.add(Map.class.getName());
return "Map<String, Double>";
case "int":
case "int32":
case "integer":
imports.add(Map.class.getName());
return "Map<String, Integer>";
case "int64":
case "long":
imports.add(Map.class.getName());
return "Map<String, Long>";
case "float":
imports.add(Map.class.getName());
return "Map<String, Float>";
case "date":
imports.add(Map.class.getName());
imports.add(LocalDate.class.getName());
return "Map<String, LocalDate>";
case "dateTime":
case "date-time":
imports.add(Map.class.getName());
imports.add(OffsetDateTime.class.getName());
return "Map<String, OffsetDateTime>";
case "duration":
imports.add(Map.class.getName());
imports.add(Duration.class.getName());
return "Map<String, Duration>";
case "time":
imports.add(Map.class.getName());
imports.add(LocalTime.class.getName());
return "Map<String, LocalTime>";
default:
// todo: case array, object
}
}
} else if (hasProperties) {
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;
}
imports.add(JsonObject.class.getName());
return JsonObject.class.getSimpleName();
}