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.parser.builder.util;
10 import com.google.common.base.Preconditions;
11 import java.util.ArrayList;
12 import java.util.List;
13 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
14 import org.opendaylight.yangtools.yang.parser.builder.api.Builder;
15 import org.opendaylight.yangtools.yang.parser.builder.api.UnknownSchemaNodeBuilder;
18 * Base helper implementation of Builders for Yang Model elements.
20 * @deprecated Pre-Beryllium implementation, scheduled for removal.
23 public abstract class AbstractBuilder implements Builder {
24 private final String moduleName;
25 private final int line;
26 private Builder parentBuilder;
28 protected final List<UnknownSchemaNode> unknownNodes = new ArrayList<>();
29 protected final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<>();
30 private boolean sealed;
32 protected AbstractBuilder(final String moduleName, final int line) {
33 this.moduleName = Preconditions.checkNotNull(moduleName,"moduleName must not be null");
38 public String getModuleName() {
43 public int getLine() {
48 public Builder getParent() {
53 public void setParent(final Builder parentBuilder) {
55 this.parentBuilder = parentBuilder;
59 public List<UnknownSchemaNodeBuilder> getUnknownNodes() {
60 return addedUnknownNodes;
64 public void addUnknownNodeBuilder(final UnknownSchemaNodeBuilder unknownNode) {
65 addedUnknownNodes.add(unknownNode);
73 protected final void checkNotSealed() {
74 Preconditions.checkState(!sealed, "Builder is sealed. No further modifications allowed");