BUG-614: convert RuntimeCodeSpecification 56/7456/1
authorRobert Varga <rovarga@cisco.com>
Wed, 28 May 2014 07:14:33 +0000 (09:14 +0200)
committerRobert Varga <rovarga@cisco.com>
Wed, 28 May 2014 07:14:33 +0000 (09:14 +0200)
This migrates RuntimeCodeSpecification from xtend to Java, increasing
its efficiency.

Change-Id: I00b3ab7f3a47e0d3fc71e55b4bec99364bfa8e5f
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeSpecification.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeSpecification.xtend [deleted file]
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/YangtoolsMappingHelper.java

diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeSpecification.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeSpecification.java
new file mode 100644 (file)
index 0000000..22b6f6f
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.binding.codegen;
+
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+public final class RuntimeCodeSpecification {
+    public final static String DIRECT_PROXY_SUFFIX = "DirectProxy";
+    public final static String INVOKER_SUFFIX = "ListenerInvoker";
+    public final static String ROUTER_SUFFIX = "Router";
+
+    public final static String DELEGATE_FIELD = "_delegate";
+    public final static String ROUTING_TABLE_FIELD_PREFIX = "_routes_";
+
+    private RuntimeCodeSpecification() {
+        throw new UnsupportedOperationException("Utility class");
+    }
+
+    /**
+     * Returns a name for generated interface
+     */
+    private static String getGeneratedName(final Class<? extends Object> cls, final String suffix) {
+        return cls.getName() + "$$Broker$" + suffix;
+    }
+
+    public static String getInvokerName(final Class<? extends NotificationListener> listener) {
+        return getGeneratedName(listener, RuntimeCodeSpecification.INVOKER_SUFFIX);
+    }
+
+    /**
+     * Returns a name for DirectProxy implementation
+     */
+    public static String getDirectProxyName(final Class<? extends RpcService> base) {
+        return getGeneratedName(base, RuntimeCodeSpecification.DIRECT_PROXY_SUFFIX);
+    }
+
+    /**
+     * Returns a name for Router implementation
+     */
+    public static String getRouterName(final Class<? extends RpcService> base) {
+        return getGeneratedName(base, RuntimeCodeSpecification.ROUTER_SUFFIX);
+    }
+
+    /**
+     * Returns a field name for specified routing context
+     */
+    public static String getRoutingTableField(final Class<? extends BaseIdentity> routingContext) {
+        return "_routes_" + routingContext.getSimpleName();
+    }
+}
diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeSpecification.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeSpecification.xtend
deleted file mode 100644 (file)
index c5648ad..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.binding.codegen
-
-import org.opendaylight.yangtools.yang.binding.RpcService
-import org.opendaylight.yangtools.yang.binding.BaseIdentity
-import org.opendaylight.yangtools.yang.binding.NotificationListener
-
-/**
- * 
- * 
- */
-class RuntimeCodeSpecification {
-
-    //public static val PACKAGE_PREFIX = "_gen.";
-
-    public static val DIRECT_PROXY_SUFFIX = "DirectProxy";
-    public static val ROUTER_SUFFIX = "Router";
-    public static val INVOKER_SUFFIX = "ListenerInvoker";
-
-    public static val DELEGATE_FIELD = "_delegate"
-    public static val ROUTING_TABLE_FIELD_PREFIX = "_routes_"
-
-    public static def getInvokerName(Class<? extends NotificationListener> listener) {
-        getGeneratedName(listener, INVOKER_SUFFIX);
-    }
-
-    /**
-     * Returns a name for DirectProxy implementation
-     * 
-     * 
-     */
-    public static def getDirectProxyName(Class<? extends RpcService> base) {
-        getGeneratedName(base, DIRECT_PROXY_SUFFIX);
-    }
-
-    /**
-     * Returns a name for Router implementation
-     * 
-     */
-    public static def getRouterName(Class<? extends RpcService> base) {
-        getGeneratedName(base, ROUTER_SUFFIX);
-    }
-
-    /**
-     * Returns a name for generated interface
-     * 
-     */
-    public static def getGeneratedName(Class<?> cls, String suffix) {
-        '''«cls.name»$$Broker$«suffix»'''.toString()
-    }
-
-    /**
-     * Returns a field name for specified routing context
-     * 
-     */
-    public static def getRoutingTableField(Class<? extends BaseIdentity> routingContext) {
-        return '''_routes_«routingContext.simpleName»'''.toString;
-    }
-}
index 0bc11d9b3547298d321dee112014963f3ff676d2..4ad0bb0558a37bcdd6827fdb0a63c1d047553bba 100644 (file)
@@ -5,18 +5,19 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
-
 package org.opendaylight.controller.sal.binding.codegen;
 
 import java.lang.reflect.Method;
+
 import org.opendaylight.yangtools.yang.binding.Notification;
 
-@SuppressWarnings("all")
-public class YangtoolsMappingHelper {
-  public static boolean isNotificationCallback(final Method it) {
-      return it.getName().startsWith("on") && (it.getParameterTypes().length == 1) &&
-              Notification.class.isAssignableFrom(it.getParameterTypes()[0]);
-  }
+public final class YangtoolsMappingHelper {
+    private YangtoolsMappingHelper() {
+        throw new UnsupportedOperationException("Utility class");
+    }
 
+    public static boolean isNotificationCallback(final Method it) {
+        return it.getName().startsWith("on") && (it.getParameterTypes().length == 1) &&
+                Notification.class.isAssignableFrom(it.getParameterTypes()[0]);
+    }
 }
\ No newline at end of file