8ca88d8d6110aa6807da562ff3c2543c10faeb57
[controller.git] / opendaylight / sal / yang-prototype / code-generator / yang-model-parser-impl / src / main / java / org / opendaylight / controller / yang / parser / builder / api / AbstractDataNodeContainerBuilder.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.yang.parser.builder.api;
9
10 import java.util.HashSet;
11 import java.util.Set;
12
13 import org.opendaylight.controller.yang.common.QName;
14 import org.opendaylight.controller.yang.model.api.DataSchemaNode;
15 import org.opendaylight.controller.yang.model.api.GroupingDefinition;
16
17 public abstract class AbstractDataNodeContainerBuilder implements DataNodeContainerBuilder {
18
19     private final QName qname;
20
21     protected Set<DataSchemaNode> childNodes;
22     protected final Set<DataSchemaNodeBuilder> addedChildNodes = new HashSet<DataSchemaNodeBuilder>();
23
24     protected Set<GroupingDefinition> groupings;
25     protected final Set<GroupingBuilder> addedGroupings = new HashSet<GroupingBuilder>();
26
27     protected AbstractDataNodeContainerBuilder(QName qname) {
28         this.qname = qname;
29     }
30
31     @Override
32     public QName getQName() {
33         return qname;
34     }
35
36     @Override
37     public Set<DataSchemaNodeBuilder> getChildNodes() {
38         return addedChildNodes;
39     }
40
41     @Override
42     public void addChildNode(DataSchemaNodeBuilder childNode) {
43         addedChildNodes.add(childNode);
44     }
45
46     public void setChildNodes(Set<DataSchemaNode> childNodes) {
47         this.childNodes = childNodes;
48     }
49
50     public Set<GroupingBuilder> getGroupings() {
51         return addedGroupings;
52     }
53
54     @Override
55     public void addGrouping(GroupingBuilder grouping) {
56         addedGroupings.add(grouping);
57     }
58
59     public void setGroupings(final Set<GroupingDefinition> groupings) {
60         this.groupings = groupings;
61     }
62
63 }