public Number apply(@Nullable Object input) {
return input instanceof Number ? (Number) input : null;
}
}), Predicates.notNull()));
} else if (type instanceof JSONSchemaStringType) {
JSONSchemaStringType stringType = (JSONSchemaStringType) type;
if (defaultValue instanceof String) {
stringType.setDefaultValue((String) defaultValue);
}
Number minimumLength = (Number) jsonObject.opt("minLength");
if (minimumLength != null) {
stringType.setMinimumLength(minimumLength.intValue());
}
Number maximumLength = (Number) jsonObject.opt("maxLength");
if (maximumLength != null) {
stringType.setMaximumLength(maximumLength.intValue());
}
stringType.setPattern(jsonObject.optString("pattern", null));
String format = jsonObject.optString("format");
stringType.setFormat(convertSchemaTextFormatFromJSONValue(format));
if (stringType.getFormat() == JSONSchemaTextFormat.CUSTOM) {
stringType.setCustomFormat(format);
}
stringType.setEnumValues(Collections2.filter(Lists.transform(enums, new Function<Object, String>() {
@Override
public String apply(@Nullable Object input) {
return input instanceof String ? (String) input : null;
}
}), Predicates.notNull()));