Search in sources :

Example 1 with YamlScalar

use of com.hazelcast.internal.yaml.YamlScalar in project hazelcast by hazelcast.

the class YamlDomChecker method check.

/**
 * Performs {code @null} checks on the provided YAML node recursively.
 *
 * @param node The YAML node to check for {@code null}s
 */
public static void check(YamlNode node) {
    if (node instanceof YamlMapping) {
        for (YamlNameNodePair nodePair : ((YamlMapping) node).childrenPairs()) {
            YamlNode child = nodePair.childNode();
            if (child == null) {
                String path = YamlUtil.constructPath(node, nodePair.nodeName());
                reportNullEntryOnConcretePath(path);
            }
            check(nodePair.childNode());
        }
    } else if (node instanceof YamlSequence) {
        for (YamlNode child : ((YamlSequence) node).children()) {
            if (child == null) {
                throw new InvalidConfigurationException("There is a null configuration entry under sequence " + node.path() + ". Please check if the provided YAML configuration is well-indented and no blocks started without " + "sub-nodes.");
            }
            check(child);
        }
    } else {
        if (((YamlScalar) node).nodeValue() == null) {
            reportNullEntryOnConcretePath(node.path());
        }
    }
}
Also used : YamlSequence(com.hazelcast.internal.yaml.YamlSequence) YamlNode(com.hazelcast.internal.yaml.YamlNode) YamlScalar(com.hazelcast.internal.yaml.YamlScalar) YamlMapping(com.hazelcast.internal.yaml.YamlMapping) YamlNameNodePair(com.hazelcast.internal.yaml.YamlNameNodePair) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Aggregations

InvalidConfigurationException (com.hazelcast.config.InvalidConfigurationException)1 YamlMapping (com.hazelcast.internal.yaml.YamlMapping)1 YamlNameNodePair (com.hazelcast.internal.yaml.YamlNameNodePair)1 YamlNode (com.hazelcast.internal.yaml.YamlNode)1 YamlScalar (com.hazelcast.internal.yaml.YamlScalar)1 YamlSequence (com.hazelcast.internal.yaml.YamlSequence)1