Problems problems,
CompositeValidator validators ) {
Object value = parent.get("type");
if (value instanceof String) {
// Simple type ...
Type type = JsonSchema.Type.byName((String)value);
if (type == Type.ANY || type == Type.UNKNOWN) return;
validators.add(new TypeValidator(type));
} else if (value instanceof List<?>) {
// Union type ...
List<Validator> unionValidators = new ArrayList<Validator>();
List<?> types = (List<?>)value;
for (Object obj : types) {
Validator validator = null;
if (obj instanceof Document) {
// It's either a schema or a reference to a schema ...
Document schemaOrRef = (Document)obj;
validator = create(schemaOrRef, parentPath.with("type"));
} else if (obj instanceof String) {
Type type = JsonSchema.Type.byName((String)obj);
if (type == Type.ANY || type == Type.UNKNOWN) continue;
validator = new TypeValidator(type);
}
if (validator != null) unionValidators.add(validator);
}