blob: 62ee584fdac0477ca26c9c7b5f817f30c9766946 [file] [log] [blame]
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.yangutils.datamodel;
18
19import java.util.LinkedList;
20import java.util.List;
Bharat saraswald9822e92016-04-05 15:13:44 +053021
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +053022import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Bharat saraswal96dfef02016-06-16 00:29:12 +053023import org.onosproject.yangutils.datamodel.utils.Parsable;
24import org.onosproject.yangutils.datamodel.utils.YangConstructType;
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +053025
26import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
27
28/*
29 * Reference RFC 6020.
30 *
31 * YANG allows the definition of notifications suitable for NETCONF.
32 * YANG data definition statements are used to model the content of the
33 * notification.
34 *
35 * The "notification" statement is used to define a NETCONF
36 * notification. It takes one argument, which is an identifier,
37 * followed by a block of substatements that holds detailed notification
38 * information. The "notification" statement defines a notification
39 * node in the schema tree.
40 *
41 * If a leaf in the notification tree has a "mandatory" statement with
42 * the value "true", the leaf MUST be present in a NETCONF notification.
43 *
44 * If a leaf in the notification tree has a default value, the NETCONF
45 * client MUST use this value in the same cases as described in
46 * Section 7.6.1. In these cases, the client MUST operationally behave
47 * as if the leaf was present in the NETCONF notification with the
48 * default value as its value.
49 *
50 * If a "config" statement is present for any node in the notification
51 * tree, the "config" statement is ignored.
52 *
53 * The notification's substatements
54 *
55 * +--------------+---------+-------------+------------------+
56 * | substatement | section | cardinality |data model mapping|
57 * +--------------+---------+-------------+------------------+
58 * | anyxml | 7.10 | 0..n | -not supported |
59 * | choice | 7.9 | 0..n | -child nodes |
60 * | container | 7.5 | 0..n | -child nodes |
61 * | description | 7.19.3 | 0..1 | -string |
62 * | grouping | 7.11 | 0..n | -child nodes |
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053063 * | if-feature | 7.18.2 | 0..n | -YangIfFeature |
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +053064 * | leaf | 7.6 | 0..n | -YangLeaf |
65 * | leaf-list | 7.7 | 0..n | -YangLeafList |
66 * | list | 7.8 | 0..n | -child nodes |
67 * | reference | 7.19.4 | 0..1 | -string |
68 * | status | 7.19.2 | 0..1 | -YangStatus |
69 * | typedef | 7.3 | 0..n | -child nodes |
70 * | uses | 7.12 | 0..n | -child nodes |
71 * +--------------+---------+-------------+------------------+
72 */
73
74/**
Bharat saraswald9822e92016-04-05 15:13:44 +053075 * Represents data model node to maintain information defined in YANG notification.
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +053076 */
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +053077public class YangNotification
78 extends YangNode
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053079 implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector, YangAugmentationHolder,
80 YangIfFeatureHolder {
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +053081
Bharat saraswal96dfef02016-06-16 00:29:12 +053082 private static final long serialVersionUID = 806201611L;
83
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +053084 /**
85 * Name of the notification.
86 */
87 private String name;
88
89 /**
90 * Description of notification.
91 */
92 private String description;
93
94 /**
95 * List of leaves contained.
96 */
97 private List<YangLeaf> listOfLeaf;
98
99 /**
100 * List of leaf-lists contained.
101 */
102 private List<YangLeafList> listOfLeafList;
103
104 /**
105 * Reference of the module.
106 */
107 private String reference;
108
109 /**
110 * Status of the node.
111 */
112 private YangStatusType status = YangStatusType.CURRENT;
113
114 /**
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530115 * List of if-feature.
116 */
117 private List<YangIfFeature> ifFeatureList;
118
119 /**
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +0530120 * Create a notification node.
121 */
122 public YangNotification() {
123 super(YangNodeType.NOTIFICATION_NODE);
124 listOfLeaf = new LinkedList<YangLeaf>();
125 listOfLeafList = new LinkedList<YangLeafList>();
126 }
127
128 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530129 public void detectCollidingChild(String identifierName, YangConstructType dataType)
130 throws DataModelException {
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +0530131 // Detect colliding child.
132 detectCollidingChildUtil(identifierName, dataType, this);
133 }
134
135 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530136 public void detectSelfCollision(String identifierName, YangConstructType dataType)
137 throws DataModelException {
Bharat saraswal96dfef02016-06-16 00:29:12 +0530138 if (getName().equals(identifierName)) {
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +0530139 throw new DataModelException("YANG file error: Duplicate input identifier detected, same as notification \""
Bharat saraswal96dfef02016-06-16 00:29:12 +0530140 + getName() + "\"");
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +0530141 }
142 }
143
144 @Override
145 public YangConstructType getYangConstructType() {
146 return YangConstructType.NOTIFICATION_DATA;
147 }
148
149 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530150 public void validateDataOnEntry()
151 throws DataModelException {
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +0530152 //TODO: implement the method.
153 }
154
155 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530156 public void validateDataOnExit()
157 throws DataModelException {
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +0530158 //TODO: implement the method.
159 }
160
161 @Override
162 public String getDescription() {
163 return description;
164 }
165
166 @Override
167 public void setDescription(String description) {
168 this.description = description;
169 }
170
171 @Override
172 public List<YangLeaf> getListOfLeaf() {
173 return listOfLeaf;
174 }
175
176 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530177 public void setListOfLeaf(List<YangLeaf> leafsList) {
178 listOfLeaf = leafsList;
179 }
180
181 @Override
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +0530182 public void addLeaf(YangLeaf leaf) {
183 getListOfLeaf().add(leaf);
184 }
185
186 @Override
187 public List<YangLeafList> getListOfLeafList() {
188 return listOfLeafList;
189 }
190
191 @Override
VinodKumarS-Huawei2ee9e7e2016-06-01 14:30:22 +0530192 public void setListOfLeafList(List<YangLeafList> listOfLeafList) {
193 this.listOfLeafList = listOfLeafList;
194 }
195
196 @Override
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +0530197 public void addLeafList(YangLeafList leafList) {
198 getListOfLeafList().add(leafList);
199 }
200
201 @Override
202 public String getName() {
203 return name;
204 }
205
206 @Override
207 public void setName(String name) {
208 this.name = name;
209 }
210
211 @Override
212 public String getReference() {
213 return reference;
214 }
215
216 @Override
217 public void setReference(String reference) {
218 this.reference = reference;
219 }
220
221 @Override
222 public YangStatusType getStatus() {
223 return status;
224 }
225
226 @Override
227 public void setStatus(YangStatusType status) {
228 this.status = status;
229 }
Vidyashree Ramadeac28b2016-06-20 15:12:43 +0530230
231 @Override
232 public List<YangIfFeature> getIfFeatureList() {
233 return ifFeatureList;
234 }
235
236 @Override
237 public void addIfFeatureList(YangIfFeature ifFeature) {
238 if (getIfFeatureList() == null) {
239 setIfFeatureList(new LinkedList<>());
240 }
241 getIfFeatureList().add(ifFeature);
242 }
243
244 @Override
245 public void setIfFeatureList(List<YangIfFeature> ifFeatureList) {
246 this.ifFeatureList = ifFeatureList;
247 }
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +0530248}