Search in sources :

Example 1 with YamlNameNodePair

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

the class AbstractYamlConfigBuilder method fillReplacerProperties.

private void fillReplacerProperties(Node node, Properties properties) {
    YamlMapping propertiesMapping = asMapping(((YamlElementAdapter) node).getYamlNode());
    for (YamlNameNodePair childNodePair : propertiesMapping.childrenPairs()) {
        String childName = childNodePair.nodeName();
        YamlNode child = childNodePair.childNode();
        Object nodeValue = asScalar(child).nodeValue();
        properties.put(childName, nodeValue != null ? nodeValue.toString() : "");
    }
}
Also used : YamlNode(com.hazelcast.internal.yaml.YamlNode) MutableYamlMapping(com.hazelcast.internal.yaml.MutableYamlMapping) YamlMapping(com.hazelcast.internal.yaml.YamlMapping) YamlNameNodePair(com.hazelcast.internal.yaml.YamlNameNodePair)

Example 2 with YamlNameNodePair

use of com.hazelcast.internal.yaml.YamlNameNodePair 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

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