X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Futil%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Futil%2Fconcurrent%2FMappingCheckedFuture.java;h=571411d24fd37878b74faed6a88582b5a0b6a7f6;hb=refs%2Fchanges%2F09%2F42509%2F1;hp=48f69e2da3ba29832d82141d338c3c3233dd44fd;hpb=008d2f641f48bb2f8fa8e88b94492a5e4b72f84b;p=yangtools.git
diff --git a/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/MappingCheckedFuture.java b/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/MappingCheckedFuture.java
index 48f69e2da3..571411d24f 100644
--- a/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/MappingCheckedFuture.java
+++ b/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/MappingCheckedFuture.java
@@ -8,15 +8,14 @@
package org.opendaylight.yangtools.util.concurrent;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.AbstractCheckedFuture;
import com.google.common.util.concurrent.ListenableFuture;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
/**
* An implementation of CheckedFuture that provides similar behavior for the get
methods
@@ -33,11 +32,11 @@ import com.google.common.util.concurrent.ListenableFuture;
* @param The result type returned by this Future's get method
* @param The checked exception type
*/
-public class MappingCheckedFuture extends AbstractCheckedFuture {
+public final class MappingCheckedFuture extends AbstractCheckedFuture {
private final Function mapper;
- private MappingCheckedFuture( ListenableFuture delegate, Function mapper ) {
+ private MappingCheckedFuture( final ListenableFuture delegate, final Function mapper ) {
super( delegate );
this.mapper = Preconditions.checkNotNull( mapper );
}
@@ -51,16 +50,16 @@ public class MappingCheckedFuture extends AbstractChecke
* @return a new MappingCheckedFuture
*/
public static MappingCheckedFuture create(
- ListenableFuture delegate, Function mapper ) {
- return new MappingCheckedFuture( delegate, mapper );
+ final ListenableFuture delegate, final Function mapper ) {
+ return new MappingCheckedFuture<>(delegate, mapper);
}
@Override
- protected X mapException( Exception e ) {
+ protected X mapException( final Exception e ) {
return mapper.apply( e );
}
- private ExecutionException wrapInExecutionException( String message, final Exception e ) {
+ private ExecutionException wrapInExecutionException( final String message, final Exception e ) {
return new ExecutionException( message, mapException( e ) );
}
@@ -68,27 +67,27 @@ public class MappingCheckedFuture extends AbstractChecke
public V get() throws InterruptedException, ExecutionException {
try {
return super.get();
- } catch( InterruptedException e ) {
+ } catch( final InterruptedException e ) {
Thread.currentThread().interrupt();
throw wrapInExecutionException( "Operation was interrupted", e );
- } catch( CancellationException e ) {
+ } catch( final CancellationException e ) {
throw wrapInExecutionException( "Operation was cancelled", e );
- } catch( ExecutionException e ) {
+ } catch( final ExecutionException e ) {
throw wrapInExecutionException( e.getMessage(), e );
}
}
@Override
- public V get( long timeout, TimeUnit unit )
+ public V get( final long timeout, final TimeUnit unit )
throws InterruptedException, ExecutionException, TimeoutException {
try {
return super.get( timeout, unit );
- } catch( InterruptedException e ) {
+ } catch( final InterruptedException e ) {
Thread.currentThread().interrupt();
throw wrapInExecutionException( "Operation was interrupted", e );
- } catch( CancellationException e ) {
+ } catch( final CancellationException e ) {
throw wrapInExecutionException( "Operation was cancelled", e );
- } catch( ExecutionException e ) {
+ } catch( final ExecutionException e ) {
throw wrapInExecutionException( e.getMessage(), e );
}
}