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.stmt.rfc6020.effective;
10 import com.google.common.collect.ImmutableList;
11 import com.google.common.collect.ImmutableSet;
12 import java.util.Collection;
13 import java.util.LinkedHashSet;
14 import java.util.LinkedList;
15 import java.util.List;
16 import java.util.Objects;
18 import javax.annotation.Nonnull;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
21 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
22 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
23 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
24 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
25 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationStatement;
26 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
28 public class NotificationEffectiveStatementImpl extends
29 AbstractEffectiveDocumentedDataNodeContainer<QName, NotificationStatement> implements NotificationDefinition {
30 private final QName qname;
31 private final SchemaPath path;
32 private final Set<AugmentationSchema> augmentations;
33 private final List<UnknownSchemaNode> unknownNodes;
35 public NotificationEffectiveStatementImpl(
36 final StmtContext<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> ctx) {
38 this.qname = ctx.getStatementArgument();
39 this.path = ctx.getSchemaPath().get();
41 // initSubstatementCollections
42 Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
43 List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
44 Set<AugmentationSchema> augmentationsInit = new LinkedHashSet<>();
45 for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
46 if (effectiveStatement instanceof UnknownSchemaNode) {
47 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
48 unknownNodesInit.add(unknownNode);
50 if (effectiveStatement instanceof AugmentationSchema) {
51 AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
52 augmentationsInit.add(augmentationSchema);
55 this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
56 this.augmentations = ImmutableSet.copyOf(augmentationsInit);
61 public QName getQName() {
67 public SchemaPath getPath() {
72 public Set<AugmentationSchema> getAvailableAugmentations() {
78 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
83 public int hashCode() {
86 result = prime * result + Objects.hashCode(qname);
87 result = prime * result + Objects.hashCode(path);
92 public boolean equals(final Object obj) {
99 if (getClass() != obj.getClass()) {
102 final NotificationEffectiveStatementImpl other = (NotificationEffectiveStatementImpl) obj;
103 return Objects.equals(qname, other.qname) && Objects.equals(path, other.path);
107 public String toString() {
108 return NotificationEffectiveStatementImpl.class.getSimpleName() + "[qname=" + qname + ", path=" + path + "]";