sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame^] | 2 | * Copyright 2016-present Open Networking Foundation |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 3 | * |
| 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 | |
| 17 | package org.onosproject.yms.app.ydt; |
| 18 | |
| 19 | import org.onosproject.yangutils.datamodel.YangSchemaNode; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 20 | import org.onosproject.yms.ydt.YdtContext; |
| 21 | |
| 22 | import java.util.ArrayList; |
| 23 | import java.util.List; |
| 24 | |
| 25 | /** |
| 26 | * Manages the application information required for schema nodes defined in |
| 27 | * the module (sub-module). |
| 28 | */ |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 29 | public class ModuleSchemaData implements ModuleAppData { |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 30 | |
| 31 | /* |
| 32 | * Reference for application's root ydtContext. |
| 33 | */ |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 34 | private YdtExtendedContext moduleContext; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 35 | |
| 36 | /* |
| 37 | * Reference for list of nodes with operation type delete. |
| 38 | */ |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 39 | private final List<YdtContext> deleteNodes = new ArrayList<>(); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 40 | |
| 41 | @Override |
| 42 | public List<YdtContext> getDeleteNodes() { |
| 43 | // This suppose to be mutable for YAB |
| 44 | return deleteNodes; |
| 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public void addDeleteNodes(YdtContext deletedNode) { |
| 49 | deleteNodes.add(deletedNode); |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public YdtContext getModuleContext() { |
| 54 | return moduleContext; |
| 55 | } |
| 56 | |
| 57 | @Override |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 58 | public void setModuleContext(YdtExtendedContext moduleContext) { |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 59 | this.moduleContext = moduleContext; |
| 60 | } |
| 61 | |
| 62 | @Override |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 63 | public YangSchemaNode getSchemaNode() { |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 64 | return moduleContext.getYangSchemaNode(); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public YangSchemaNode getRootSchemaNode() { |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 69 | return moduleContext.getYangSchemaNode(); |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 70 | } |
| 71 | } |