Bug 4035: Fixed some sonar warnings in md.sal.binding.impl 13/19213/11
authorTony Tkacik <ttkacik@cisco.com>
Tue, 28 Apr 2015 13:41:05 +0000 (15:41 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Wed, 19 Aug 2015 12:10:57 +0000 (14:10 +0200)
Change-Id: I7b850b65a7bfc40ef757115ae37a031fa88bebeb
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
17 files changed:
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenDataBrokerAdapter.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenDataChangeEvent.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/HydrogenNotificationBrokerImpl.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationInvoker.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotifyTask.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMAdapterLoader.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcServiceAdapter.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMTransactionChainAdapter.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMWriteTransactionAdapter.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ContextReferenceExtractor.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataObjectModification.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/spi/AdapterLoader.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RootBindingAwareBroker.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/ForwardedBackwardsCompatibleDataBrokerTest.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingTestContext.java

index 0ac8f69..da6859b 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
@@ -57,7 +58,8 @@ public class HydrogenDataBrokerAdapter implements DataProviderService, AutoClose
 
     private static final Logger LOG = LoggerFactory.getLogger(HydrogenDataBrokerAdapter.class);
 
-    private final ConcurrentHashMap<InstanceIdentifier<?>, CommitHandlerRegistrationImpl> commitHandlers = new ConcurrentHashMap<>();
+    private final ConcurrentMap<InstanceIdentifier<?>, CommitHandlerRegistrationImpl> commitHandlers =
+            new ConcurrentHashMap<>();
     private final ListeningExecutorService executorService = SingletonHolder.getDefaultCommitExecutor();
 
     private final DataBroker delegate;
@@ -74,13 +76,13 @@ public class HydrogenDataBrokerAdapter implements DataProviderService, AutoClose
 
     @Override
     public DataObject readConfigurationData(final InstanceIdentifier<? extends DataObject> path) {
-        DataModificationTransaction tx = beginTransaction();
+        final DataModificationTransaction tx = beginTransaction();
         return tx.readConfigurationData(path);
     }
 
     @Override
     public DataObject readOperationalData(final InstanceIdentifier<? extends DataObject> path) {
-        DataModificationTransaction tx = beginTransaction();
+        final DataModificationTransaction tx = beginTransaction();
         return tx.readOperationalData(path);
     }
 
@@ -88,7 +90,7 @@ public class HydrogenDataBrokerAdapter implements DataProviderService, AutoClose
     public Registration registerCommitHandler(
             final InstanceIdentifier<? extends DataObject> path,
             final DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> commitHandler) {
-        CommitHandlerRegistrationImpl reg = new CommitHandlerRegistrationImpl(path, commitHandler);
+        final CommitHandlerRegistrationImpl reg = new CommitHandlerRegistrationImpl(path, commitHandler);
         commitHandlers.put(path, reg);
         return reg;
     }
@@ -105,11 +107,11 @@ public class HydrogenDataBrokerAdapter implements DataProviderService, AutoClose
             final InstanceIdentifier<? extends DataObject> path, final DataChangeListener listener) {
 
 
-        org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncOperListener = new BackwardsCompatibleOperationalDataChangeInvoker(listener);
-        org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncCfgListener = new BackwardsCompatibleConfigurationDataChangeInvoker(listener);
+        final org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncOperListener = new BackwardsCompatibleOperationalDataChangeInvoker(listener);
+        final org.opendaylight.controller.md.sal.binding.api.DataChangeListener asyncCfgListener = new BackwardsCompatibleConfigurationDataChangeInvoker(listener);
 
-        ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> cfgReg = delegate.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, asyncCfgListener, DataChangeScope.SUBTREE);
-        ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> operReg = delegate.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, path, asyncOperListener, DataChangeScope.SUBTREE);
+        final ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> cfgReg = delegate.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, path, asyncCfgListener, DataChangeScope.SUBTREE);
+        final ListenerRegistration<org.opendaylight.controller.md.sal.binding.api.DataChangeListener> operReg = delegate.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, path, asyncOperListener, DataChangeScope.SUBTREE);
 
         return new LegacyListenerRegistration(listener,cfgReg,operReg);
     }
