Merge "Resolve Bug:707 - ConfigPusher should wait for netconf-impl to register JMX...
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / codegen / RuntimeCodeSpecification.xtend
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.sal.binding.codegen
9
10 import org.opendaylight.yangtools.yang.binding.RpcService
11 import org.opendaylight.yangtools.yang.binding.BaseIdentity
12 import org.opendaylight.yangtools.yang.binding.NotificationListener
13
14 /**
15  * 
16  * 
17  */
18 class RuntimeCodeSpecification {
19
20     //public static val PACKAGE_PREFIX = "_gen.";
21
22     public static val DIRECT_PROXY_SUFFIX = "DirectProxy";
23     public static val ROUTER_SUFFIX = "Router";
24     public static val INVOKER_SUFFIX = "ListenerInvoker";
25
26     public static val DELEGATE_FIELD = "_delegate"
27     public static val ROUTING_TABLE_FIELD_PREFIX = "_routes_"
28
29     public static def getInvokerName(Class<? extends NotificationListener> listener) {
30         getGeneratedName(listener, INVOKER_SUFFIX);
31     }
32
33     /**
34      * Returns a name for DirectProxy implementation
35      * 
36      * 
37      */
38     public static def getDirectProxyName(Class<? extends RpcService> base) {
39         getGeneratedName(base, DIRECT_PROXY_SUFFIX);
40     }
41
42     /**
43      * Returns a name for Router implementation
44      * 
45      */
46     public static def getRouterName(Class<? extends RpcService> base) {
47         getGeneratedName(base, ROUTER_SUFFIX);
48     }
49
50     /**
51      * Returns a name for generated interface
52      * 
53      */
54     public static def getGeneratedName(Class<?> cls, String suffix) {
55         '''«cls.name»$$Broker$«suffix»'''.toString()
56     }
57
58     /**
59      * Returns a field name for specified routing context
60      * 
61      */
62     public static def getRoutingTableField(Class<? extends BaseIdentity> routingContext) {
63         return '''_routes_«routingContext.simpleName»'''.toString;
64     }
65 }