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.ImmutableSet;
13 import java.util.List;
14 import java.util.Objects;
15 import javax.annotation.Nonnull;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
19 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
20 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
21 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
22 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
23 import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
27 public class GroupingEffectiveStatementImpl extends
28 AbstractEffectiveDocumentedDataNodeContainer<QName, GroupingStatement> implements GroupingDefinition {
29 private final QName qname;
30 private final SchemaPath path;
31 private final boolean addedByUses;
32 private final Set<NotificationDefinition> notifications;
33 private final List<UnknownSchemaNode> unknownNodes;
35 public GroupingEffectiveStatementImpl(
36 final StmtContext<QName, GroupingStatement, EffectiveStatement<QName, GroupingStatement>> ctx) {
39 qname = ctx.getStatementArgument();
40 path = ctx.getSchemaPath().get();
42 addedByUses = ctx.getCopyHistory().contains(CopyType.ADDED_BY_USES);
44 final ImmutableSet.Builder<NotificationDefinition> notificationsBuilder = ImmutableSet.builder();
45 final ImmutableList.Builder<UnknownSchemaNode> b = ImmutableList.builder();
46 for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
47 if (effectiveStatement instanceof NotificationDefinition) {
48 notificationsBuilder.add((NotificationDefinition) effectiveStatement);
50 if (effectiveStatement instanceof UnknownSchemaNode) {
51 b.add((UnknownSchemaNode) effectiveStatement);
55 this.notifications = notificationsBuilder.build();
56 unknownNodes = b.build();
61 public QName getQName() {
67 public SchemaPath getPath() {
72 public boolean isAddedByUses() {
78 public Set<NotificationDefinition> getNotifications() {
83 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
88 public int hashCode() {
91 result = prime * result + Objects.hashCode(qname);
92 result = prime * result + Objects.hashCode(path);
97 public boolean equals(final Object obj) {
104 if (getClass() != obj.getClass()) {
107 final GroupingEffectiveStatementImpl other = (GroupingEffectiveStatementImpl) obj;
108 return Objects.equals(qname, other.qname) && Objects.equals(path, other.path);
112 public String toString() {
113 return GroupingEffectiveStatementImpl.class.getSimpleName() + "[" + "qname=" + qname + "]";