@@ -125,20 +127,20 @@ public class HydrogenDataBrokerAdapter implements DataProviderService, AutoClose
 
         final List<DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject>> subTrans = new ArrayList<>();
         LOG.debug("Tx: {} Submitted.",tx.getIdentifier());
-        ListenableFuture<Boolean> requestCommit = executorService.submit(new Callable<Boolean>() {
+        final ListenableFuture<Boolean> requestCommit = executorService.submit(new Callable<Boolean>() {
 
             @Override
             public Boolean call() throws Exception {
                 try {
-                    for (CommitHandlerRegistrationImpl handler : commitHandlers.values()) {
+                    for (final CommitHandlerRegistrationImpl handler : commitHandlers.values()) {
 
-                        DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> subTx = handler
+                        final DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> subTx = handler
                                 .getInstance().requestCommit(tx);
                         subTrans.add(subTx);
                     }
-                } catch (Exception e) {
+                } catch (final Exception e) {
                     LOG.error("Tx: {} Rollback.",tx.getIdentifier(),e);
-                    for (DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> subTx : subTrans) {
+                    for (final DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> subTx : subTrans) {
                         subTx.rollback();
                     }
                     return false;
@@ -149,7 +151,7 @@ public class HydrogenDataBrokerAdapter implements DataProviderService, AutoClose
 
         });
 
-        ListenableFuture<RpcResult<TransactionStatus>> dataStoreCommit = Futures.transform(requestCommit, new AsyncFunction<Boolean, RpcResult<TransactionStatus>>() {
+        final ListenableFuture<RpcResult<TransactionStatus>> dataStoreCommit = Futures.transform(requestCommit, new AsyncFunction<Boolean, RpcResult<TransactionStatus>>() {
 
             @Override
             public ListenableFuture<RpcResult<TransactionStatus>> apply(final Boolean requestCommitSuccess) throws Exception {
@@ -164,12 +166,12 @@ public class HydrogenDataBrokerAdapter implements DataProviderService, AutoClose
             @Override
             public RpcResult<TransactionStatus> apply(final RpcResult<TransactionStatus> input) {
                 if(input.isSuccessful()) {
-                    for(DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> subTx : subTrans ) {
+                    for(final DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> subTx : subTrans ) {
                         subTx.finish();
                     }
                 } else {
                     LOG.error("Tx: {} Rollback - Datastore commit failed.",tx.getIdentifier());
-                    for(DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> subTx : subTrans ) {
+                    for(final DataCommitTransaction<InstanceIdentifier<? extends DataObject>, DataObject> subTx : subTrans ) {
                         subTx.rollback();
                     }
                 }
@@ -206,7 +208,7 @@ public class HydrogenDataBrokerAdapter implements DataProviderService, AutoClose
 
         @Override
         public void putOperationalData(final InstanceIdentifier<? extends DataObject> path, final DataObject data) {
-            boolean previouslyRemoved = posponedRemovedOperational.remove(path);
+            final boolean previouslyRemoved = posponedRemovedOperational.remove(path);
 
             @SuppressWarnings({ "rawtypes", "unchecked" })
             final InstanceIdentifier<DataObject> castedPath = (InstanceIdentifier) path;
@@ -219,8 +221,8 @@ public class HydrogenDataBrokerAdapter implements DataProviderService, AutoClose
 
         @Override
         public void putConfigurationData(final InstanceIdentifier<? extends DataObject> path, final DataObject data) {
-            boolean previouslyRemoved = posponedRemovedConfiguration.remove(path);
-            DataObject originalObj = readConfigurationData(path);
+            final boolean previouslyRemoved = posponedRemovedConfiguration.remove(path);
+            final DataObject originalObj = readConfigurationData(path);
             if (originalObj != null) {
                 original.put(path, originalObj);
 
@@ -311,10 +313,10 @@ public class HydrogenDataBrokerAdapter implements DataProviderService, AutoClose
             LOG.trace("Transaction {} changed status to {}", getIdentifier(), status);
             this.status = status;
 
-            for(ListenerRegistration<DataTransactionListener> listener : listeners) {
+            for(final ListenerRegistration<DataTransactionListener> listener : listeners) {
                 try {
                     listener.getInstance().onStatusUpdated(this, status);
-                } catch (Exception e) {
+                } catch (final Exception e) {
                     LOG.error("Error during invoking transaction listener {}",listener.getInstance(),e);
                 }
             }
@@ -323,11 +325,11 @@ public class HydrogenDataBrokerAdapter implements DataProviderService, AutoClose
         @Override
         public ListenableFuture<RpcResult<TransactionStatus>> commit() {
 
-            for(InstanceIdentifier<? extends DataObject> path : posponedRemovedConfiguration) {
+            for(final InstanceIdentifier<? extends DataObject> path : posponedRemovedConfiguration) {
                 delegate.delete(LogicalDatastoreType.CONFIGURATION, path);
             }
 
-            for(InstanceIdentifier<? extends DataObject> path : posponedRemovedOperational) {
+            for(final InstanceIdentifier<? extends DataObject> path : posponedRemovedOperational) {
                 delegate.delete(LogicalDatastoreType.OPERATIONAL, path);
             }
 
@@ -423,7 +425,7 @@ public class HydrogenDataBrokerAdapter implements DataProviderService, AutoClose
         @Override
         public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
 
-            DataChangeEvent legacyChange = HydrogenDataChangeEvent.createOperational(change);
+            final DataChangeEvent legacyChange = HydrogenDataChangeEvent.createOperational(change);
             delegate.onDataChanged(legacyChange);
 
         }
@@ -446,7 +448,7 @@ public class HydrogenDataBrokerAdapter implements DataProviderService, AutoClose
         @Override
         public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
 
-            DataChangeEvent legacyChange = HydrogenDataChangeEvent.createConfiguration(change);
+            final DataChangeEvent legacyChange = HydrogenDataChangeEvent.createConfiguration(change);
 
             delegate.onDataChanged(legacyChange);
 
index e2b838e..8f50d0a 100644 (file)
@@ -11,7 +11,6 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
-
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
 import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -95,7 +94,7 @@ public abstract class HydrogenDataChangeEvent implements
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
-    private final static class OperationalChangeEvent extends HydrogenDataChangeEvent {
+    private static final class OperationalChangeEvent extends HydrogenDataChangeEvent {
 
         private final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> delegate;
         private Map<InstanceIdentifier<?>, DataObject> updatedCache;
@@ -132,9 +131,10 @@ public abstract class HydrogenDataChangeEvent implements
         @Override
         public Map<InstanceIdentifier<?>, DataObject> getUpdatedOperationalData() {
             if(updatedCache == null) {
-                Map<InstanceIdentifier<?>, DataObject> created = delegate.getCreatedData();
-                Map<InstanceIdentifier<?>, DataObject> updated = delegate.getUpdatedData();
-                HashMap<InstanceIdentifier<?>, DataObject> updatedComposite = new HashMap<>(created.size() + updated.size());
+                final Map<InstanceIdentifier<?>, DataObject> created = delegate.getCreatedData();
+                final Map<InstanceIdentifier<?>, DataObject> updated = delegate.getUpdatedData();
+                final Map<InstanceIdentifier<?>, DataObject> updatedComposite =
+                        new HashMap<>(created.size() + updated.size());
                 updatedComposite.putAll(created);
                 updatedComposite.putAll(updated);
                 updatedCache = Collections.unmodifiableMap(updatedComposite);
@@ -150,7 +150,7 @@ public abstract class HydrogenDataChangeEvent implements
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
-    private final static class ConfigurationChangeEvent extends HydrogenDataChangeEvent {
+    private static final class ConfigurationChangeEvent extends HydrogenDataChangeEvent {
 
         private final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> delegate;
         private Map<InstanceIdentifier<?>, DataObject> updatedCache;
@@ -187,9 +187,10 @@ public abstract class HydrogenDataChangeEvent implements
         @Override
         public Map<InstanceIdentifier<?>, DataObject> getUpdatedConfigurationData() {
             if(updatedCache == null) {
-                Map<InstanceIdentifier<?>, DataObject> created = delegate.getCreatedData();
-                Map<InstanceIdentifier<?>, DataObject> updated = delegate.getUpdatedData();
-                HashMap<InstanceIdentifier<?>, DataObject> updatedComposite = new HashMap<>(created.size() + updated.size());
+                final Map<InstanceIdentifier<?>, DataObject> created = delegate.getCreatedData();
+                final Map<InstanceIdentifier<?>, DataObject> updated = delegate.getUpdatedData();
+                final Map<InstanceIdentifier<?>, DataObject> updatedComposite =
+                        new HashMap<>(created.size() + updated.size());
                 updatedComposite.putAll(created);
                 updatedComposite.putAll(updated);
                 updatedCache = Collections.unmodifiableMap(updatedComposite);
index b746020..90e9484 100644 (file)
@@ -53,7 +53,7 @@ public class HydrogenNotificationBrokerImpl implements NotificationProviderServi
         return HashMultimap.create(listeners.get().getListeners());
     }
 
-    private final void addRegistrations(final NotificationListenerRegistration<?>... registrations) {
+    private void addRegistrations(final NotificationListenerRegistration<?>... registrations) {
         synchronized (this) {
             final Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> newListeners =
                     mutableListeners();
index cdc6315..f98c8b8 100644 (file)
@@ -30,7 +30,7 @@ final class NotificationInvoker implements org.opendaylight.controller.sal.bindi
         delegate = listener;
         final Map<Class<? extends Notification>, InvokerContext> builder = new HashMap<>();
         for(final TypeToken<?> ifaceToken : TypeToken.of(listener.getClass()).getTypes().interfaces()) {
-            Class<?> iface = ifaceToken.getRawType();
+            final Class<?> iface = ifaceToken.getRawType();
             if(NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
                 @SuppressWarnings("unchecked")
                 final Class<? extends NotificationListener> listenerType = (Class<? extends NotificationListener>) iface;
@@ -54,7 +54,7 @@ final class NotificationInvoker implements org.opendaylight.controller.sal.bindi
     @Override
     public void onNotification(final Notification notification) {
         getContext(notification.getImplementedInterface()).invoke(notification);
-    };
+    }
 
     private InvokerContext getContext(final Class<?> type) {
         return invokers.get(type);
@@ -74,7 +74,7 @@ final class NotificationInvoker implements org.opendaylight.controller.sal.bindi
         return ret;
     }
 
-    private class InvokerContext {
+    private final class InvokerContext {
 
         private final QName name;
         private final NotificationListenerInvoker invoker;
index 345ec62..59be9af 100644 (file)
@@ -7,13 +7,12 @@
  */
 package org.opendaylight.controller.md.sal.binding.compat;
 
+import com.google.common.base.Objects;
+import com.google.common.base.Preconditions;
 import org.opendaylight.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Objects;
-import com.google.common.base.Preconditions;
-
 class NotifyTask implements Runnable {
     private static final Logger LOG = LoggerFactory.getLogger(NotifyTask.class);
 
@@ -62,23 +61,30 @@ class NotifyTask implements Runnable {
 
     @Override
     public boolean equals(final Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
-        NotifyTask other = (NotifyTask) obj;
+        }
+        final NotifyTask other = (NotifyTask) obj;
         if (registration == null) {
-            if (other.registration != null)
+            if (other.registration != null) {
                 return false;
-        } else if (!registration.equals(other.registration))
+            }
+        } else if (!registration.equals(other.registration)) {
             return false;
+        }
         if (notification == null) {
-            if (other.notification != null)
+            if (other.notification != null) {
                 return false;
-        } else if (!notification.equals(other.notification))
+            }
+        } else if (!notification.equals(other.notification)) {
             return false;
+        }
         return true;
     }
 
index 175dbb6..96108ee 100644 (file)
@@ -38,8 +38,7 @@ public abstract class BindingDOMAdapterLoader extends AdapterLoader<BindingServi
     }
 
     @Override
-    protected final AdapterBuilder<? extends BindingService, DOMService> createBuilder(final Class<? extends BindingService> key)
-            throws IllegalArgumentException {
+    protected final AdapterBuilder<? extends BindingService, DOMService> createBuilder(final Class<? extends BindingService> key) {
         final Factory<?> factory = FACTORIES.get(key);
         Preconditions.checkArgument(factory != null, "Unsupported service type %s", key);
         final BindingDOMAdapterBuilder<?> builder = factory.newBuilder();
index 90d9145..8ebc5e6 100644 (file)
@@ -52,13 +52,11 @@ public class BindingDOMRpcServiceAdapter implements RpcConsumerRegistry {
         this.codec = codec;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public <T extends RpcService> T getRpcService(final Class<T> rpcService) {
         Preconditions.checkArgument(rpcService != null, "Rpc Service needs to be specied.");
-        @SuppressWarnings("unchecked")
-        final
-        T proxy = (T) proxies.getUnchecked(rpcService).getProxy();
-        return proxy;
+        return (T) proxies.getUnchecked(rpcService).getProxy();
     }
 
     private RpcServiceAdapter createProxy(final Class<? extends RpcService> key) {
index 1a0787e..4dc55d2 100644 (file)
@@ -53,15 +53,14 @@ final class BindingDOMTransactionChainAdapter implements BindingTransactionChain
 
     @Override
     public ReadOnlyTransaction newReadOnlyTransaction() {
-        DOMDataReadOnlyTransaction delegateTx = delegate.newReadOnlyTransaction();
-        ReadOnlyTransaction bindingTx = new BindingDOMReadTransactionAdapter(delegateTx, codec);
-        return bindingTx;
+        final DOMDataReadOnlyTransaction delegateTx = delegate.newReadOnlyTransaction();
+        return new BindingDOMReadTransactionAdapter(delegateTx, codec);
     }
 
     @Override
     public ReadWriteTransaction newReadWriteTransaction() {
-        DOMDataReadWriteTransaction delegateTx = delegate.newReadWriteTransaction();
-        ReadWriteTransaction bindingTx = new BindingDOMReadWriteTransactionAdapter(delegateTx, codec) {
+        final DOMDataReadWriteTransaction delegateTx = delegate.newReadWriteTransaction();
+        return new BindingDOMReadWriteTransactionAdapter(delegateTx, codec) {
 
             @Override
             public CheckedFuture<Void, TransactionCommitFailedException> submit() {
@@ -69,33 +68,31 @@ final class BindingDOMTransactionChainAdapter implements BindingTransactionChain
             }
 
         };
-        return bindingTx;
     }
 
     @Override
     public WriteTransaction newWriteOnlyTransaction() {
         final DOMDataWriteTransaction delegateTx = delegate.newWriteOnlyTransaction();
-        WriteTransaction bindingTx = new BindingDOMWriteTransactionAdapter<DOMDataWriteTransaction>(delegateTx, codec) {
+        return new BindingDOMWriteTransactionAdapter<DOMDataWriteTransaction>(delegateTx, codec) {
 
             @Override
             public CheckedFuture<Void,TransactionCommitFailedException> submit() {
                 return listenForFailure(this,super.submit());
-            };
+            }
 
         };
-        return bindingTx;
     }
 
     private CheckedFuture<Void, TransactionCommitFailedException> listenForFailure(
-            final WriteTransaction tx, CheckedFuture<Void, TransactionCommitFailedException> future) {
+            final WriteTransaction tx, final CheckedFuture<Void, TransactionCommitFailedException> future) {
         Futures.addCallback(future, new FutureCallback<Void>() {
             @Override
-            public void onFailure(Throwable t) {
+            public void onFailure(final Throwable t) {
                 failTransactionChain(tx,t);
             }
 
             @Override
-            public void onSuccess(Void result) {
+            public void onSuccess(final Void result) {
                 // Intentionally NOOP
             }
         });
@@ -103,7 +100,7 @@ final class BindingDOMTransactionChainAdapter implements BindingTransactionChain
         return future;
     }
 
-    private void failTransactionChain(WriteTransaction tx, Throwable t) {
+    private void failTransactionChain(final WriteTransaction tx, final Throwable t) {
         /*
          *  We asume correct state change for underlaying transaction
          *
index 02e15a1..88c8bf5 100644 (file)
@@ -41,8 +41,8 @@ class BindingDOMWriteTransactionAdapter<T extends DOMDataWriteTransaction> exten
     }
 
     @Override
-    public <T extends DataObject> void merge(final LogicalDatastoreType store, final InstanceIdentifier<T> path,
-                                             final T data) {
+    public <D extends DataObject> void merge(final LogicalDatastoreType store, final InstanceIdentifier<D> path,
+                                             final D data) {
         merge(store, path, data,false);
     }
 
index 776691c..845f422 100644 (file)
@@ -94,7 +94,7 @@ public final class BindingToNormalizedNodeCodec implements BindingCodecTreeFacto
         this.futureSchema = waitForSchema ? new FutureSchema(WAIT_DURATION_SEC, TimeUnit.SECONDS) : null;
     }
 
-    final YangInstanceIdentifier toYangInstanceIdentifierBlocking(final InstanceIdentifier<? extends DataObject> binding) {
+    YangInstanceIdentifier toYangInstanceIdentifierBlocking(final InstanceIdentifier<? extends DataObject> binding) {
         try {
             return codecRegistry.toYangInstanceIdentifier(binding);
         } catch (final MissingSchemaException e) {
@@ -202,7 +202,7 @@ public final class BindingToNormalizedNodeCodec implements BindingCodecTreeFacto
     }
 
     public Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> toBinding(
-            final @Nonnull Entry<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> normalized)
+            @Nonnull final Entry<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> normalized)
                     throws DeserializationException {
         try {
             /*
@@ -218,7 +218,7 @@ public final class BindingToNormalizedNodeCodec implements BindingCodecTreeFacto
              * It is safe to  loose generic information and cast it to other generic signature.
              *
              */
-            @SuppressWarnings({ "unchecked", "rawtypes" })
+            @SuppressWarnings("unchecked")
             final Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding = Entry.class.cast(codecRegistry.fromNormalizedNode(normalized.getKey(), normalized.getValue()));
             return Optional.fromNullable(binding);
         } catch (final IllegalArgumentException e) {
@@ -228,7 +228,7 @@ public final class BindingToNormalizedNodeCodec implements BindingCodecTreeFacto
 
     @Override
     public void onGlobalContextUpdated(final SchemaContext arg0) {
-        legacyToNormalized = new DataNormalizer (arg0);
+        legacyToNormalized = new DataNormalizer(arg0);
         runtimeContext = BindingRuntimeContext.create(classLoadingStrategy, arg0);
         codecRegistry.onBindingRuntimeContextUpdated(runtimeContext);
         if(futureSchema != null) {
index 453958f..84f1244 100644 (file)
@@ -61,7 +61,8 @@ abstract class ContextReferenceExtractor {
      */
     abstract @Nullable InstanceIdentifier<?> extract(DataObject obj);
 
-    private static @Nonnull ContextReferenceExtractor create(final Class<?> key) {
+    @Nonnull
+    private static ContextReferenceExtractor create(final Class<?> key) {
         final Method contextGetter = getContextGetter(key);
         if (contextGetter == null) {
             return NULL_EXTRACTOR;
@@ -83,7 +84,8 @@ abstract class ContextReferenceExtractor {
         return NULL_EXTRACTOR;
     }
 
-    private static @Nullable Method findGetValueMethod(final Class<?> type, final Class<?> returnType) {
+    @Nullable
+    private static Method findGetValueMethod(final Class<?> type, final Class<?> returnType) {
         try {
             final Method method = type.getMethod(GET_VALUE_NAME);
             if(returnType.equals(method.getReturnType())) {
index 83d48f7..1170828 100644 (file)
@@ -59,7 +59,7 @@ final class LazyDataObjectModification<T extends DataObject> implements DataObje
 
     private static Collection<DataObjectModification<? extends DataObject>> from(final BindingCodecTreeNode<?> parentCodec,
             final Collection<DataTreeCandidateNode> domChildNodes) {
-        final ArrayList<DataObjectModification<? extends DataObject>> result = new ArrayList<>(domChildNodes.size());
+        final List<DataObjectModification<? extends DataObject>> result = new ArrayList<>(domChildNodes.size());
         populateList(result, parentCodec, domChildNodes);
         return result;
     }
index 24ca97e..f9163ce 100644 (file)
@@ -61,7 +61,7 @@ class RpcServiceAdapter implements InvocationHandler {
         proxy = (RpcService) Proxy.newProxyInstance(type.getClassLoader(), new Class[] {type}, this);
     }
 
-    private final ListenableFuture<RpcResult<?>> invoke0(final SchemaPath schemaPath, final NormalizedNode<?, ?> input) {
+    private ListenableFuture<RpcResult<?>> invoke0(final SchemaPath schemaPath, final NormalizedNode<?, ?> input) {
         final CheckedFuture<DOMRpcResult, DOMRpcException> result = delegate.invokeRpc(schemaPath, input);
         if(result instanceof LazyDOMRpcResultFuture) {
             return ((LazyDOMRpcResultFuture) result).getBindingFuture();
@@ -105,14 +105,15 @@ class RpcServiceAdapter implements InvocationHandler {
     private static boolean isObjectMethod(final Method m) {
         switch (m.getName()) {
             case "toString":
-                return (m.getReturnType() == String.class && m.getParameterTypes().length == 0);
+                return (m.getReturnType().equals(String.class) && m.getParameterTypes().length == 0);
             case "hashCode":
-                return (m.getReturnType() == int.class && m.getParameterTypes().length == 0);
+                return (m.getReturnType().equals(int.class) && m.getParameterTypes().length == 0);
             case "equals":
-                return (m.getReturnType() == boolean.class && m.getParameterTypes().length == 1 && m
+                return (m.getReturnType().equals(boolean.class) && m.getParameterTypes().length == 1 && m
                         .getParameterTypes()[0] == Object.class);
+            default:
+                return false;
         }
-        return false;
     }
 
     private Object callObjectMethod(final Object self, final Method m, final Object[] args) {
@@ -123,8 +124,9 @@ class RpcServiceAdapter implements InvocationHandler {
                 return System.identityHashCode(self);
             case "equals":
                 return (self == args[0]);
+            default:
+                return null;
         }
-        return null;
     }
 
     private static ListenableFuture<RpcResult<?>> transformFuture(final SchemaPath rpc,
index aea5907..7919a8f 100644 (file)
@@ -29,8 +29,10 @@ public abstract class AdapterLoader<T, D> extends CacheLoader<Class<? extends T>
         return  Optional.<T>of(builder.build());
     }
 
-    protected abstract @Nullable D getDelegate(Class<? extends D> reqDeleg);
+    @Nullable
+    protected abstract D getDelegate(Class<? extends D> reqDeleg);
 
-    protected abstract @Nonnull AdapterBuilder<? extends T, D> createBuilder(Class<? extends T> key) throws IllegalArgumentException;
+    @Nonnull
+    protected abstract AdapterBuilder<? extends T, D> createBuilder(Class<? extends T> key);
 
 }
index 193f3c8..3fccb1d 100644 (file)
@@ -37,10 +37,8 @@ import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class RootBindingAwareBroker implements //
-        Mutable, //
-        Identifiable<String>, //
-        BindingAwareBroker, AutoCloseable, RpcProviderRegistry {
+public class RootBindingAwareBroker implements Mutable, Identifiable<String>, BindingAwareBroker, AutoCloseable,
+        RpcProviderRegistry {
 
     private final static Logger LOG = LoggerFactory.getLogger(RootBindingAwareBroker.class);
 
index 587b926..7598882 100644 (file)
@@ -10,15 +10,13 @@ package org.opendaylight.controller.md.sal.binding.impl.test;
 
 import static junit.framework.TestCase.assertNotNull;
 
-import org.opendaylight.controller.md.sal.binding.compat.HydrogenDataBrokerAdapter;
-
 import com.google.common.collect.ImmutableSet;
 import java.util.concurrent.ExecutionException;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.compat.HydrogenDataBrokerAdapter;
 import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
 import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestCustomizer;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
@@ -33,10 +31,7 @@ import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
 public class ForwardedBackwardsCompatibleDataBrokerTest extends
     AbstractDataBrokerTest {
 
-    private DataBrokerTestCustomizer testCustomizer;
     private HydrogenDataBrokerAdapter dataBroker;
-    private DOMDataBroker domBroker;
-
     private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
     private static final TopLevelListKey TOP_LIST_KEY = new TopLevelListKey("foo");
     private static final InstanceIdentifier<TopLevelList> NODE_PATH = TOP_PATH.child(TopLevelList.class, TOP_LIST_KEY);
index 1203a72..5ca041a 100644 (file)
@@ -177,7 +177,6 @@ public class BindingTestContext implements AutoCloseable {
 
     private ProviderSession createMockContext() {
 
-        @SuppressWarnings("deprecation")
         final ClassToInstanceMap<BrokerService> domBrokerServices = ImmutableClassToInstanceMap
                 .<BrokerService> builder()
                 //

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