blob: c61ce800569ac84daa72fa42e59cc66e6173d691 [file] [log] [blame]
Gaurav Agrawale3ed0d92016-03-23 19:04:17 +05301/*
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
17package org.onosproject.yangutils.datamodel;
18
19import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
20import org.onosproject.yangutils.parser.Parsable;
21import org.onosproject.yangutils.utils.YangConstructType;
22
23import java.util.List;
24
25/*
26 * Reference RFC 6020.
27 *
28 * The union built-in type represents a value that corresponds to one of
29 * its member types.
30 *
31 * When the type is "union", the "type" statement (Section 7.4) MUST be
32 * present. It is used to repeatedly specify each member type of the
33 * union. It takes as an argument a string that is the name of a member
34 * type.
35 *
36 * A member type can be of any built-in or derived type, except it MUST
37 * NOT be one of the built-in types "empty" or "leafref".
38 *
39 * When a string representing a union data type is validated, the string
40 * is validated against each member type, in the order they are
41 * specified in the "type" statement, until a match is found.
42 *
43 * Any default value or "units" property defined in the member types is
44 * not inherited by the union type.
45 */
46
47/**
48 * Data model node to maintain information defined in YANG union.
49 */
50public class YangUnion implements Parsable {
51
52 // List of YANG type.
53 private List<YangType<?>> typeList;
54
55 // Name of the union.
56 private String unionName;
57
58 /**
59 * Create a YANG union node.
60 */
61 public YangUnion() {
62 }
63
64 /**
65 * Returns list of YANG type.
66 *
67 * @return the list of YANG type
68 */
69 public List<YangType<?>> getTypeList() {
70 return typeList;
71 }
72
73 /**
74 * Returns union name.
75 *
76 * @return the union name
77 */
78 public String getUnionName() {
79 return unionName;
80 }
81
82 /**
83 * Set the list of YANG type.
84 *
85 * @param typeList list of YANG type.
86 */
87 public void setTypeList(List<YangType<?>> typeList) {
88 this.typeList = typeList;
89 }
90
91 /**
92 * Set the union name.
93 *
94 * @param unionName name of the union.
95 */
96 public void setUnionName(String unionName) {
97 this.unionName = unionName;
98 }
99
100 @Override
101 public YangConstructType getYangConstructType() {
102 return YangConstructType.UNION_DATA;
103 }
104
105 @Override
106 public void validateDataOnEntry() throws DataModelException {
107 //TODO: implement the method.
108 }
109
110 @Override
111 public void validateDataOnExit() throws DataModelException {
112 //TODO: implement the method.
113 }
114}