Allow rpc definition for RuntimeMXBeans to come from groupings
[controller.git] / opendaylight / config / yang-test / src / main / java / org / opendaylight / controller / config / yang / test / util / NetconfTestImplModuleUtil.java
1
2
3 /*
4  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
5  *
6  * This program and the accompanying materials are made available under the
7  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
8  * and is available at http://www.eclipse.org/legal/epl-v10.html
9  */
10
11 package org.opendaylight.controller.config.yang.test.util;
12
13 import com.google.common.collect.Lists;
14 import java.math.BigInteger;
15 import java.util.List;
16 import org.opendaylight.controller.config.yang.test.impl.Asdf;
17 import org.opendaylight.controller.config.yang.test.impl.Deep2;
18 import org.opendaylight.controller.config.yang.test.impl.Deep3;
19 import org.opendaylight.controller.config.yang.test.impl.Deep4;
20 import org.opendaylight.controller.config.yang.test.impl.InnerInnerRunningDataRuntimeMXBean;
21 import org.opendaylight.controller.config.yang.test.impl.InnerRunningDataAdditionalRuntimeMXBean;
22 import org.opendaylight.controller.config.yang.test.impl.InnerRunningDataRuntimeMXBean;
23 import org.opendaylight.controller.config.yang.test.impl.InnerRunningDataRuntimeRegistration;
24 import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModule;
25 import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplRuntimeMXBean;
26 import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplRuntimeRegistration;
27 import org.opendaylight.controller.config.yang.test.impl.NotStateBean;
28 import org.opendaylight.controller.config.yang.test.impl.RetValContainer;
29 import org.opendaylight.controller.config.yang.test.impl.RetValList;
30
31 public class NetconfTestImplModuleUtil {
32     public static NetconfTestImplRuntimeRegistration registerRuntimeBeans(final NetconfTestImplModule module) {
33         NetconfTestImplRuntimeRegistration reg = module.getRootRuntimeBeanRegistratorWrapper().register(new NetconfTestImplRuntimeMXBean() {
34
35             @Override
36             public Long getCreatedSessions() {
37                 return module.getSimpleLong();
38             }
39
40             @Override
41             public Asdf getAsdf() {
42                 final Asdf asdf = new Asdf();
43                 asdf.setSimpleString("asdf");
44                 return asdf;
45             }
46
47             @Override
48             public BigInteger getCommonStat() {
49                 return new BigInteger("54");
50             }
51
52             @Override
53             public String noArg(final String arg1) {
54                 return arg1.toUpperCase();
55             }
56
57             @Override
58             public Long commonRpcTwo() {
59                 return 1L;
60             }
61
62             @Override
63             public String commonRpcThree() {
64                 return "true";
65             }
66
67             @Override
68             public Boolean commonRpc() {
69                 return true;
70             }
71
72             @Override
73             public void netconfImplRpcFromGrouping() {
74                 // rpc from grouping within same yang module
75             }
76
77         });
78
79         for (int i = 0; i < module.getSimpleShort(); i++) {
80             final int finalI = i;
81
82             reg.register(new InnerRunningDataAdditionalRuntimeMXBean() {
83                 @Override
84                 public Integer getSimpleInt3() {
85                     return module.getSimpleTest();
86                 }
87
88                 @Override
89                 public Deep4 getDeep4() {
90                     final Deep4 d = new Deep4();
91                     d.setBoool(false);
92                     return d;
93                 }
94
95                 @Override
96                 public String getSimpleString() {
97                     return Integer.toString(finalI);
98                 }
99
100                 @Override
101                 public void noArgInner() {
102                 }
103             });
104
105             InnerRunningDataRuntimeRegistration innerReg = reg.register(new InnerRunningDataRuntimeMXBean() {
106                 @Override
107                 public Integer getSimpleInt3() {
108                     return finalI;
109                 }
110
111                 @Override
112                 public Deep2 getDeep2() {
113                     return new Deep2();
114                 }
115             });
116
117             for (int j = 0; j < module.getSimpleShort(); j++) {
118                 final int finalJ = j;
119                 innerReg.register(new InnerInnerRunningDataRuntimeMXBean() {
120                     @Override
121                     public List<NotStateBean> getNotStateBean() {
122                         NotStateBean b1 = new NotStateBean();
123                         b1.setElement("not state");
124                         return Lists.newArrayList(b1);
125                     }
126
127                     @Override
128                     public Integer getSimpleInt3() {
129                         return finalJ;
130                     }
131
132                     @Override
133                     public Deep3 getDeep3() {
134                         return new Deep3();
135                     }
136
137                     @Override
138                     public List<String> getListOfStrings() {
139                         return Lists.newArrayList("l1", "l2");
140                     }
141
142                     @Override
143                     public List<RetValList> listOutput() {
144                         return Lists.newArrayList(new RetValList());
145                     }
146
147                     @Override
148                     public Boolean noArgInnerInner(Integer integer, Boolean aBoolean) {
149                         return aBoolean;
150                     }
151
152                     @Override
153                     public RetValContainer containerOutput() {
154                         return new RetValContainer();
155                     }
156
157                     @Override
158                     public List<String> leafListOutput() {
159                         return Lists.newArrayList("1", "2");
160                     }
161                 });
162             }
163         }
164
165         return reg;
166     }
167 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.