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.HashSet;
14 import java.util.LinkedList;
15 import java.util.List;
16 import java.util.Objects;
18 import org.opendaylight.yangtools.yang.common.QName;
19 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
20 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
21 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
22 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
23 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
24 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationStatement;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
27 public class NotificationEffectiveStatementImpl extends
28 AbstractEffectiveDocumentedDataNodeContainer<QName, NotificationStatement> implements NotificationDefinition {
29 private final QName qname;
30 private final SchemaPath path;
31 private final Set<AugmentationSchema> augmentations;
32 private final List<UnknownSchemaNode> unknownNodes;
34 public NotificationEffectiveStatementImpl(
35 final StmtContext<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> ctx) {
37 this.qname = ctx.getStatementArgument();
38 this.path = ctx.getSchemaPath().get();
40 // initSubstatementCollections
41 Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
42 List<UnknownSchemaNode> unknownNodesInit = new LinkedList<>();
43 Set<AugmentationSchema> augmentationsInit = new HashSet<>();
44 for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
45 if (effectiveStatement instanceof UnknownSchemaNode) {
46 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
47 unknownNodesInit.add(unknownNode);
49 if (effectiveStatement instanceof AugmentationSchema) {
50 AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
51 augmentationsInit.add(augmentationSchema);
54 this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
55 this.augmentations = ImmutableSet.copyOf(augmentationsInit);
59 public QName getQName() {
64 public SchemaPath getPath() {
69 public Set<AugmentationSchema> getAvailableAugmentations() {
74 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
79 public int hashCode() {
82 result = prime * result + Objects.hashCode(qname);
83 result = prime * result + Objects.hashCode(path);
88 public boolean equals(final Object obj) {
95 if (getClass() != obj.getClass()) {
98 final NotificationEffectiveStatementImpl other = (NotificationEffectiveStatementImpl) obj;
99 return Objects.equals(qname, other.qname) && Objects.equals(path, other.path);
103 public String toString() {
104 StringBuilder sb = new StringBuilder(NotificationEffectiveStatementImpl.class.getSimpleName());
105 sb.append("[qname=").append(qname).append(", path=").append(path).append("]");
106 return sb.toString();