Migrate isFoo() callers
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / schema / provider / impl / RemoteYangTextSourceProviderImpl.java
index 0b07eeb19bb049305d2fff05f481daba4ee25bc8..5e88952dda26f2e2ad670c202f6f67b0e795e965 100644 (file)
@@ -5,13 +5,15 @@
  * 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.cluster.schema.provider.impl;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.annotations.Beta;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.io.IOException;
 import java.util.Set;
 import org.opendaylight.controller.cluster.schema.provider.RemoteYangTextSourceProvider;
@@ -33,8 +35,9 @@ public class RemoteYangTextSourceProviderImpl implements RemoteYangTextSourcePro
     private final SchemaRepository repository;
     private final Set<SourceIdentifier> providedSources;
 
-    public RemoteYangTextSourceProviderImpl(SchemaRepository repository, Set<SourceIdentifier> providedSources) {
-        this.repository = repository;
+    public RemoteYangTextSourceProviderImpl(final SchemaRepository repository,
+            final Set<SourceIdentifier> providedSources) {
+        this.repository = requireNonNull(repository);
         this.providedSources = providedSources;
     }
 
@@ -44,15 +47,16 @@ public class RemoteYangTextSourceProviderImpl implements RemoteYangTextSourcePro
     }
 
     @Override
-    public Future<YangTextSchemaSourceSerializationProxy> getYangTextSchemaSource(SourceIdentifier identifier) {
+    public Future<YangTextSchemaSourceSerializationProxy> getYangTextSchemaSource(final SourceIdentifier identifier) {
         LOG.trace("Sending yang schema source for {}", identifier);
 
         final Promise<YangTextSchemaSourceSerializationProxy> promise = akka.dispatch.Futures.promise();
-        CheckedFuture<YangTextSchemaSource, ?> future = repository.getSchemaSource(identifier, YangTextSchemaSource.class);
+        ListenableFuture<YangTextSchemaSource> future =
+                repository.getSchemaSource(identifier, YangTextSchemaSource.class);
 
         Futures.addCallback(future, new FutureCallback<YangTextSchemaSource>() {
             @Override
-            public void onSuccess(YangTextSchemaSource result) {
+            public void onSuccess(final YangTextSchemaSource result) {
                 try {
                     promise.success(new YangTextSchemaSourceSerializationProxy(result));
                 } catch (IOException e) {
@@ -62,11 +66,11 @@ public class RemoteYangTextSourceProviderImpl implements RemoteYangTextSourcePro
             }
 
             @Override
-            public void onFailure(Throwable t) {
-                LOG.warn("Unable to retrieve schema source from provider", t);
-                promise.failure(t);
+            public void onFailure(final Throwable failure) {
+                LOG.warn("Unable to retrieve schema source from provider", failure);
+                promise.failure(failure);
             }
-        });
+        }, MoreExecutors.directExecutor());
 
         return promise.future();
     }