Gaurav Agrawal | 2779d36 | 2017-02-17 16:10:22 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 72b2df2 | 2017-08-03 18:48:28 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Gaurav Agrawal | 2779d36 | 2017-02-17 16:10:22 +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.yang.model; |
| 18 | |
| 19 | import java.util.LinkedList; |
| 20 | import java.util.List; |
| 21 | |
| 22 | /** |
| 23 | * Representation of an entity that provides common basis to specify atomic |
| 24 | * model. |
| 25 | */ |
| 26 | public final class LeafModelObject extends ModelObject { |
| 27 | |
| 28 | private LeafIdentifier leafIdentifier; |
| 29 | private List<Object> values; |
| 30 | |
| 31 | /** |
| 32 | * Creates an instance of leaf model object. |
| 33 | */ |
| 34 | public LeafModelObject() { |
| 35 | super(ModelObjectType.ATOMIC); |
| 36 | values = new LinkedList<>(); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Returns leaf identifier. |
| 41 | * |
| 42 | * @return leaf identifier |
| 43 | */ |
| 44 | public LeafIdentifier leafIdentifier() { |
| 45 | return leafIdentifier; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Sets leaf identifier. |
| 50 | * |
| 51 | * @param id leaf identifier |
| 52 | */ |
| 53 | public void leafIdentifier(LeafIdentifier id) { |
| 54 | leafIdentifier = id; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Returns value of leaf, it will be single value for leaf and can be |
| 59 | * single or list for leaf-list. |
| 60 | * |
| 61 | * @return value(s) |
| 62 | */ |
| 63 | public List<Object> values() { |
| 64 | return values; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Sets list of values. For leaf it will always be single value. |
| 69 | * |
| 70 | * @param v value(s) |
| 71 | */ |
| 72 | public void values(List<Object> v) { |
| 73 | values = v; |
| 74 | } |
Vidyashree Rama | a5ba656 | 2017-03-08 11:23:28 +0530 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | * Adds value to list. |
| 78 | * |
| 79 | * @param v value |
| 80 | */ |
| 81 | public void addValue(Object v) { |
| 82 | values.add(v); |
| 83 | } |
Gaurav Agrawal | 2779d36 | 2017-02-17 16:10:22 +0530 | [diff] [blame] | 84 | } |