BUG-614: convert RuntimeCodeSpecification
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / codegen / RuntimeCodeSpecification.java
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.BaseIdentity;
11 import org.opendaylight.yangtools.yang.binding.NotificationListener;
12 import org.opendaylight.yangtools.yang.binding.RpcService;
13
14 public final class RuntimeCodeSpecification {
15     public final static String DIRECT_PROXY_SUFFIX = "DirectProxy";
16     public final static String INVOKER_SUFFIX = "ListenerInvoker";
17     public final static String ROUTER_SUFFIX = "Router";
18
19     public final static String DELEGATE_FIELD = "_delegate";
20     public final static String ROUTING_TABLE_FIELD_PREFIX = "_routes_";
21
22     private RuntimeCodeSpecification() {
23         throw new UnsupportedOperationException("Utility class");
24     }
25
26     /**
27      * Returns a name for generated interface
28      */
29     private static String getGeneratedName(final Class<? extends Object> cls, final String suffix) {
30         return cls.getName() + "$$Broker$" + suffix;
31     }
32
33     public static String getInvokerName(final Class<? extends NotificationListener> listener) {
34         return getGeneratedName(listener, RuntimeCodeSpecification.INVOKER_SUFFIX);
35     }
36
37     /**
38      * Returns a name for DirectProxy implementation
39      */
40     public static String getDirectProxyName(final Class<? extends RpcService> base) {
41         return getGeneratedName(base, RuntimeCodeSpecification.DIRECT_PROXY_SUFFIX);
42     }
43
44     /**
45      * Returns a name for Router implementation
46      */
47     public static String getRouterName(final Class<? extends RpcService> base) {
48         return getGeneratedName(base, RuntimeCodeSpecification.ROUTER_SUFFIX);
49     }
50
51     /**
52      * Returns a field name for specified routing context
53      */
54     public static String getRoutingTableField(final Class<? extends BaseIdentity> routingContext) {
55         return "_routes_" + routingContext.getSimpleName();
56     }
57 }

©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.