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.parser.rfc7950.stmt;
10 import com.google.common.collect.ImmutableSet;
11 import java.util.Collection;
12 import java.util.HashSet;
13 import java.util.LinkedHashSet;
14 import java.util.Optional;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
18 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
20 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
21 import org.opendaylight.yangtools.yang.model.api.UsesNode;
22 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
23 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
24 import org.opendaylight.yangtools.yang.model.api.stmt.TypedefEffectiveStatement;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
27 @Deprecated(forRemoval = true)
28 public abstract class AbstractEffectiveDocumentedDataNodeContainer<A, D extends DeclaredStatement<A>>
29 extends AbstractSchemaEffectiveDocumentedNode<A, D> implements DataNodeContainer {
31 private final ImmutableSet<GroupingDefinition> groupings;
32 private final ImmutableSet<UsesNode> uses;
33 private final ImmutableSet<TypeDefinition<?>> typeDefinitions;
34 private final ImmutableSet<DataSchemaNode> publicChildNodes;
36 protected AbstractEffectiveDocumentedDataNodeContainer(final StmtContext<A, D, ?> ctx) {
39 Set<GroupingDefinition> mutableGroupings = new HashSet<>();
40 Set<UsesNode> mutableUses = new HashSet<>();
41 Set<TypeDefinition<?>> mutableTypeDefinitions = new LinkedHashSet<>();
42 Set<DataSchemaNode> mutablePublicChildNodes = new LinkedHashSet<>();
44 for (EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
45 if (stmt instanceof DataSchemaNode) {
46 mutablePublicChildNodes.add((DataSchemaNode) stmt);
48 if (stmt instanceof UsesNode && !mutableUses.add((UsesNode) stmt)) {
49 throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, stmt);
51 if (stmt instanceof TypedefEffectiveStatement
52 && !mutableTypeDefinitions.add(((TypedefEffectiveStatement) stmt).getTypeDefinition())) {
53 throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, stmt);
55 if (stmt instanceof GroupingDefinition && !mutableGroupings.add((GroupingDefinition) stmt)) {
56 throw EffectiveStmtUtils.createNameCollisionSourceException(ctx, stmt);
60 this.groupings = ImmutableSet.copyOf(mutableGroupings);
61 this.publicChildNodes = ImmutableSet.copyOf(mutablePublicChildNodes);
62 this.typeDefinitions = ImmutableSet.copyOf(mutableTypeDefinitions);
63 this.uses = ImmutableSet.copyOf(mutableUses);
67 public final Collection<? extends TypeDefinition<?>> getTypeDefinitions() {
68 return typeDefinitions;
72 public final Collection<? extends DataSchemaNode> getChildNodes() {
73 return publicChildNodes;
77 public final Set<GroupingDefinition> getGroupings() {
82 public final Optional<DataSchemaNode> findDataChildByName(final QName name) {
83 return findDataSchemaNode(name);
87 public Set<UsesNode> getUses() {