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 org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
17 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
24 public class GroupingEffectiveStatementImpl extends
25 AbstractEffectiveDocumentedDataNodeContainer<QName, GroupingStatement> implements GroupingDefinition {
26 private final QName qname;
27 private final SchemaPath path;
28 private final boolean addedByUses;
29 private final List<UnknownSchemaNode> unknownNodes;
31 public GroupingEffectiveStatementImpl(
32 final StmtContext<QName, GroupingStatement, EffectiveStatement<QName, GroupingStatement>> ctx) {
35 qname = ctx.getStatementArgument();
36 path = ctx.getSchemaPath().get();
38 addedByUses = ctx.getCopyHistory().contains(CopyType.ADDED_BY_USES);
40 final Builder<UnknownSchemaNode> b = ImmutableList.builder();
41 for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
42 if (effectiveStatement instanceof UnknownSchemaNode) {
43 b.add((UnknownSchemaNode) effectiveStatement);
47 unknownNodes = b.build();
51 public QName getQName() {
56 public SchemaPath getPath() {
61 public boolean isAddedByUses() {
66 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
71 public int hashCode() {
74 result = prime * result + Objects.hashCode(qname);
75 result = prime * result + Objects.hashCode(path);
80 public boolean equals(final Object obj) {
87 if (getClass() != obj.getClass()) {
90 final GroupingEffectiveStatementImpl other = (GroupingEffectiveStatementImpl) obj;
91 return Objects.equals(qname, other.qname) && Objects.equals(path, other.path);
95 public String toString() {
96 return GroupingEffectiveStatementImpl.class.getSimpleName() + "[" +