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.ArrayList;
13 import java.util.LinkedHashSet;
14 import java.util.List;
15 import java.util.Objects;
17 import javax.annotation.Nonnull;
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.ConstraintDefinition;
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 ConstraintDefinition constraints;
33 private final Set<AugmentationSchema> augmentations;
34 private final List<UnknownSchemaNode> unknownNodes;
36 public NotificationEffectiveStatementImpl(
37 final StmtContext<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> ctx) {
39 this.qname = ctx.getStatementArgument();
40 this.path = ctx.getSchemaPath().get();
42 this.constraints = EffectiveConstraintDefinitionImpl.forParent(this);
44 // initSubstatementCollections
45 List<UnknownSchemaNode> unknownNodesInit = new ArrayList<>();
46 Set<AugmentationSchema> augmentationsInit = new LinkedHashSet<>();
47 for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
48 if (effectiveStatement instanceof UnknownSchemaNode) {
49 UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
50 unknownNodesInit.add(unknownNode);
52 if (effectiveStatement instanceof AugmentationSchema) {
53 AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
54 augmentationsInit.add(augmentationSchema);
57 this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
58 this.augmentations = ImmutableSet.copyOf(augmentationsInit);
63 public QName getQName() {
69 public SchemaPath getPath() {
74 public ConstraintDefinition getConstraints() {
79 public Set<AugmentationSchema> getAvailableAugmentations() {
85 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
90 public int hashCode() {
93 result = prime * result + Objects.hashCode(qname);
94 result = prime * result + Objects.hashCode(path);
99 public boolean equals(final Object obj) {
106 if (getClass() != obj.getClass()) {
109 final NotificationEffectiveStatementImpl other = (NotificationEffectiveStatementImpl) obj;
110 return Objects.equals(qname, other.qname) && Objects.equals(path, other.path);
114 public String toString() {
115 return NotificationEffectiveStatementImpl.class.getSimpleName() + "[qname=" + qname + ", path=" + path + "]";