@Override public boolean isEmpty() { return treeNode.isEmpty(); }
private void removeEmptyIntermediateNode(Path path, TreeNode treeNode) { if (treeNode.isEmpty()) { children.remove(path.getHead()); } } }
@Override public TreeNode evaluate(TreeNode rootNode, TreeNode valueNode) { if (valueNode.type() == TreeNode.Type.VALUE_NODE && !valueNode.isEmpty()) { try { return new ValueNode(processValue(rootNode, valueNode.value())); } catch (Exception e) { LOGGER.error("Error when evaluating configuration macro: {}", valueNode.value(), e); return new ValueNode(); } } else { return valueNode; } }
@Override public TreeNode evaluate(TreeNode rootNode, TreeNode valueNode) { if (valueNode.type() == TreeNode.Type.VALUE_NODE && !valueNode.isEmpty()) { try { return new ValueNode(processValue(rootNode, valueNode.value())); } catch (Exception e) { LOGGER.error("Error when evaluating configuration function: {}", valueNode.value(), e); return new ValueNode(); } } else { return valueNode; } }
@Override public TreeNode remove(String name) { Path path = new Path(name); if (path.hasTail()) { if (children.size() > path.getIndex()) { TreeNode treeNode = children.get(path.getIndex()); try { TreeNode removedNode = treeNode.remove(path.getTail()); if (treeNode.isEmpty()) { children.remove(path.getIndex()); } return removedNode; } catch (PropertyNotFoundException e) { throw new PropertyNotFoundException(e, path.getHead()); } } else { throw new PropertyNotFoundException(name); } } else { return children.remove(path.getIndex()); } }
public Object map(TreeNode treeNode, Type type) { if (treeNode == null || (treeNode.type() == TreeNode.Type.VALUE_NODE && treeNode.isEmpty())) { return null; } for (ConfigurationMapper configurationMapper : items) { if (configurationMapper.canHandle(type)) { return configurationMapper.map(treeNode, type); } } ObjectMapper<?> objectMapper = new ObjectMapper<>(rawClassOf(type)); objectMapper.initialize(coffig); return objectMapper.map(treeNode); }