Package com.bazaarvoice.commons.data.model.json.schema.types

Examples of com.bazaarvoice.commons.data.model.json.schema.types.JSONSchemaStringType


                        putOpt("exclusiveMaximum", numberType.getMaximumExclusive()).
                        putOpt("divisibleBy", numberType.getDivisibleBy());
            }

            if (type instanceof JSONSchemaStringType) {
                JSONSchemaStringType stringType = (JSONSchemaStringType) type;
                jsonObject.putOpt("minLength", stringType.getMinimumLength()).
                        putOpt("maxLength", stringType.getMaximumLength()).
                        putOpt("pattern", stringType.getPattern()).
                        putOpt("format", convertSchemaTextFormatToJSONValue(stringType.getFormat(), stringType.getCustomFormat()));

            } else if (type instanceof JSONSchemaObjectType) {
                JSONSchemaObjectType objectType = (JSONSchemaObjectType) type;

                jsonObject.put("properties", _namedPropertyMarshaller.toMappedJSONObject(objectType.getNamedProperties()));
View Full Code Here


                    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()));
View Full Code Here

    public static JSONSchema newStrictObjectArraySchema(JSONSchemaProperty... properties) {
        return newArraySchema(newStrictObjectSchema(properties));
    }

    public static JSONSchema newStringSchema() {
        return newSimpleSchema(new JSONSchemaStringType());
    }
View Full Code Here

    public static JSONSchema newStringSchema() {
        return newSimpleSchema(new JSONSchemaStringType());
    }

    public static JSONSchema newStringFormatSchema(JSONSchemaTextFormat format) {
        return newSimpleSchema(new JSONSchemaStringType().format(format));
    }
View Full Code Here

                        putOpt("exclusiveMaximum", numberType.getMaximumExclusive()).
                        putOpt("divisibleBy", numberType.getDivisibleBy());
            }

            if (type instanceof JSONSchemaStringType) {
                JSONSchemaStringType stringType = (JSONSchemaStringType) type;
                jsonObject.putOpt("minLength", stringType.getMinimumLength()).
                        putOpt("maxLength", stringType.getMaximumLength()).
                        putOpt("pattern", stringType.getPattern()).
                        putOpt("format", convertSchemaTextFormatToJSONValue(stringType.getFormat(), stringType.getCustomFormat()));

            } else if (type instanceof JSONSchemaObjectType) {
                JSONSchemaObjectType objectType = (JSONSchemaObjectType) type;

                jsonObject.put("properties", _namedPropertyMarshaller.toMappedJSONObject(objectType.getNamedProperties()));
View Full Code Here

                    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()));
View Full Code Here

TOP

Related Classes of com.bazaarvoice.commons.data.model.json.schema.types.JSONSchemaStringType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.