blob: 6ec7f47929ad4d9924afcadb7679ef848e938e2c [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_MANY_ELEMENTS_ERROR_APP_TAG;
21
22import java.io.Serializable;
23
24/**
25 * Represents max element data represented in YANG.
26 */
27public class YangMaxElement implements YangAppErrorHolder, Serializable {
28
29 private static final long serialVersionUID = 807201694L;
30
31 /**
32 * YANG application error information.
33 */
34 private YangAppErrorInfo yangAppErrorInfo;
35
36 /**
37 * Reference:RFC 6020.
38 *
39 * The "max-elements" statement, which is optional, takes as an argument a
40 * positive integer or the string "unbounded", which puts a constraint on
41 * valid list entries. A valid leaf-list or list always has at most
42 * max-elements entries.
43 *
44 * If no "max-elements" statement is present, it defaults to "unbounded".
45 */
46 private int maxElement = Integer.MAX_VALUE;
47
48 /**
49 * Creates a YANG maximum element.
50 */
51 public YangMaxElement() {
52 YangAppErrorInfo yangAppErrorInfo = new YangAppErrorInfo();
53 yangAppErrorInfo.setErrorTag(OPERATION_FAILED_ERROR_TAG);
54 yangAppErrorInfo.setErrorAppTag(TOO_MANY_ELEMENTS_ERROR_APP_TAG);
55 }
56
57 /**
58 * Returns the maximum element value.
59 *
60 * @return the maximum element value
61 */
62 public int getMaxElement() {
63 return maxElement;
64 }
65
66 /**
67 * Sets the maximum element value.
68 *
69 * @param maxElement the maximum element value
70 */
71 public void setMaxElement(int maxElement) {
72 this.maxElement = maxElement;
73 }
74
75 @Override
76 public void setAppErrorInfo(YangAppErrorInfo yangAppErrorInfo) {
77 this.yangAppErrorInfo = yangAppErrorInfo;
78 }
79
80 @Override
81 public YangAppErrorInfo getAppErrorInfo() {
82 return yangAppErrorInfo;
83 }
84}