Package org.infinispan.schematic.document.JsonSchema

Examples of org.infinispan.schematic.document.JsonSchema.Type


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


                    // We're supposed to check the whole document is the correct type ...
                    fieldValue = document;
                }
            }
            if (fieldValue != null) {
                Type actual = Type.typeFor(fieldValue);
                if (!type.isEquivalent(actual)) {
                    // See if the value is convertable ...
                    Object converted = type.convertValueFrom(fieldValue, actual);
                    Path pathToField = fieldName != null ? pathToDocument.with(fieldName) : pathToDocument;
                    String reason = "Field value for '" + pathToField + "' expected to be of type " + type + " but was of type "
View Full Code Here

                              String fieldName,
                              Document parent,
                              Path pathToParent,
                              Problems problems,
                              SchemaDocumentResolver resolver ) {
            Type type = Type.typeFor(fieldValue);
            if (type != Type.NULL) {
                if (disallowedTypes.contains(type)) {
                    problems.recordError(pathToParent.with(fieldName), "The '" + fieldName + "' field on '" + pathToParent
                                                                       + "' contains a value '" + fieldValue + "' whose type '"
                                                                       + type + "' is disallowed.");
View Full Code Here

TOP

Related Classes of org.infinispan.schematic.document.JsonSchema.Type

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.