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
9 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
11 import com.google.common.collect.ImmutableList;
12 import com.google.common.collect.ImmutableList.Builder;
13 import java.util.List;
14 import java.util.Objects;
15 import javax.annotation.Nonnull;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
18 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
19 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
21 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
25 public class GroupingEffectiveStatementImpl extends
26 AbstractEffectiveDocumentedDataNodeContainer<QName, GroupingStatement> implements GroupingDefinition {
27 private final QName qname;
28 private final SchemaPath path;
29 private final boolean addedByUses;
30 private final List<UnknownSchemaNode> unknownNodes;
32 public GroupingEffectiveStatementImpl(
33 final StmtContext<QName, GroupingStatement, EffectiveStatement<QName, GroupingStatement>> ctx) {
36 qname = ctx.getStatementArgument();
37 path = ctx.getSchemaPath().get();
39 addedByUses = ctx.getCopyHistory().contains(CopyType.ADDED_BY_USES);
41 final Builder<UnknownSchemaNode> b = ImmutableList.builder();
42 for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
43 if (effectiveStatement instanceof UnknownSchemaNode) {
44 b.add((UnknownSchemaNode) effectiveStatement);
48 unknownNodes = b.build();
53 public QName getQName() {
59 public SchemaPath getPath() {
64 public boolean isAddedByUses() {
70 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
75 public int hashCode() {
78 result = prime * result + Objects.hashCode(qname);
79 result = prime * result + Objects.hashCode(path);
84 public boolean equals(final Object obj) {
91 if (getClass() != obj.getClass()) {
94 final GroupingEffectiveStatementImpl other = (GroupingEffectiveStatementImpl) obj;
95 return Objects.equals(qname, other.qname) && Objects.equals(path, other.path);
99 public String toString() {
100 return GroupingEffectiveStatementImpl.class.getSimpleName() + "[" +