sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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; |
| 20 | import org.onosproject.yms.app.ydt.exceptions.YdtException; |
| 21 | import org.onosproject.yms.ydt.YdtContext; |
| 22 | |
| 23 | import java.util.ArrayList; |
| 24 | import java.util.List; |
| 25 | |
| 26 | /** |
| 27 | * Manages the application information required for schema nodes defined in |
| 28 | * the module (sub-module). |
| 29 | */ |
| 30 | public class ModuleSchemaData implements AppData { |
| 31 | |
| 32 | private static final String E_NOT_MAINTAINED = |
| 33 | "Augmented info is not maintained."; |
| 34 | |
| 35 | /* |
| 36 | * Reference for application's root ydtContext. |
| 37 | */ |
| 38 | private YdtContext moduleContext; |
| 39 | |
| 40 | /* |
| 41 | * Reference for list of nodes with operation type delete. |
| 42 | */ |
| 43 | private List<YdtContext> deleteNodes = new ArrayList<>(); |
| 44 | |
| 45 | @Override |
| 46 | public List<YdtContext> getDeleteNodes() { |
| 47 | // This suppose to be mutable for YAB |
| 48 | return deleteNodes; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public void addDeleteNodes(YdtContext deletedNode) { |
| 53 | deleteNodes.add(deletedNode); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public YdtContext getModuleContext() { |
| 58 | return moduleContext; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public void setModuleContext(YdtContext moduleContext) { |
| 63 | this.moduleContext = moduleContext; |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public YangSchemaNode getAugmentingSchemaNode() { |
| 68 | throw new YdtException(E_NOT_MAINTAINED); |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public void setAugmentingSchemaNode(YangSchemaNode schemaNode) { |
| 73 | throw new YdtException(E_NOT_MAINTAINED); |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public YangSchemaNode getSchemaNode() { |
| 78 | return ((YdtExtendedContext) moduleContext).getYangSchemaNode(); |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public YangSchemaNode getRootSchemaNode() { |
| 83 | return getSchemaNode(); |
| 84 | } |
| 85 | } |