Vidyashree Rama | 07c26bb | 2016-07-28 17:33:15 +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.yangutils.datamodel; |
| 18 | |
| 19 | import java.util.LinkedList; |
| 20 | import java.util.List; |
| 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 22 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
| 23 | import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
| 24 | |
| 25 | /** |
| 26 | * Represents data model node to maintain information defined in YANG app-data-structure. |
| 27 | */ |
| 28 | public class YangAppDataStructure implements Parsable { |
| 29 | |
| 30 | /** |
| 31 | * Data structure information. |
| 32 | */ |
| 33 | private YangDataStructure dataStructure; |
| 34 | |
| 35 | /** |
| 36 | * List of key names. |
| 37 | */ |
| 38 | private List<String> keyList; |
| 39 | |
| 40 | /** |
| 41 | * Prefix of app-data-structure. |
| 42 | */ |
| 43 | private String prefix; |
| 44 | |
| 45 | /** |
| 46 | * Returns the YANG data structure information. |
| 47 | * |
| 48 | * @return the YANG data structure information |
| 49 | */ |
| 50 | public YangDataStructure getDataStructure() { |
| 51 | return dataStructure; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Sets the YANG data structure information. |
| 56 | * |
| 57 | * @param dataStructure the YANG data structure to set |
| 58 | */ |
| 59 | public void setDataStructure(YangDataStructure dataStructure) { |
| 60 | this.dataStructure = dataStructure; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Returns the list of key field names. |
| 65 | * |
| 66 | * @return the list of key field names |
| 67 | */ |
| 68 | public List<String> getKeyList() { |
| 69 | return keyList; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Sets the list of key field names. |
| 74 | * |
| 75 | * @param keyList the list of key field names |
| 76 | */ |
| 77 | public void setKeyList(List<String> keyList) { |
| 78 | this.keyList = keyList; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Adds a key field name. |
| 83 | * |
| 84 | * @param key key field name |
| 85 | */ |
| 86 | public void addKey(String key) { |
| 87 | if (getKeyList() == null) { |
| 88 | setKeyList(new LinkedList<>()); |
| 89 | } |
| 90 | getKeyList().add(key); |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Returns the prefix. |
| 95 | * |
| 96 | * @return the prefix |
| 97 | */ |
| 98 | public String getPrefix() { |
| 99 | return prefix; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Sets the prefix information. |
| 104 | * |
| 105 | * @param prefix the prefix to set |
| 106 | */ |
| 107 | public void setPrefix(String prefix) { |
| 108 | this.prefix = prefix; |
| 109 | } |
| 110 | |
| 111 | @Override |
| 112 | public YangConstructType getYangConstructType() { |
| 113 | return YangConstructType.APP_DATA_STRUCTURE; |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | public void validateDataOnEntry() throws DataModelException { |
| 118 | // TODO : to be implemented |
| 119 | } |
| 120 | |
| 121 | @Override |
| 122 | public void validateDataOnExit() throws DataModelException { |
| 123 | // TODO : to be implemented |
| 124 | } |
| 125 | } |