Java Code Examples for com.fasterxml.jackson.databind.util.ClassUtil#emptyIterator()

The following examples show how to use com.fasterxml.jackson.databind.util.ClassUtil#emptyIterator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: POJOPropertyBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Iterator<AnnotatedParameter> getConstructorParameters() {
    if (_ctorParameters == null) {
        return ClassUtil.emptyIterator();
    }
    return new MemberIterator<AnnotatedParameter>(_ctorParameters);
}
 
Example 2
Source File: Attribute.java    From zentity with Apache License 2.0 4 votes vote down vote up
/**
 * Parse a single input attribute value. The following examples are all valid attribute structures, although the
 * first example would be converted to the second example.
 * <pre>
 *  {
 *   ATTRIBUTE_NAME: [
 *     ATTRIBUTE_VALUE,
 *     ...
 *   ]
 * }
 *
 * {
 *   ATTRIBUTE_NAME: {
 *     "values": [
 *       ATTRIBUTE_VALUE,
 *       ...
 *     ]
 *   }
 * }
 *
 * {
 *   ATTRIBUTE_NAME: {
 *     "values": [
 *       ATTRIBUTE_VALUE,
 *       ...
 *     ],
 *     "params": {
 *       ATTRIBUTE_PARAM_FIELD: ATTRIBUTE_PARAM_VALUE,
 *       ...
 *     }
 *   }
 * }
 *
 * {
 *   ATTRIBUTE_NAME: {
 *     "params": {
 *       ATTRIBUTE_PARAM_FIELD: ATTRIBUTE_PARAM_VALUE,
 *       ...
 *     }
 *   }
 * }
 * </pre>
 *
 * @param json Attribute object of an entity model.
 * @throws ValidationException
 */
public void deserialize(JsonNode json) throws ValidationException, JsonProcessingException {
    if (json.isNull())
        return;
    if (!json.isObject() && !json.isArray())
        throw new ValidationException("'attributes." + this.name + "' must be an object or array.");

    Iterator<JsonNode> valuesNode = ClassUtil.emptyIterator();
    Iterator<Map.Entry<String, JsonNode>> paramsNode = ClassUtil.emptyIterator();

    // Parse values from array
    if (json.isArray()) {
        valuesNode = json.elements();

    } else if (json.isObject()) {

        // Parse values from object
        if (json.has("values")) {
            if (!json.get("values").isArray())
                throw new ValidationException("'attributes." + this.name + ".values' must be an array.");
            valuesNode = json.get("values").elements();
        }

        // Parse params from object
        if (json.has("params")) {
            if (!json.get("params").isObject())
                throw new ValidationException("'attributes." + this.name + ".params' must be an object.");
            paramsNode = json.get("params").fields();
        }
    } else {
        throw new ValidationException("'attributes." + this.name + "' must be an object or array.");
    }

    // Set any values or params that were specified in the input.
    while (valuesNode.hasNext()) {
        JsonNode valueNode = valuesNode.next();
        this.values().add(Value.create(this.type, valueNode));
    }

    // Set any params that were specified in the input, with the values serialized as strings.
    while (paramsNode.hasNext()) {
        Map.Entry<String, JsonNode> paramNode = paramsNode.next();
        String paramField = paramNode.getKey();
        JsonNode paramValue = paramNode.getValue();
        if (paramValue.isObject() || paramValue.isArray())
            this.params().put(paramField, Json.MAPPER.writeValueAsString(paramValue));
        else if (paramValue.isNull())
            this.params().put(paramField, "null");
        else
            this.params().put(paramField, paramValue.asText());
    }
}
 
Example 3
Source File: JsonNode.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Iterator<String> fieldNames() {
    return ClassUtil.emptyIterator();
}
 
Example 4
Source File: JsonSerializer.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Accessor for iterating over logical properties that the type
 * handled by this serializer has, from serialization perspective.
 * Actual type of properties, if any, will be
 * {@link com.fasterxml.jackson.databind.ser.BeanPropertyWriter}.
 * Of standard Jackson serializers, only {@link com.fasterxml.jackson.databind.ser.BeanSerializer}
 * exposes properties.
 *
 * @since 2.6
 */
public Iterator<PropertyWriter> properties() {
    return ClassUtil.emptyIterator();
}
 
Example 5
Source File: JsonNode.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Method for accessing all value nodes of this Node, iff
 * this node is a JSON Array or Object node. In case of Object node,
 * field names (keys) are not included, only values.
 * For other types of nodes, returns empty iterator.
 */
public Iterator<JsonNode> elements() {
    return ClassUtil.emptyIterator();
}
 
Example 6
Source File: JsonNode.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * @return Iterator that can be used to traverse all key/value pairs for
 *   object nodes; empty iterator (no contents) for other types
 */
public Iterator<Map.Entry<String, JsonNode>> fields() {
    return ClassUtil.emptyIterator();
}
 
Example 7
Source File: BeanPropertyDefinition.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Additional method that may be called instead of {@link #getConstructorParameter()}
 * to get access to all constructor parameters, not just the highest priority one.
 * 
 * @since 2.5
 */
public Iterator<AnnotatedParameter> getConstructorParameters() {
    return ClassUtil.emptyIterator();
}