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;
10 import com.google.common.collect.Collections2;
11 import java.util.Collection;
12 import java.util.Optional;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
17 abstract class AbstractRecursiveCandidateNode extends AbstractDataTreeCandidateNode {
18 AbstractRecursiveCandidateNode(final NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> data) {
23 public final Optional<DataTreeCandidateNode> getModifiedChild(final PathArgument identifier) {
24 return data().getChild(identifier).map(this::createChild);
28 public final Collection<DataTreeCandidateNode> getChildNodes() {
29 return Collections2.transform(data().getValue(), this::createChild);
32 abstract DataTreeCandidateNode createContainer(
33 NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>> childData);
35 abstract DataTreeCandidateNode createLeaf(NormalizedNode<?,?> childData);
37 @SuppressWarnings("unchecked")
38 private DataTreeCandidateNode createChild(final NormalizedNode<?, ?> childData) {
39 if (childData instanceof NormalizedNodeContainer) {
40 return createContainer((NormalizedNodeContainer<?, PathArgument, NormalizedNode<?, ?>>) childData);
42 return createLeaf(childData);