2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.data.api.schema.tree.spi;
10 import com.google.common.base.Optional;
12 import org.opendaylight.yangtools.util.MapAdaptor;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
16 * A container node which may need further materialization. Materialized nodes are tracked in a map, which is consulted
17 * before creating a new child node from backing data. Since the child is immutable, we do not have to track it.
19 final class LazyMutableContainerNode extends AbstractMutableContainerNode {
20 LazyMutableContainerNode(final AbstractContainerNode parent) {
21 this(parent, MapAdaptor.getDefaultInstance().<PathArgument, TreeNode>initialSnapshot(1));
24 LazyMutableContainerNode(final AbstractContainerNode parent, final Map<PathArgument, TreeNode> children) {
25 super(parent, children);
29 public Optional<TreeNode> getChild(final PathArgument childId) {
30 final TreeNode modified = getModifiedChild(childId);
31 if (modified != null) {
32 return Optional.of(modified);
35 return Optional.fromNullable(AbstractContainerNode.getChildFromData(getData(), childId, getVersion()));