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

Examples of com.bazaarvoice.commons.data.model.json.GenericJSONArrayList


        jsonSchema.setTitle(jsonObject.optString("title", null));
        jsonSchema.setDescription(jsonObject.optString("description", null));

        Object typeValue = jsonObject.opt("type");
        if (typeValue instanceof JSONArray) {
            jsonSchema.setTypes(convertSchemaTypesFromJSONValues(new GenericJSONArrayList((JSONArray) typeValue)));
        } else if (typeValue instanceof Collection) {
            //noinspection unchecked
            jsonSchema.setTypes(convertSchemaTypesFromJSONValues((Collection) typeValue));
        } else if (typeValue != null) {
            jsonSchema.setTypes(convertSchemaTypesFromJSONValues(Collections.singleton(typeValue)));
        }

        for (final JSONSchemaType<?> type : jsonSchema.getTypes()) {
            Object defaultValue = jsonObject.opt("default");
            Number minimum = (Number) jsonObject.opt("minimum");
            Boolean minimumExclusive = (Boolean) jsonObject.opt("exclusiveMinimum");
            Number maximum = (Number) jsonObject.opt("maximum");
            Boolean maximumExclusive = (Boolean) jsonObject.opt("exclusiveMaximum");
            Number divisibleBy = (Number) jsonObject.opt("divisibleBy");

            List<Object> enums = new GenericJSONArrayList(jsonObject.optJSONArray("enum"));

            if (type instanceof JSONSchemaBooleanType) {
                JSONSchemaBooleanType booleanType = (JSONSchemaBooleanType) type;
                if (defaultValue instanceof Boolean) {
                    booleanType.setDefaultValue((Boolean) defaultValue);
View Full Code Here


    @Override
    public void validate(JSONSchema schema, Object obj, String path, ValidationResults results) {
        Collection coll;
        if (obj instanceof JSONArray) {
            coll = new GenericJSONArrayList((JSONArray) obj);
        } else if (obj instanceof Collection) {
            coll = (Collection) obj;
        } else {
            final Iterable iter = (Iterable) obj;
            coll = new AbstractCollection() {
View Full Code Here

        }
        return enums;
    }

    protected static List<Object> convertJSONArrayToList(@Nullable JSONArray jsonArray) {
        return new GenericJSONArrayList(jsonArray);
    }
View Full Code Here

        jsonSchema.setTitle(jsonObject.optString("title", null));
        jsonSchema.setDescription(jsonObject.optString("description", null));

        Object typeValue = jsonObject.opt("type");
        if (typeValue instanceof JSONArray) {
            jsonSchema.setTypes(convertSchemaTypesFromJSONValues(new GenericJSONArrayList((JSONArray) typeValue)));
        } else if (typeValue instanceof Collection) {
            //noinspection unchecked
            jsonSchema.setTypes(convertSchemaTypesFromJSONValues((Collection) typeValue));
        } else if (typeValue != null) {
            jsonSchema.setTypes(convertSchemaTypesFromJSONValues(Collections.singleton(typeValue)));
        }

        for (final JSONSchemaType<?> type : jsonSchema.getTypes()) {
            Object defaultValue = jsonObject.opt("default");
            Number minimum = (Number) jsonObject.opt("minimum");
            Boolean minimumExclusive = (Boolean) jsonObject.opt("exclusiveMinimum");
            Number maximum = (Number) jsonObject.opt("maximum");
            Boolean maximumExclusive = (Boolean) jsonObject.opt("exclusiveMaximum");
            Number divisibleBy = (Number) jsonObject.opt("divisibleBy");

            List<Object> enums = new GenericJSONArrayList(jsonObject.optJSONArray("enum"));

            if (type instanceof JSONSchemaBooleanType) {
                JSONSchemaBooleanType booleanType = (JSONSchemaBooleanType) type;
                if (defaultValue instanceof Boolean) {
                    booleanType.setDefaultValue((Boolean) defaultValue);
View Full Code Here

    @Override
    public void validate(JSONSchema schema, Object obj, String path, ValidationResults results) {
        Collection coll;
        if (obj instanceof JSONArray) {
            coll = new GenericJSONArrayList((JSONArray) obj);
        } else if (obj instanceof Collection) {
            coll = (Collection) obj;
        } else {
            final Iterable iter = (Iterable) obj;
            coll = new AbstractCollection() {
View Full Code Here

    }

    protected JSONSchema convertTypesFromJSONObject(JSONObject jsonObject, JSONSchema jsonSchema) {
        Object typeValue = jsonObject.opt("type");
        if (typeValue instanceof JSONArray) {
            jsonSchema.setTypes(convertSchemaTypesFromJSONValues(jsonObject, new GenericJSONArrayList((JSONArray) typeValue)));
        } else if (typeValue instanceof Collection) {
            //noinspection unchecked
            jsonSchema.setTypes(convertSchemaTypesFromJSONValues(jsonObject, (Collection) typeValue));
        } else if (typeValue != null) {
            jsonSchema.setTypes(convertSchemaTypesFromJSONValues(jsonObject, Collections.singleton(typeValue)));
View Full Code Here

    protected <V> AbstractJSONSchemaSimpleType<V,?> convertSimpleTypeFieldsFromJSONObject(JSONObject jsonObject, AbstractJSONSchemaSimpleType<V,?> simpleType) {
        @SuppressWarnings ("unchecked")
        Object defaultValue = jsonObject.opt("default");

        List<Object> enums = new GenericJSONArrayList(jsonObject.optJSONArray("enum"));

        if (simpleType instanceof JSONSchemaBooleanType) {
            convertBooleanTypeFieldsFromJSONObject(defaultValue, (JSONSchemaBooleanType) simpleType);
        } else if (simpleType instanceof JSONSchemaIntegerType) {
            convertIntegerTypeFieldsFromJSONObject(jsonObject, (JSONSchemaIntegerType) simpleType, defaultValue, enums);
View Full Code Here

TOP

Related Classes of com.bazaarvoice.commons.data.model.json.GenericJSONArrayList

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.