blob: 4eab3a835a5b1ddaae4f9236d8c862787ef0913f [file] [log] [blame]
rama-huawei6c728a92016-07-11 14:48:12 +05301/*
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
17package org.onosproject.yangutils.datamodel;
18
19import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.OPERATION_FAILED_ERROR_TAG;
20import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.TOO_FEW_ELEMENTS_ERROR_APP_TAG;
21
22import java.io.Serializable;
23
24/**
25 * Represents minimum element data represented in YANG.
26 */
27public class YangMinElement implements YangAppErrorHolder, Serializable {
28
29 private static final long serialVersionUID = 807201695L;
30
31 /**
32 * YANG application error information.
33 */
34 private YangAppErrorInfo yangAppErrorInfo;
35
36 /**
37 * Reference:RFC 6020.
38 *
39 * The "min-elements" statement, which is optional, takes as an argument a
40 * non-negative integer that puts a constraint on valid list entries. A
41 * valid leaf-list or list MUST have at least min-elements entries.
42 *
43 * If no "min-elements" statement is present, it defaults to zero.
44 *
45 * The behavior of the constraint depends on the type of the leaf-list's or
46 * list's closest ancestor node in the schema tree that is not a non-
47 * presence container:
48 *
49 * If this ancestor is a case node, the constraint is enforced if any
50 * other node from the case exists.
51 *
52 * Otherwise, it is enforced if the ancestor node exists.
53 */
54 private int minElement = 0;
55
56 /**
57 * Creates a YANG minimum element.
58 */
59 public YangMinElement() {
60 YangAppErrorInfo yangAppErrorInfo = new YangAppErrorInfo();
61 yangAppErrorInfo.setErrorTag(OPERATION_FAILED_ERROR_TAG);
62 yangAppErrorInfo.setErrorAppTag(TOO_FEW_ELEMENTS_ERROR_APP_TAG);
63 }
64
65 /**
66 * Returns the minimum element value.
67 *
68 * @return the minimum element value
69 */
70 public int getMinElement() {
71 return minElement;
72 }
73
74 /**
75 * Sets the minimum element value.
76 *
77 * @param minElement the minimum element value
78 */
79 public void setMinElement(int minElement) {
80 this.minElement = minElement;
81 }
82
83 @Override
84 public void setAppErrorInfo(YangAppErrorInfo yangAppErrorInfo) {
85 this.yangAppErrorInfo = yangAppErrorInfo;
86 }
87
88 @Override
89 public YangAppErrorInfo getAppErrorInfo() {
90 return yangAppErrorInfo;
91 }
92}