Allow derived context to be reused
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / notification / NotificationEffectiveStatementImpl.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.notification;
9
10 import com.google.common.collect.ImmutableList;
11 import org.eclipse.jdt.annotation.Nullable;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
14 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
15 import org.opendaylight.yangtools.yang.model.api.SchemaNodeDefaults;
16 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
17 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationStatement;
20 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement.DefaultWithDataTree.WithSubstatements;
21 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.AugmentationTargetMixin;
22 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.CopyableMixin;
23 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.DataNodeContainerMixin;
24 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.MustConstraintMixin;
25 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.SchemaNodeMixin;
26
27 final class NotificationEffectiveStatementImpl
28         extends WithSubstatements<QName, NotificationStatement, NotificationEffectiveStatement>
29         implements NotificationDefinition, NotificationEffectiveStatement,
30                    SchemaNodeMixin<QName, NotificationStatement>, DataNodeContainerMixin<QName, NotificationStatement>,
31                    AugmentationTargetMixin<QName, NotificationStatement>, CopyableMixin<QName, NotificationStatement>,
32                    MustConstraintMixin<QName, NotificationStatement> {
33
34     private final @Nullable SchemaPath path;
35     private final int flags;
36
37     NotificationEffectiveStatementImpl(final NotificationStatement declared,
38             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final int flags,
39             final SchemaPath path) {
40         super(declared, substatements);
41         this.flags = flags;
42         this.path = path;
43     }
44
45     NotificationEffectiveStatementImpl(final NotificationEffectiveStatementImpl original, final int flags,
46             final SchemaPath path) {
47         super(original);
48         this.flags = flags;
49         this.path = path;
50     }
51
52     @Override
53     public QName argument() {
54         return getQName();
55     }
56
57     @Override
58     public DataSchemaNode dataChildByName(final QName name) {
59         return dataSchemaNode(name);
60     }
61
62     @Override
63     public int flags() {
64         return flags;
65     }
66
67     @Override
68     @Deprecated
69     public SchemaPath getPath() {
70         return SchemaNodeDefaults.throwUnsupportedIfNull(this, path);
71     }
72
73     @Override
74     public NotificationEffectiveStatement asEffectiveStatement() {
75         return this;
76     }
77
78     @Override
79     public String toString() {
80         return NotificationEffectiveStatementImpl.class.getSimpleName() + "[qname=" + getQName() + ", path=" + path
81                 + "]";
82     }
83 }