2 * Copyright (c) 2013 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.impl.util;
10 import static com.google.common.base.Preconditions.checkNotNull;
12 import com.google.common.collect.Iterables;
14 import java.util.ArrayList;
15 import java.util.List;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
20 import org.opendaylight.yangtools.yang.data.api.Node;
21 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
24 * @deprecated Use one of the {@link NormalizedNodeContainerBuilder} implementations.
27 public abstract class AbstractCompositeNodeBuilder<P extends CompositeNode> extends AbstractNodeBuilder<P, CompositeNodeBuilder<P>> implements CompositeNodeBuilder<P> {
29 final List<Node<?>> childNodes;
31 public AbstractCompositeNodeBuilder() {
33 childNodes = new ArrayList<>();
36 public AbstractCompositeNodeBuilder(final QName nodeType, final Map<QName, String> attributes) {
37 super(nodeType, attributes);
38 childNodes = new ArrayList<>();
41 public AbstractCompositeNodeBuilder(final QName nodeType, final Iterable<? extends Node<?>> nodes) {
43 childNodes = new ArrayList<>();
47 public AbstractCompositeNodeBuilder<P> add(final Node<?> node) {
48 childNodes.add(checkNotNull(node, "Node should not be null"));
53 public AbstractCompositeNodeBuilder<P> addAll(final Iterable<? extends Node<?>> nodes) {
54 Iterables.addAll(childNodes, checkNotNull(nodes, "Node should not be null"));
59 public CompositeNodeBuilder<P> addLeaf(final String leafLocalName, final String leafValue) {
60 return addLeaf(QName.create(getQName(), leafLocalName), leafValue);
63 public List<Node<?>> getChildNodes() {