--- /dev/null
+/*
+ * 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 com.google.common.base.Objects;
+import java.lang.reflect.Field;
+import java.util.Map;
+import org.eclipse.xtext.xbase.lib.Exceptions;
+import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeSpecification;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
+
+@SuppressWarnings("all")
+public class RuntimeCodeHelper {
+ /**
+ * Helper method to return delegate from ManagedDirectedProxy with use of reflection.
+ *
+ * Note: This method uses reflection, but access to delegate field should be
+ * avoided and called only if neccessary.
+ */
+ public static <T extends RpcService> T getDelegate(final RpcService proxy) {
+ try {
+ Class<? extends RpcService> _class = proxy.getClass();
+ final Field field = _class.getField(RuntimeCodeSpecification.DELEGATE_FIELD);
+ boolean _equals = Objects.equal(field, null);
+ if (_equals) {
+ UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException("Unable to get delegate from proxy");
+ throw _unsupportedOperationException;
+ }
+ try {
+ Object _get = field.get(proxy);
+ return ((T) _get);
+ } catch (Throwable _e) {
+ throw Exceptions.sneakyThrow(_e);
+ }
+ } catch (Throwable _e_1) {
+ throw Exceptions.sneakyThrow(_e_1);
+ }
+ }
+
+ /**
+ * Helper method to set delegate to ManagedDirectedProxy with use of reflection.
+ *
+ * Note: This method uses reflection, but setting delegate field should not occur too much
+ * to introduce any significant performance hits.
+ */
+ public static void setDelegate(final RpcService proxy, final RpcService delegate) {
+ try {
+ Class<? extends RpcService> _class = proxy.getClass();
+ final Field field = _class.getField(RuntimeCodeSpecification.DELEGATE_FIELD);
+ boolean _equals = Objects.equal(field, null);
+ if (_equals) {
+ UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException("Unable to set delegate to proxy");
+ throw _unsupportedOperationException;
+ }
+ boolean _or = false;
+ boolean _equals_1 = Objects.equal(delegate, null);
+ if (_equals_1) {
+ _or = true;
+ } else {
+ Class<? extends Object> _type = field.getType();
+ Class<? extends RpcService> _class_1 = delegate.getClass();
+ boolean _isAssignableFrom = _type.isAssignableFrom(_class_1);
+ _or = (_equals_1 || _isAssignableFrom);
+ }
+ if (_or) {
+ field.set(proxy, delegate);
+ } else {
+ IllegalArgumentException _illegalArgumentException = new IllegalArgumentException("delegate class is not assignable to proxy");
+ throw _illegalArgumentException;
+ }
+ } catch (Throwable _e) {
+ throw Exceptions.sneakyThrow(_e);
+ }
+ }
+
+ /**
+ * Helper method to set delegate to ManagedDirectedProxy with use of reflection.
+ *
+ * Note: This method uses reflection, but setting delegate field should not occur too much
+ * to introduce any significant performance hits.
+ */
+ public static void setDelegate(final Object proxy, final Object delegate) {
+ try {
+ Class<? extends Object> _class = proxy.getClass();
+ final Field field = _class.getField(RuntimeCodeSpecification.DELEGATE_FIELD);
+ boolean _equals = Objects.equal(field, null);
+ if (_equals) {
+ UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException("Unable to set delegate to proxy");
+ throw _unsupportedOperationException;
+ }
+ boolean _or = false;
+ boolean _equals_1 = Objects.equal(delegate, null);
+ if (_equals_1) {
+ _or = true;
+ } else {
+ Class<? extends Object> _type = field.getType();
+ Class<? extends Object> _class_1 = delegate.getClass();
+ boolean _isAssignableFrom = _type.isAssignableFrom(_class_1);
+ _or = (_equals_1 || _isAssignableFrom);
+ }
+ if (_or) {
+ field.set(proxy, delegate);
+ } else {
+ IllegalArgumentException _illegalArgumentException = new IllegalArgumentException("delegate class is not assignable to proxy");
+ throw _illegalArgumentException;
+ }
+ } catch (Throwable _e) {
+ throw Exceptions.sneakyThrow(_e);
+ }
+ }
+
+ public static Map<InstanceIdentifier<? extends Object>,? extends RpcService> getRoutingTable(final RpcService target, final Class<? extends BaseIdentity> tableClass) {
+ try {
+ Class<? extends RpcService> _class = target.getClass();
+ String _routingTableField = RuntimeCodeSpecification.getRoutingTableField(tableClass);
+ final Field field = _class.getField(_routingTableField);
+ boolean _equals = Objects.equal(field, null);
+ if (_equals) {
+ UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException(
+ "Unable to get routing table. Table field does not exists");
+ throw _unsupportedOperationException;
+ }
+ try {
+ Object _get = field.get(target);
+ return ((Map<InstanceIdentifier<? extends Object>,? extends RpcService>) _get);
+ } catch (Throwable _e) {
+ throw Exceptions.sneakyThrow(_e);
+ }
+ } catch (Throwable _e_1) {
+ throw Exceptions.sneakyThrow(_e_1);
+ }
+ }
+
+ public static void setRoutingTable(final RpcService target, final Class<? extends BaseIdentity> tableClass, final Map<InstanceIdentifier<? extends Object>,? extends RpcService> routingTable) {
+ try {
+ Class<? extends RpcService> _class = target.getClass();
+ String _routingTableField = RuntimeCodeSpecification.getRoutingTableField(tableClass);
+ final Field field = _class.getField(_routingTableField);
+ boolean _equals = Objects.equal(field, null);
+ if (_equals) {
+ UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException(
+ "Unable to set routing table. Table field does not exists");
+ throw _unsupportedOperationException;
+ }
+ field.set(target, routingTable);
+ } catch (Throwable _e) {
+ throw Exceptions.sneakyThrow(_e);
+ }
+ }
+}
\ No newline at end of file
+++ /dev/null
-/*
- * 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 java.util.Map
-
-import org.opendaylight.yangtools.yang.binding.BaseIdentity
-import org.opendaylight.yangtools.yang.binding.RpcService
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-
-import static extension org.opendaylight.controller.sal.binding.codegen.RuntimeCodeSpecification.*
-
-class RuntimeCodeHelper {
- /**
- * Helper method to return delegate from ManagedDirectedProxy with use of reflection.
- *
- * Note: This method uses reflection, but access to delegate field should be
- * avoided and called only if neccessary.
- *
- */
- public static def <T extends RpcService> getDelegate(RpcService proxy) {
- val field = proxy.class.getField(DELEGATE_FIELD)
- if (field == null) throw new UnsupportedOperationException("Unable to get delegate from proxy");
- return field.get(proxy) as T
- }
-
- /**
- * Helper method to set delegate to ManagedDirectedProxy with use of reflection.
- *
- * Note: This method uses reflection, but setting delegate field should not occur too much
- * to introduce any significant performance hits.
- *
- */
- public static def void setDelegate(RpcService proxy, RpcService delegate) {
- val field = proxy.class.getField(DELEGATE_FIELD)
- if (field == null) throw new UnsupportedOperationException("Unable to set delegate to proxy");
- if (delegate == null || field.type.isAssignableFrom(delegate.class)) {
- field.set(proxy, delegate)
- } else
- throw new IllegalArgumentException("delegate class is not assignable to proxy");
- }
-
- /**
- * Helper method to set delegate to ManagedDirectedProxy with use of reflection.
- *
- * Note: This method uses reflection, but setting delegate field should not occur too much
- * to introduce any significant performance hits.
- *
- */
- public static def void setDelegate(Object proxy, Object delegate) {
- val field = proxy.class.getField(DELEGATE_FIELD)
- if (field == null) throw new UnsupportedOperationException("Unable to set delegate to proxy");
- if (delegate == null || field.type.isAssignableFrom(delegate.class)) {
- field.set(proxy, delegate)
- } else
- throw new IllegalArgumentException("delegate class is not assignable to proxy");
- }
-
-
- public static def Map<InstanceIdentifier<?>, ? extends RpcService> getRoutingTable(RpcService target,
- Class<? extends BaseIdentity> tableClass) {
- val field = target.class.getField(tableClass.routingTableField)
- if (field == null) throw new UnsupportedOperationException(
- "Unable to get routing table. Table field does not exists");
- return field.get(target) as Map<InstanceIdentifier<? extends Object>, ? extends RpcService>;
- }
-
- public static def void setRoutingTable(RpcService target, Class<? extends BaseIdentity> tableClass,
- Map<InstanceIdentifier<?>, ? extends RpcService> routingTable) {
- val field = target.class.getField(tableClass.routingTableField)
- if (field == null) throw new UnsupportedOperationException(
- "Unable to set routing table. Table field does not exists");
- field.set(target,routingTable);
- }
-
-}
--- /dev/null
+/*
+ * 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 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]);
+ }
+
+}
\ No newline at end of file
+++ /dev/null
-/*
- * 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 java.lang.reflect.Method
-import org.opendaylight.yangtools.yang.binding.Notification
-
-public static class YangtoolsMappingHelper {
-
- public static def boolean isNotificationCallback(Method it) {
- return name.startsWith("on") && parameterTypes.size === 1 &&
- Notification.isAssignableFrom(parameterTypes.get(0))
- }
-}
--- /dev/null
+/*
+ * 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.impl;
+
+import org.eclipse.xtext.xbase.lib.Exceptions;
+
+@SuppressWarnings("all")
+public class BrokerImplClassLoader extends ClassLoader {
+ private final ClassLoader spiClassLoader;
+
+ public BrokerImplClassLoader(final ClassLoader model, final ClassLoader spi) {
+ super(model);
+ this.spiClassLoader = spi;
+ }
+
+ public Class<? extends Object> loadClass(final String name) throws ClassNotFoundException {
+ try {
+ return super.loadClass(name);
+ } catch (ClassNotFoundException e) {
+ return this.spiClassLoader.loadClass(name);
+ }
+ }
+}
+++ /dev/null
-/*
- * 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.impl
-
-import java.lang.ClassLoader
-
-class BrokerImplClassLoader extends ClassLoader {
-
- val ClassLoader spiClassLoader
-
- public new(ClassLoader model, ClassLoader spi) {
- super(model)
- spiClassLoader = spi;
- }
-
- override public loadClass(String name) throws ClassNotFoundException {
- try {
- return super.loadClass(name);
- } catch (ClassNotFoundException e) {
- return spiClassLoader.loadClass(name);
- }
- }
-
-}
--- /dev/null
+/*
+ * 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.impl;
+
+import org.opendaylight.yangtools.yang.binding.RpcService;
+import org.osgi.framework.ServiceRegistration;
+
+@SuppressWarnings("all")
+public class RpcProxyContext {
+ public RpcProxyContext(final Class<? extends RpcService> proxyClass) {
+ this.proxyClass = proxyClass;
+ }
+
+ protected final Class<? extends RpcService> proxyClass;
+
+ protected RpcService _proxy;
+
+ public RpcService getProxy() {
+ return this._proxy;
+ }
+
+ public void setProxy(final RpcService proxy) {
+ this._proxy = proxy;
+ }
+
+ protected ServiceRegistration<? extends RpcService> _registration;
+
+ public ServiceRegistration<? extends RpcService> getRegistration() {
+ return this._registration;
+ }
+
+ public void setRegistration(final ServiceRegistration<? extends RpcService> registration) {
+ this._registration = registration;
+ }
+}
\ No newline at end of file
+++ /dev/null
-/*
- * 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.impl
-
-import org.opendaylight.yangtools.yang.binding.RpcService
-import org.osgi.framework.ServiceRegistration
-
-class RpcProxyContext {
-
- new(Class<? extends RpcService> proxyClass) {
- this.proxyClass = proxyClass
- }
-
- protected val Class<? extends RpcService> proxyClass;
-
- @Property
- protected var RpcService proxy;
-
- @Property
- protected var ServiceRegistration<? extends RpcService> registration;
-}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2014 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.impl.util;
+
+import java.util.Iterator;
+import org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+@SuppressWarnings("all")
+public class BindingAwareDataReaderRouter extends AbstractDataReadRouter<InstanceIdentifier<? extends DataObject>,DataObject> {
+ protected DataObject merge(final InstanceIdentifier<? extends DataObject> path, final Iterable<DataObject> data) {
+ return data.iterator().next();
+ }
+}
+++ /dev/null
-/*
- * Copyright (c) 2014 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.impl.util
-
-import org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
-import org.opendaylight.yangtools.yang.binding.DataObject
-
-class BindingAwareDataReaderRouter extends AbstractDataReadRouter<InstanceIdentifier<? extends DataObject>, DataObject> {
-
- override protected merge(InstanceIdentifier<? extends DataObject> path, Iterable<DataObject> data) {
- return data.iterator.next;
- }
-
-}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.impl.util;
+
+import com.google.common.collect.Multimap;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map.Entry;
+import org.opendaylight.yangtools.concepts.Path;
+
+@SuppressWarnings("all")
+public class MapUtils {
+ public static <P extends Path<P>, V extends Object> Collection<Entry<? extends P,? extends V>> getAllChildren(final Multimap<? extends P,? extends V> map, final P path) {
+ HashSet<Entry<? extends P,? extends V>> _hashSet = new HashSet<Entry<? extends P, ? extends V>>();
+ final HashSet<Entry<? extends P,? extends V>> ret = _hashSet;
+ final Collection<? extends Entry<? extends P,? extends V>> entries = map.entries();
+ for (final Entry<? extends P,? extends V> entry : entries) {
+ {
+ final P currentPath = entry.getKey();
+ if (path.contains(currentPath)) {
+ ret.add(entry);
+ } else if (currentPath.contains(path)){
+ ret.add(entry);
+ }
+ }
+ }
+ return ret;
+ }
+}
+
+++ /dev/null
-/*
- * Copyright (c) 2014 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.impl.util
-
-import com.google.common.collect.Multimap
-import java.util.Collection
-import java.util.HashSet
-import java.util.Map.Entry
-import org.opendaylight.yangtools.concepts.Path
-
-class MapUtils {
-
- public static def <P extends Path<P>, V> Collection<Entry<? extends P, ? extends V>> getAllChildren(
- Multimap<? extends P, ? extends V> map, P path) {
- val ret = new HashSet();
- val entries = map.entries;
-
- for (entry : entries) {
- val currentPath = entry.key;
- // If the registered reader processes nested elements
- if (path.contains(currentPath)) {
- ret.add(entry);
- } else if(currentPath.contains(path)) {
- // If the registered reader is parent of entry
- ret.add(entry);
- }
- }
-
- return ret;
- }
-}