Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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.translator.tojava; |
| 18 | |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 19 | import org.onosproject.yangutils.datamodel.YangType; |
| 20 | |
| 21 | /** |
| 22 | * Maintains the attribute info corresponding to class/interface generated. |
| 23 | */ |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 24 | public class AttributeInfo { |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * The data type info of attribute. |
| 28 | */ |
| 29 | private YangType<?> attrType; |
| 30 | |
| 31 | /** |
| 32 | * Name of the attribute. |
| 33 | */ |
| 34 | private String name; |
| 35 | |
| 36 | /** |
| 37 | * If the added attribute is a list of info. |
| 38 | */ |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 39 | private boolean isListAttr = false; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * If the added attribute has to be accessed in a fully qualified manner. |
| 43 | */ |
Bharat saraswal | 022dae9 | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 44 | private boolean isQualifiedName = false; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 45 | |
| 46 | /** |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 47 | * The class info will be used to set the attribute type and package info |
| 48 | * will be use for qualified name. |
| 49 | */ |
| 50 | private ImportInfo importInfo; |
| 51 | |
| 52 | /** |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 53 | * Default constructor. |
| 54 | */ |
| 55 | public AttributeInfo() { |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Get the data type info of attribute. |
| 60 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 61 | * @return the data type info of attribute |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 62 | */ |
| 63 | public YangType<?> getAttributeType() { |
| 64 | return attrType; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Set the data type info of attribute. |
| 69 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 70 | * @param type the data type info of attribute |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 71 | */ |
| 72 | public void setAttributeType(YangType<?> type) { |
Bharat saraswal | c46ee2a | 2016-02-25 02:26:43 +0530 | [diff] [blame] | 73 | |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 74 | attrType = type; |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Get name of the attribute. |
| 79 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 80 | * @return name of the attribute |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 81 | */ |
| 82 | public String getAttributeName() { |
| 83 | return name; |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Set name of the attribute. |
| 88 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 89 | * @param attrName name of the attribute |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 90 | */ |
| 91 | public void setAttributeName(String attrName) { |
| 92 | name = attrName; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Get if the added attribute is a list of info. |
| 97 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 98 | * @return the if the added attribute is a list of info |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 99 | */ |
| 100 | public boolean isListAttr() { |
| 101 | return isListAttr; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Set if the added attribute is a list of info. |
| 106 | * |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 107 | * @param isList if the added attribute is a list of info |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 108 | */ |
| 109 | public void setListAttr(boolean isList) { |
| 110 | isListAttr = isList; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Get if the added attribute has to be accessed in a fully qualified |
| 115 | * manner. |
| 116 | * |
| 117 | * @return the if the added attribute has to be accessed in a fully |
| 118 | * qualified manner. |
| 119 | */ |
| 120 | public boolean isQualifiedName() { |
| 121 | return isQualifiedName; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Set if the added attribute has to be accessed in a fully qualified |
| 126 | * manner. |
| 127 | * |
| 128 | * @param isQualified if the added attribute has to be accessed in a fully |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 129 | * qualified manner |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 130 | */ |
| 131 | public void setQualifiedName(boolean isQualified) { |
| 132 | isQualifiedName = isQualified; |
| 133 | } |
| 134 | |
Vinod Kumar S | 0871098 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 135 | /** |
| 136 | * Get the import info for the attribute type. It will be null, of the type |
| 137 | * is basic built-in java type. |
| 138 | * |
| 139 | * @return import info |
| 140 | */ |
| 141 | public ImportInfo getImportInfo() { |
| 142 | return importInfo; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Set the import info for the attribute type. |
| 147 | * |
| 148 | * @param importInfo import info for the attribute type |
| 149 | */ |
| 150 | public void setImportInfo(ImportInfo importInfo) { |
| 151 | this.importInfo = importInfo; |
| 152 | } |
| 153 | |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 154 | } |