super(name, 0, null);
this.name = name;
instance = new ModuleImpl(name);
+ actualPath.push(this);
}
/**
builder.setParent(parent);
String groupingName = qname.getLocalName();
- if (parent == null) {
+ if (parent.equals(this)) {
for (GroupingBuilder addedGrouping : addedGroupings) {
if (addedGrouping.getQName().getLocalName().equals(groupingName)) {
throw new YangParseException(name, line, "grouping with same name '" + groupingName
Builder parent = getActualNode();
builder.setParent(parent);
- if (parent == null) {
+ if (parent.equals(this)) {
// augment can be declared only under 'module' ...
addedAugments.add(builder);
} else {
Builder parent = getActualNode();
usesBuilder.setParent(parent);
- if (parent == null) {
+ if (parent.equals(this)) {
addedUsesNodes.add(usesBuilder);
} else {
if (!(parent instanceof DataNodeContainerBuilder)) {
public void addRefine(final RefineHolder refine) {
final Builder parent = getActualNode();
- if (parent == null) {
+ if (!(parent instanceof UsesNodeBuilder)) {
throw new YangParseException(name, refine.getLine(), "refine can be defined only in uses statement");
- } else {
- if (parent instanceof UsesNodeBuilder) {
- ((UsesNodeBuilder) parent).addRefine(refine);
- } else {
- throw new YangParseException(name, refine.getLine(), "refine can be defined only in uses statement");
- }
- refine.setParent(parent);
}
+ ((UsesNodeBuilder) parent).addRefine(refine);
+ refine.setParent(parent);
}
public RpcDefinitionBuilder addRpc(final int line, final QName qname) {
Builder parent = getActualNode();
- if (parent != null) {
+ if (!(parent.equals(this))) {
throw new YangParseException(name, line, "rpc can be defined only in module or submodule");
}
}
public ContainerSchemaNodeBuilder addRpcOutput(final SchemaPath schemaPath, final QName qname, final int line) {
- final Builder parent = actualPath.getFirst();
+ final Builder parent = getActualNode();
if (!(parent instanceof RpcDefinitionBuilder)) {
throw new YangParseException(name, line, "output can be defined only in rpc statement");
}
}
public NotificationBuilder addNotification(final int line, final QName qname) {
- if (!(actualPath.isEmpty())) {
+ final Builder parent = getActualNode();
+ if (!(parent.equals(this))) {
throw new YangParseException(name, line, "notification can be defined only in module or submodule");
}
public FeatureBuilder addFeature(final int line, final QName qname) {
Builder parent = getActualNode();
- if (parent != null) {
+ if (!(parent.equals(this))) {
throw new YangParseException(name, line, "feature can be defined only in module or submodule");
}
public ChoiceCaseBuilder addCase(final int line, final QName qname) {
Builder parent = getActualNode();
- if (parent == null) {
+ if (parent == null || parent.equals(this)) {
throw new YangParseException(name, line, "'case' parent not found");
}
builder.setParent(parent);
String typedefName = qname.getLocalName();
- if (parent == null) {
+ if (parent.equals(this)) {
for (TypeDefinitionBuilder tdb : addedTypedefs) {
if (tdb.getQName().getLocalName().equals(typedefName)) {
throw new YangParseException(name, line, "typedef with same name '" + typedefName
public DeviationBuilder addDeviation(final int line, final String targetPath) {
Builder parent = getActualNode();
- if (parent != null) {
+ if (!(parent.equals(this))) {
throw new YangParseException(name, line, "deviation can be defined only in module or submodule");
}
public IdentitySchemaNodeBuilder addIdentity(final QName qname, final List<String> parentPath, final int line) {
Builder parent = getActualNode();
- if (parent != null) {
+ if (!(parent.equals(this))) {
throw new YangParseException(name, line, "identity can be defined only in module or submodule");
}
String identityName = qname.getLocalName();
builder.setParent(parent);
allUnknownNodes.add(builder);
- if (parent == null) {
+ if (parent.equals(this)) {
addedUnknownNodes.add(builder);
} else {
if (parent instanceof SchemaNodeBuilder) {
*/
private void addChildToParent(final Builder parent, final DataSchemaNodeBuilder child, final String childName) {
final int line = child.getLine();
- if (parent == null) {
+ if (parent.equals(this)) {
// if parent == null => node is defined under module
// All leafs, leaf-lists, lists, containers, choices, rpcs,
// notifications, and anyxmls defined within a parent node or at the