Code Clean Up 35/53235/2
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Mon, 13 Mar 2017 16:59:21 +0000 (17:59 +0100)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Wed, 15 Mar 2017 09:23:02 +0000 (09:23 +0000)
Anonymous type replaced by lambda

Change-Id: Idd81b1e43866e5d960ec2dfa777b66bae3e53da9
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
53 files changed:
bgp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/app/BmpMonitoringStationImpl.java
bgp/bmp-impl/src/test/java/org/opendaylight/controller/config/yang/bmp/impl/AbstractBmpModuleTest.java
bgp/bmp-impl/src/test/java/org/opendaylight/controller/config/yang/bmp/impl/BmpMonitorImplModuleTest.java
bgp/bmp-impl/src/test/java/org/opendaylight/protocol/bmp/impl/session/BmpDispatcherImplTest.java
bgp/bmp-mock/src/main/java/org/opendaylight/protocol/bmp/mock/BmpMock.java
bgp/bmp-mock/src/main/java/org/opendaylight/protocol/bmp/mock/BmpMockArguments.java
bgp/bmp-mock/src/main/java/org/opendaylight/protocol/bmp/mock/BmpMockSession.java
bgp/bmp-mock/src/test/java/org/opendaylight/protocol/bmp/mock/BmpMockSessionTest.java
bgp/bmp-spi/src/test/java/org/opendaylight/protocol/bmp/spi/parser/AbstractBmpMessageWithTlvParserTest.java
bgp/config-loader-impl/src/main/java/org/opendaylight/protocol/bgp/config/loader/impl/BGPFileWatcher.java
bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/spi/pojo/SimpleEvpnNlriRegistry.java
bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecNlriParser.java
bgp/inet/src/test/java/org/opendaylight/protocol/bgp/inet/Ipv6BgpPrefixSidParserTest.java
bgp/inet/src/test/java/org/opendaylight/protocol/bgp/inet/codec/nexthop/NextHopParserSerializerTest.java
bgp/openconfig-state/src/test/java/org/opendaylight/protocol/bgp/state/NeighborUtilTest.java
bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/pojo/SimpleRegistryTest.java
bgp/path-selection-mode/src/main/java/org/opendaylight/protocol/bgp/mode/impl/BestPathStateImpl.java
bgp/path-selection-mode/src/test/java/org/opendaylight/protocol/bgp/mode/impl/AbstractRouteEntryTest.java
bgp/rib-impl/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/RIBImplModule.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BgpPeerRpc.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImplTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/FSMTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SynchronizationAndExceptionTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/config/AbstractConfig.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/config/RibImplTest.java
bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/AbstractRIBSupportTest.java
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/LinkstateTopologyBuilder.java
bgp/topology-provider/src/test/java/org/opendaylight/controller/config/yang/bgp/topology/provider/AbstractTopologyBuilderModuleTest.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionNegotiator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractSessionNegotiator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPByteToMessageDecoder.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPPeerRegistry.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPProtocolSessionPromise.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionNegotiator.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionTest.java
pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/Main.java
pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/PCCTunnelManagerImpl.java
pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/PCCTunnelManagerImplTest.java
pcep/testtool/src/test/java/org/opendaylight/protocol/pcep/testtool/PCCMock.java
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/OperationResults.java
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/Stateful07TopologySessionListener.java
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/TopologyRPCs.java
pcep/tunnel-provider/src/main/java/org/opendaylight/bgpcep/pcep/tunnel/provider/CreateTunnelInstructionExecutor.java
pcep/tunnel-provider/src/main/java/org/opendaylight/bgpcep/pcep/tunnel/provider/DestroyTunnelInstructionExecutor.java
pcep/tunnel-provider/src/main/java/org/opendaylight/bgpcep/pcep/tunnel/provider/UpdateTunnelInstructionExecutor.java
rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/pojo/SimpleEROSubobjectRegistryTest.java
rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/pojo/SimpleRROSubobjectRegistryTest.java
rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/pojo/SimpleXROSubobjectRegistryTest.java
rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/EROSubobjectListParserTest.java
rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/RROSubobjectListParserTest.java
rsvp/spi/src/test/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/XROSubobjectListParserTest.java

index e043f46459375f7cdf11083738693787aca2cdf9..d0b659cbdb3f1a64de3cbe207f91ba764341fbcb 100644 (file)
@@ -144,12 +144,7 @@ public final class BmpMonitoringStationImpl implements BmpMonitoringStation {
 
     @Override
     public void close() throws Exception {
-        this.channel.close().addListener(new ChannelFutureListener() {
-            @Override
-            public void operationComplete(final ChannelFuture channelFuture) throws Exception {
-                BmpMonitoringStationImpl.this.sessionManager.close();
-            }
-        }).await();
+        this.channel.close().addListener((ChannelFutureListener) channelFuture -> BmpMonitoringStationImpl.this.sessionManager.close()).await();
 
         final DOMDataWriteTransaction wTx = this.domDataBroker.newWriteOnlyTransaction();
         wTx.delete(LogicalDatastoreType.OPERATIONAL, this.yangMonitorId);
index 727b78a9986c7e037b8f0f43b2c4386298d76206..efbaf3fe9ffd8a3b4aaf69322116db6a5d6e7754 100644 (file)
@@ -38,14 +38,11 @@ import org.osgi.framework.ServiceReference;
 public class AbstractBmpModuleTest extends AbstractConfigTest {
     @Before
     public void setUp() throws Exception {
-        doAnswer(new Answer<Filter>() {
-            @Override
-            public Filter answer(final InvocationOnMock invocation) {
-                final String str = invocation.getArgumentAt(0, String.class);
-                final Filter mockFilter = mock(Filter.class);
-                doReturn(str).when(mockFilter).toString();
-                return mockFilter;
-            }
+        doAnswer(invocation -> {
+            final String str = invocation.getArgumentAt(0, String.class);
+            final Filter mockFilter = mock(Filter.class);
+            doReturn(str).when(mockFilter).toString();
+            return mockFilter;
         }).when(mockedContext).createFilter(anyString());
 
         Mockito.doNothing().when(this.mockedContext).addServiceListener(any(ServiceListener.class), Mockito.anyString());
index aa8827a4070742f2161521188d936b746c10dd05..b043f708081a41f1fce86d9c6526654174b81b77 100644 (file)
@@ -138,14 +138,11 @@ public class BmpMonitorImplModuleTest extends AbstractBmpModuleTest {
         final SchemaContext context = parseYangStreams(getFilesAsStreams(getYangModelsPaths()));
         final SchemaService mockedSchemaService = mock(SchemaService.class);
         doReturn(context).when(mockedSchemaService).getGlobalContext();
-        doAnswer(new Answer<ListenerRegistration<SchemaContextListener>>() {
-            @Override
-            public ListenerRegistration<SchemaContextListener> answer(final InvocationOnMock invocation) {
-                invocation.getArgumentAt(0, SchemaContextListener.class).onGlobalContextUpdated(context);
-                final ListenerRegistration<SchemaContextListener> reg = mock(ListenerRegistration.class);
-                doNothing().when(reg).close();
-                return reg;
-            }
+        doAnswer(invocation -> {
+            invocation.getArgumentAt(0, SchemaContextListener.class).onGlobalContextUpdated(context);
+            final ListenerRegistration<SchemaContextListener> reg = mock(ListenerRegistration.class);
+            doNothing().when(reg).close();
+            return reg;
         }).when(mockedSchemaService).registerSchemaContextListener(any(SchemaContextListener.class));
 
         setupMockService(SchemaService.class, mockedSchemaService);
index 69edf89a186dbaf93d6013043eb62cfe1373fddf..d850924f87e7f304d6a7d3dac3e39a2f5e2434ae 100644 (file)
@@ -69,13 +69,7 @@ public class BmpDispatcherImplTest {
         this.bmpActivator.start(ctx);
         final BmpMessageRegistry messageRegistry = ctx.getBmpMessageRegistry();
 
-        this.dispatcher = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(), messageRegistry, new BmpSessionFactory() {
-            @Override
-            public BmpSession getSession(final Channel channel,
-                    final BmpSessionListenerFactory sessionListenerFactory) {
-                return BmpDispatcherImplTest.this.mockedSession;
-            }
-        });
+        this.dispatcher = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(), messageRegistry, (channel, sessionListenerFactory) -> BmpDispatcherImplTest.this.mockedSession);
     }
 
     @After
index 19d6a3c29e0c3b668174bb796efd61544eb3ef7f..e838967001fdb1674af99f6f45480b375317be83 100644 (file)
@@ -58,13 +58,7 @@ public final class BmpMock {
         bmpActivator.start(ctx);
 
         return new BmpMockDispatcher(ctx.getBmpMessageRegistry(),
-            new BmpSessionFactory() {
-                @Override
-                public BmpSession getSession(final Channel channel,
-                    final BmpSessionListenerFactory sessionListenerFactory) {
-                    return new BmpMockSession(arguments.getPeersCount(), arguments.getPrePolicyRoutesCount(), arguments.getPostPolicyRoutesCount());
-                }
-            });
+            (channel, sessionListenerFactory) -> new BmpMockSession(arguments.getPeersCount(), arguments.getPrePolicyRoutesCount(), arguments.getPostPolicyRoutesCount()));
     }
 
     private static void deployClients(final BmpMockDispatcher dispatcher, final BmpMockArguments arguments) {
index 8293c02ebb9698651a63d76310c48a1866e57312..7874e1db02ab8762c321394733b59a7c108403a7 100644 (file)
@@ -101,25 +101,9 @@ public final class BmpMockArguments implements ArgumentsInput {
         parser.addArgument(toArgName(PRE_POLICY_ROUTES_COUNT_DST)).type(Integer.class).setDefault(0);
         parser.addArgument(toArgName(POST_POLICY_ROUTES_COUNT_DST)).type(Integer.class).setDefault(0);
         parser.addArgument(toArgName(PASSIVE_MODE_DST)).action(Arguments.storeTrue());
-        parser.addArgument(toArgName(LOCAL_ADDRESS_DST)).type(new ArgumentType<InetSocketAddress>() {
-            @Override
-            public InetSocketAddress convert(final ArgumentParser parser, final Argument arg, final String value)
-                    throws ArgumentParserException {
-                return getInetSocketAddress(value, DEFAULT_LOCAL_PORT);
-            }
-        }).setDefault(LOCAL_ADDRESS);
-        parser.addArgument(toArgName(REMOTE_ADDRESS_DST)).type(new ArgumentType<InetSocketAddress>() {
-            @Override
-            public InetSocketAddress convert(final ArgumentParser parser, final Argument arg, final String value)
-                    throws ArgumentParserException {
-                return getInetSocketAddress(value, DEFAULT_REMOTE_PORT);
-            }
-        }).setDefault(REMOTE_ADDRESS);
-        parser.addArgument(toArgName(LOG_LEVEL_DST)).type(new ArgumentType<Level>(){
-            @Override
-            public Level convert(final ArgumentParser parser, final Argument arg, final String value) throws ArgumentParserException {
-                return Level.toLevel(value);
-            }}).setDefault(Level.INFO);
+        parser.addArgument(toArgName(LOCAL_ADDRESS_DST)).type((parser13, arg, value) -> getInetSocketAddress(value, DEFAULT_LOCAL_PORT)).setDefault(LOCAL_ADDRESS);
+        parser.addArgument(toArgName(REMOTE_ADDRESS_DST)).type((parser12, arg, value) -> getInetSocketAddress(value, DEFAULT_REMOTE_PORT)).setDefault(REMOTE_ADDRESS);
+        parser.addArgument(toArgName(LOG_LEVEL_DST)).type((parser1, arg, value) -> Level.toLevel(value)).setDefault(Level.INFO);
         return parser;
     }
 
index 05724c861fb99cd2a5c4a719c7e42c5969361da6..887d201aabb8a908d099aedd7c8baf53ff5a9e46 100644 (file)
@@ -66,12 +66,7 @@ public final class BmpMockSession extends SimpleChannelInboundHandler<Notificati
     @Override
     public void channelActive(final ChannelHandlerContext ctx) {
         this.channel = ctx.channel();
-        this.channel.closeFuture().addListener(new ChannelFutureListener() {
-            @Override
-            public void operationComplete(final ChannelFuture future) throws Exception {
-                LOG.info("BMP session {} final successfully established.", BmpMockSession.this.channel);
-            }
-        });
+        this.channel.closeFuture().addListener((ChannelFutureListener) future -> LOG.info("BMP session {} final successfully established.", BmpMockSession.this.channel));
         LOG.info("BMP session {} successfully established.", this.channel);
         final InetSocketAddress localAddress = (InetSocketAddress) this.channel.localAddress();
         this.remoteAddress = (InetSocketAddress) this.channel.remoteAddress();
index 5be0a04401eb253ee02632fe1d365195e9a22f11..e25d0666e4381c153a50a8e77612cf9c62b8ccc1 100644 (file)
@@ -51,12 +51,9 @@ public class BmpMockSessionTest {
         Mockito.doReturn(LOCAL_ADDRESS).when(this.channel).localAddress();
         final ChannelPipeline pipeline = Mockito.mock(ChannelPipeline.class);
         Mockito.doReturn(pipeline).when(this.channel).pipeline();
-        Mockito.doAnswer(new Answer<Void>() {
-            @Override
-            public Void answer(final InvocationOnMock invocation) throws Throwable {
-                messages.add((Notification) invocation.getArguments()[0]);
-                return null;
-            }
+        Mockito.doAnswer(invocation -> {
+            messages.add((Notification) invocation.getArguments()[0]);
+            return null;
         }).when(this.channel).writeAndFlush(Mockito.any());
         final ChannelFuture channelFuture = Mockito.mock(ChannelFuture.class);
         Mockito.doReturn(null).when(channelFuture).addListener(Mockito.any());
index 3b907ed9135e4fdb3ca4ed2a05c2d69da7d007df..1e16c246f512490b5179969f9a559c1cca5865d9 100644 (file)
@@ -33,22 +33,16 @@ public class AbstractBmpMessageWithTlvParserTest {
     private static final byte[] DATA = { 0, 1, 0, 4, 't', 'e', 's', 't' };
     private static final int TYPE = 1;
 
-    public static final BmpTlvSerializer DESCRIPTION_TLV_SERIALIZER = new BmpTlvSerializer() {
-        @Override
-        public void serializeTlv(final Tlv tlv, final ByteBuf output) {
-            Preconditions.checkArgument(tlv instanceof DescriptionTlv, "DescriptionTlv is mandatory.");
-            TlvUtil.formatTlvAscii(TYPE, ((DescriptionTlv) tlv).getDescription(), output);
-        }
+    public static final BmpTlvSerializer DESCRIPTION_TLV_SERIALIZER = (tlv, output) -> {
+        Preconditions.checkArgument(tlv instanceof DescriptionTlv, "DescriptionTlv is mandatory.");
+        TlvUtil.formatTlvAscii(TYPE, ((DescriptionTlv) tlv).getDescription(), output);
     };
 
-    public static final BmpTlvParser DESCRIPTION_TLV_PARSER = new BmpTlvParser() {
-        @Override
-        public Tlv parseTlv(final ByteBuf buffer) throws BmpDeserializationException {
-            if (buffer == null) {
-                return null;
-            }
-            return new DescriptionTlvBuilder().setDescription(buffer.toString(StandardCharsets.US_ASCII)).build();
+    public static final BmpTlvParser DESCRIPTION_TLV_PARSER = buffer -> {
+        if (buffer == null) {
+            return null;
         }
+        return new DescriptionTlvBuilder().setDescription(buffer.toString(StandardCharsets.US_ASCII)).build();
     };
 
     @Before
index 87607178daafec432ac6b9d00b3629358bd20b1e..78fe148c6018dc83486624d7425bc5d1eec8a0b8 100644 (file)
@@ -29,16 +29,13 @@ public final class BGPFileWatcher implements FileWatcher, AutoCloseable {
 
     public BGPFileWatcher() throws IOException {
         this.watchService = FileSystems.getDefault().newWatchService();
-        Runtime.getRuntime().addShutdownHook(new Thread() {
-            @Override
-            public void run() {
-                try {
-                    BGPFileWatcher.this.watchService.close();
-                } catch (final IOException e) {
-                    LOG.warn(INTERRUPTED, e);
-                }
+        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
+            try {
+                BGPFileWatcher.this.watchService.close();
+            } catch (final IOException e) {
+                LOG.warn(INTERRUPTED, e);
             }
-        });
+        }));
         PATH.register(this.watchService, OVERFLOW, ENTRY_CREATE);
     }
 
index 5da38162c59bf14d2182388aad7fb3cad8b53676..afa14ddad1c827054ff774d24b031761b3691483 100644 (file)
@@ -74,12 +74,12 @@ public class SimpleEvpnNlriRegistry implements EvpnRegistry {
 
     @Override
     public EvpnChoice serializeEvpnModel(final ChoiceNode evpnChoice) {
-        return getEvpnCase(evpnChoice, (serializer, cont) -> serializer.serializeEvpnModel(cont));
+        return getEvpnCase(evpnChoice, EvpnSerializer::serializeEvpnModel);
     }
 
     @Override
     public EvpnChoice serializeEvpnRouteKey(final ChoiceNode evpnChoice) {
-        return getEvpnCase(evpnChoice, (serializer, cont) -> serializer.createRouteKey(cont));
+        return getEvpnCase(evpnChoice, EvpnSerializer::createRouteKey);
     }
 
     private EvpnChoice getEvpnCase(final ChoiceNode evpnChoice, final SerializerInterface serializerInterface) {
index b637cc8a7beab441e7fd4da8fd3c207846265fa8..4eae0d2d07bdcf687c9e787a60220fab84ae76d8 100644 (file)
@@ -469,7 +469,7 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri
     protected final String stringNlri(final List<Flowspec> flows) {
         final StringBuilder buffer = new StringBuilder("all packets ");
         final Joiner joiner = Joiner.on(FLOW_SEPARATOR);
-        joiner.appendTo(buffer, Iterables.transform(flows, fs -> encodeFlow(fs)));
+        joiner.appendTo(buffer, Iterables.transform(flows, this::encodeFlow));
         return buffer.toString().replace("  ", " ");
     }
 
index 1424b8b36f133c1d0005a7ca353ff16eb34b8dc5..da00cf72ba196c0c1d7f909e97be05509cd6404c 100644 (file)
@@ -27,12 +27,7 @@ public final class Ipv6BgpPrefixSidParserTest {
 
     @Test(expected=IllegalArgumentException.class)
     public void testWrongTlvType() {
-        this.handler.serializeBgpPrefixSidTlv(new BgpPrefixSidTlv() {
-            @Override
-            public Class<? extends DataContainer> getImplementedInterface() {
-                return BgpPrefixSidTlv.class;
-            }
-        }, Unpooled.EMPTY_BUFFER);
+        this.handler.serializeBgpPrefixSidTlv(() -> BgpPrefixSidTlv.class, Unpooled.EMPTY_BUFFER);
     }
 
     @Test
index 42b1d8c898cbbe802bb85f4c5cb50d47e036c2de..a4ea2eebaa85f0a6dfcdec7e9ec827541f466d61 100644 (file)
@@ -81,12 +81,7 @@ public class NextHopParserSerializerTest {
     public void testSerializeIpv4NextHopEmpty() {
         buffer.clear();
         try {
-            ipv4NextHopParserSerializer.serializeNextHop(new CNextHop() {
-                @Override
-                public Class<? extends DataContainer> getImplementedInterface() {
-                    return null;
-                }
-            }, buffer);
+            ipv4NextHopParserSerializer.serializeNextHop(() -> null, buffer);
         } catch (final IllegalArgumentException e) {
             assertEquals("cNextHop is not a Ipv4 NextHop object.", e.getMessage());
         }
@@ -96,12 +91,7 @@ public class NextHopParserSerializerTest {
     public void testSerializeIpv6NextHopEmpty() {
         buffer.clear();
         try {
-            ipv6NextHopParserSerializer.serializeNextHop(new CNextHop() {
-                @Override
-                public Class<? extends DataContainer> getImplementedInterface() {
-                    return null;
-                }
-            }, buffer);
+            ipv6NextHopParserSerializer.serializeNextHop(() -> null, buffer);
         } catch (final IllegalArgumentException e) {
             assertEquals("cNextHop is not a Ipv6 NextHop object.", e.getMessage());
         }
index 82a41482a0908fb99a99df9f350b4958fc38fe0a..e4163a784f1b021f2f9b26e4d9749bdcad00fc97 100644 (file)
@@ -62,20 +62,10 @@ public class NeighborUtilTest {
         doReturn(false).when(this.sessionState).isAsn32CapabilitySupported();
         doReturn(false).when(this.sessionState).isAddPathCapabilitySupported();
         doReturn(this.state).when(this.sessionState).getSessionState();
-        Mockito.doAnswer(new Answer<State>() {
-            @Override
-            public State answer(final InvocationOnMock invocation) throws Throwable {
-                return NeighborUtilTest.this.state;
-            }
-        }).when(this.sessionState).getSessionState();
+        Mockito.doAnswer(invocation -> NeighborUtilTest.this.state).when(this.sessionState).getSessionState();
         doReturn(Collections.singleton(TABLES_KEY)).when(this.bgpAfiSafiState).getAfiSafisAdvertized();
         doReturn(Collections.singleton(TABLES_KEY)).when(this.bgpAfiSafiState).getAfiSafisReceived();
-        Mockito.doAnswer(new Answer<Optional>() {
-            @Override
-            public Optional answer(final InvocationOnMock invocation) throws Throwable {
-                return NeighborUtilTest.this.afiSafi;
-            }
-        }).when(this.tableRegistry).getAfiSafiType(eq(TABLES_KEY));
+        Mockito.doAnswer(invocation -> NeighborUtilTest.this.afiSafi).when(this.tableRegistry).getAfiSafiType(eq(TABLES_KEY));
         doReturn(false).when(this.bgpAfiSafiState).isAfiSafiSupported(eq(TABLES_KEY));
         doReturn(false).when(this.bgpAfiSafiState).isGracefulRestartAdvertized(eq(TABLES_KEY));
         doReturn(false).when(this.bgpAfiSafiState).isGracefulRestartReceived(eq(TABLES_KEY));
index 4fafdcd1608104aa10bbadb63d8ecd3cc3a230a6..f8306d6637d08eb1586d5dc91a177da95196a70e 100644 (file)
@@ -54,12 +54,7 @@ import org.opendaylight.yangtools.yang.binding.Notification;
 
 public class SimpleRegistryTest {
 
-    private static final MultiPathSupport ADD_PATH_SUPPORT = new MultiPathSupport() {
-        @Override
-        public boolean isTableTypeSupported(final BgpTableType tableType) {
-            return true;
-        }
-    };
+    private static final MultiPathSupport ADD_PATH_SUPPORT = tableType -> true;
 
     private static final PeerSpecificParserConstraint CONSTRAINT = new PeerSpecificParserConstraint() {
         @Override
index bc6f906e069bc1ee9a58cea19a82c50a90cd97d6..2a98f61fca9a5b7d4820beb0daf951d33aa23f59 100644 (file)
@@ -115,12 +115,7 @@ public final class BestPathStateImpl implements BestPathState {
     public BestPathStateImpl(final ContainerNode attributes) {
         final NamespaceSpecificIds col;
         try {
-            col = PATH_CACHE.get(attributes.getNodeType().getModule(), new Callable<NamespaceSpecificIds>() {
-                @Override
-                public NamespaceSpecificIds call() {
-                    return new NamespaceSpecificIds(attributes.getNodeType());
-                }
-            });
+            col = PATH_CACHE.get(attributes.getNodeType().getModule(), () -> new NamespaceSpecificIds(attributes.getNodeType()));
         } catch (final ExecutionException e) {
             LOG.error("Error creating namespace-specific attributes collection.", e);
             throw new IllegalStateException("Error creating namespace-specific attributes collection.", e);
index cffac05f5caf29e79ddcd374db75b2bb6fa05a29..ef3e648b0182101def0c1f448e78c0b412597faf 100644 (file)
@@ -131,32 +131,26 @@ public class AbstractRouteEntryTest {
     }
 
     private void mockTransactionChain() {
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                yIIChanges.add((YangInstanceIdentifier) args[1]);
-                return args[1];
-            }
+        Mockito.doAnswer(invocation -> {
+            final Object[] args = invocation.getArguments();
+            yIIChanges.add((YangInstanceIdentifier) args[1]);
+            return args[1];
         }).when(this.tx).put(Mockito.any(LogicalDatastoreType.class), Mockito.any(YangInstanceIdentifier.class), Mockito.any(NormalizedNode.class));
 
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                if (routePaYii.equals(args[1])) {
-                    yIIChanges.remove(routePaYii);
-                } else if (routePaAddPathYii.equals(args[1])) {
-                    yIIChanges.remove(routePaAddPathYii);
-                } else if (routeRiboutYii.equals(args[1])) {
-                    yIIChanges.remove(routeRiboutYii);
-                    yIIChanges.remove(routeAddRiboutAttYii);
-                } else if (routeAddRiboutYii.equals(args[1])) {
-                    yIIChanges.remove(routeAddRiboutYii);
-                    yIIChanges.remove(routeAddRiboutAttYii);
-                }
-                return args[1];
+        Mockito.doAnswer(invocation -> {
+            final Object[] args = invocation.getArguments();
+            if (routePaYii.equals(args[1])) {
+                yIIChanges.remove(routePaYii);
+            } else if (routePaAddPathYii.equals(args[1])) {
+                yIIChanges.remove(routePaAddPathYii);
+            } else if (routeRiboutYii.equals(args[1])) {
+                yIIChanges.remove(routeRiboutYii);
+                yIIChanges.remove(routeAddRiboutAttYii);
+            } else if (routeAddRiboutYii.equals(args[1])) {
+                yIIChanges.remove(routeAddRiboutYii);
+                yIIChanges.remove(routeAddRiboutAttYii);
             }
+            return args[1];
         }).when(this.tx).delete(Mockito.any(LogicalDatastoreType.class), Mockito.any(YangInstanceIdentifier.class));
     }
 
@@ -177,17 +171,14 @@ public class AbstractRouteEntryTest {
     private void mockExportPolicies() {
         Mockito.doReturn(true).when(this.peerPT).isTableSupported(PEER_ID);
         Mockito.doReturn(false).when(this.peerPT).isTableSupported(PEER_ID2);
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                if (PeerRole.Ibgp.equals(args[0])) {
-                    return peg;
-                } else if (PeerRole.Ebgp.equals(args[0])) {
-                    return pegNot;
-                } else {
-                    return null;
-                }
+        Mockito.doAnswer(invocation -> {
+            final Object[] args = invocation.getArguments();
+            if (PeerRole.Ibgp.equals(args[0])) {
+                return peg;
+            } else if (PeerRole.Ebgp.equals(args[0])) {
+                return pegNot;
+            } else {
+                return null;
             }
         }).when(this.peerPT).getPeerGroup(Mockito.any(PeerRole.class));
 
@@ -199,32 +190,29 @@ public class AbstractRouteEntryTest {
         Mockito.doReturn(ROUTE_ATTRIBUTES_IDENTIFIER).when(this.ribSupport).routeAttributesIdentifier();
         Mockito.doReturn(ROUTE_ID_PA_ADD_PATH).when(this.ribSupport).getRouteIdAddPath(Mockito.any(Long.class), Mockito.eq(ROUTE_ID_PA_ADD_PATH));
         Mockito.doReturn(null).when(this.ribSupport).getRouteIdAddPath(Mockito.any(Long.class), Mockito.eq(ROUTE_ID_PA));
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                final YangInstanceIdentifier yii = (YangInstanceIdentifier) args[0];
-                final PathArgument paa = (PathArgument) args[1];
-
-                if (ROUTE_ID_PA.equals(paa)) {
-                    if (yii.equals(locRibTargetYii)) {
-                        return routePaYii;
-                    } else if (yii.equals(locRibOutTargetYii)) {
-                        return routeRiboutYii;
-                    } else if (yii.equals(locRibOutTargetYiiPeer2)) {
-                        return routeRiboutYiiPeer2;
-                    }
-                } else if (ROUTE_ID_PA_ADD_PATH.equals(paa)) {
-                    if (yii.equals(locRibTargetYii)) {
-                        return routePaAddPathYii;
-                    } else if (yii.equals(locRibOutTargetYii)) {
-                        return routeAddRiboutYii;
-                    } else if (yii.equals(locRibOutTargetYiiPeer2)) {
-                        return routeAddRiboutYiiPeer2;
-                    }
+        Mockito.doAnswer(invocation -> {
+            final Object[] args = invocation.getArguments();
+            final YangInstanceIdentifier yii = (YangInstanceIdentifier) args[0];
+            final PathArgument paa = (PathArgument) args[1];
+
+            if (ROUTE_ID_PA.equals(paa)) {
+                if (yii.equals(locRibTargetYii)) {
+                    return routePaYii;
+                } else if (yii.equals(locRibOutTargetYii)) {
+                    return routeRiboutYii;
+                } else if (yii.equals(locRibOutTargetYiiPeer2)) {
+                    return routeRiboutYiiPeer2;
+                }
+            } else if (ROUTE_ID_PA_ADD_PATH.equals(paa)) {
+                if (yii.equals(locRibTargetYii)) {
+                    return routePaAddPathYii;
+                } else if (yii.equals(locRibOutTargetYii)) {
+                    return routeAddRiboutYii;
+                } else if (yii.equals(locRibOutTargetYiiPeer2)) {
+                    return routeAddRiboutYiiPeer2;
                 }
-                return null;
             }
+            return null;
         }).when(this.ribSupport).routePath(Mockito.any(YangInstanceIdentifier.class), Mockito.any(PathArgument.class));
     }
 
index 698fb577bfa1ee9053417f681f16d220a9b395a1..8dfec44b2d343e1a453eb77980a002afecf642b3 100755 (executable)
@@ -114,7 +114,7 @@ public final class RIBImplModule extends org.opendaylight.controller.config.yang
 
     private Map<TablesKey, PathSelectionMode> mapBestPathSelectionStrategyByFamily(final List<BGPBestPathSelection> bestPathSelectionDependency) {
         return Collections.unmodifiableMap(bestPathSelectionDependency.stream().collect(
-                Collectors.toMap(st -> new TablesKey(st.getAfi(), st.getSafi()), st -> st.getStrategy())));
+                Collectors.toMap(st -> new TablesKey(st.getAfi(), st.getSafi()), BGPBestPathSelection::getStrategy)));
     }
 
     private static interface AutoCloseableRIB extends RIB, AutoCloseable {
index 420e27e816e2d72bca18942107041fe4fc6d2b6b..0af5d690c19ba2fdb944bf38c5f03d6b6207e194 100644 (file)
@@ -117,17 +117,14 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter
                 preferences.getBgpId()).setBgpParameters(preferences.getParams()).build());
             if (this.state != State.FINISHED) {
                 this.state = State.OPEN_SENT;
-                this.pending = this.channel.eventLoop().schedule(new Runnable() {
-                    @Override
-                    public void run() {
-                        synchronized (AbstractBGPSessionNegotiator.this) {
-                            AbstractBGPSessionNegotiator.this.pending = null;
-                            if (AbstractBGPSessionNegotiator.this.state != State.FINISHED) {
-                                AbstractBGPSessionNegotiator.this
-                                    .sendMessage(buildErrorNotify(BGPError.HOLD_TIMER_EXPIRED));
-                                negotiationFailed(new BGPDocumentedException("HoldTimer expired", BGPError.FSM_ERROR));
-                                AbstractBGPSessionNegotiator.this.state = State.FINISHED;
-                            }
+                this.pending = this.channel.eventLoop().schedule(() -> {
+                    synchronized (AbstractBGPSessionNegotiator.this) {
+                        AbstractBGPSessionNegotiator.this.pending = null;
+                        if (AbstractBGPSessionNegotiator.this.state != State.FINISHED) {
+                            AbstractBGPSessionNegotiator.this
+                                .sendMessage(buildErrorNotify(BGPError.HOLD_TIMER_EXPIRED));
+                            negotiationFailed(new BGPDocumentedException("HoldTimer expired", BGPError.FSM_ERROR));
+                            AbstractBGPSessionNegotiator.this.state = State.FINISHED;
                         }
                     }
                 }, INITIAL_HOLDTIMER, TimeUnit.MINUTES);
@@ -266,15 +263,12 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter
     }
 
     private void sendMessage(final Notification msg) {
-        this.channel.writeAndFlush(msg).addListener(new ChannelFutureListener() {
-            @Override
-            public void operationComplete(final ChannelFuture f) {
-                if (!f.isSuccess()) {
-                    LOG.warn("Failed to send message {} to channel {}", msg,  AbstractBGPSessionNegotiator.this.channel, f.cause());
-                    negotiationFailedCloseChannel(f.cause());
-                } else {
-                    LOG.trace("Message {} sent to channel {}", msg, AbstractBGPSessionNegotiator.this.channel);
-                }
+        this.channel.writeAndFlush(msg).addListener((ChannelFutureListener) f -> {
+            if (!f.isSuccess()) {
+                LOG.warn("Failed to send message {} to channel {}", msg,  AbstractBGPSessionNegotiator.this.channel, f.cause());
+                negotiationFailedCloseChannel(f.cause());
+            } else {
+                LOG.trace("Message {} sent to channel {}", msg, AbstractBGPSessionNegotiator.this.channel);
             }
         });
     }
index 26a12fb4d4e9a17d5ec45cb001334f868714a32a..5a41cf2d368dc1261637af6d879eb3b2259b93d3 100644 (file)
@@ -43,14 +43,11 @@ public class BgpPeerRpc implements BgpPeerRpcService {
     public Future<RpcResult<Void>> routeRefreshRequest(final RouteRefreshRequestInput input) {
         final ChannelFuture f = sendRRMessage(input);
         if (f != null) {
-            return Futures.transform(JdkFutureAdapters.listenInPoolThread(f), new Function<Void, RpcResult<Void>>() {
-                @Override
-                public RpcResult<Void> apply(final Void input) {
-                    if (f.isSuccess()) {
-                        return RpcResultBuilder.<Void>success().build();
-                    } else {
-                        return RpcResultBuilder.<Void>failed().withError(ErrorType.RPC, FAILURE_MSG).build();
-                    }
+            return Futures.transform(JdkFutureAdapters.listenInPoolThread(f), (Function<Void, RpcResult<Void>>) input1 -> {
+                if (f.isSuccess()) {
+                    return RpcResultBuilder.<Void>success().build();
+                } else {
+                    return RpcResultBuilder.<Void>failed().withError(ErrorType.RPC, FAILURE_MSG).build();
                 }
             });
         }
index 499ae8bbc8b6dc37fcc818391ead43d99ef058aa..a1dd4586005aa56574805c19aa5781abdfe1729a 100644 (file)
@@ -115,25 +115,19 @@ public class BGPSessionImplTest {
         final ChannelFuture f = mock(ChannelFuture.class);
         doReturn(null).when(f).addListener(Mockito.any());
 
-        doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) {
-                final Object[] args = invocation.getArguments();
-                BGPSessionImplTest.this.receivedMsgs.add((Notification) args[0]);
-                return f;
-            }
+        doAnswer(invocation -> {
+            final Object[] args = invocation.getArguments();
+            BGPSessionImplTest.this.receivedMsgs.add((Notification) args[0]);
+            return f;
         }).when(this.speakerListener).writeAndFlush(Mockito.any(Notification.class));
         doReturn(this.eventLoop).when(this.speakerListener).eventLoop();
         doReturn(true).when(this.speakerListener).isActive();
-        doAnswer(new Answer<Void>() {
-            @Override
-            public Void answer(final InvocationOnMock invocation) throws Throwable {
-                final Runnable command = (Runnable) invocation.getArguments()[0];
-                final long delay = (long) invocation.getArguments()[1];
-                final TimeUnit unit = (TimeUnit) invocation.getArguments()[2];
-                GlobalEventExecutor.INSTANCE.schedule(command, delay, unit);
-                return null;
-            }
+        doAnswer(invocation -> {
+            final Runnable command = (Runnable) invocation.getArguments()[0];
+            final long delay = (long) invocation.getArguments()[1];
+            final TimeUnit unit = (TimeUnit) invocation.getArguments()[2];
+            GlobalEventExecutor.INSTANCE.schedule(command, delay, unit);
+            return null;
         }).when(this.eventLoop).schedule(Mockito.any(Runnable.class), Mockito.any(long.class), Mockito.any(TimeUnit.class));
         doReturn("TestingChannel").when(this.speakerListener).toString();
         doReturn(true).when(this.speakerListener).isWritable();
index 4e90b99b234b6107d5bcc20cdff464a6f729dcbe..ef09a18db15effb8cfdf253d764ee47be51e389d 100644 (file)
@@ -119,13 +119,10 @@ public class FSMTest {
         doReturn(null).when(f).addListener(any(GenericFutureListener.class));
 
         final InetAddress peerAddress = InetAddress.getByName("1.1.1.2");
-        doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) {
-                final Object[] args = invocation.getArguments();
-                FSMTest.this.receivedMsgs.add((Notification) args[0]);
-                return f;
-            }
+        doAnswer(invocation -> {
+            final Object[] args = invocation.getArguments();
+            FSMTest.this.receivedMsgs.add((Notification) args[0]);
+            return f;
         }).when(this.speakerListener).writeAndFlush(any(Notification.class));
         doReturn(this.eventLoop).when(this.speakerListener).eventLoop();
         doReturn(null).when(this.eventLoop).schedule(any(Runnable.class), any(long.class), any(TimeUnit.class));
index 74cac34aeecbb01c6d6662260ec369ef031c207d..b2ccca18684b50678c32607083d1800013a8003c 100644 (file)
@@ -150,15 +150,12 @@ public class SynchronizationAndExceptionTest extends AbstractAddPathTest {
         doReturn(null).when(mock(ChannelFuture.class)).addListener(any());
         doReturn(this.eventLoop).when(this.speakerListener).eventLoop();
         doReturn(true).when(this.speakerListener).isActive();
-        doAnswer(new Answer<Void>() {
-            @Override
-            public Void answer(final InvocationOnMock invocation) throws Throwable {
-                final Runnable command = (Runnable) invocation.getArguments()[0];
-                final long delay = (long) invocation.getArguments()[1];
-                final TimeUnit unit = (TimeUnit) invocation.getArguments()[2];
-                GlobalEventExecutor.INSTANCE.schedule(command, delay, unit);
-                return null;
-            }
+        doAnswer(invocation -> {
+            final Runnable command = (Runnable) invocation.getArguments()[0];
+            final long delay = (long) invocation.getArguments()[1];
+            final TimeUnit unit = (TimeUnit) invocation.getArguments()[2];
+            GlobalEventExecutor.INSTANCE.schedule(command, delay, unit);
+            return null;
         }).when(this.eventLoop).schedule(any(Runnable.class), any(long.class), any(TimeUnit.class));
         doReturn("TestingChannel").when(this.speakerListener).toString();
         doReturn(true).when(this.speakerListener).isWritable();
@@ -187,13 +184,10 @@ public class SynchronizationAndExceptionTest extends AbstractAddPathTest {
             any(YangInstanceIdentifier.class), any(NormalizedNode.class));
         Mockito.doNothing().when(this.tx).delete(Mockito.any(LogicalDatastoreType.class), Mockito.any(YangInstanceIdentifier.class));
         final CheckedFuture future = mock(CheckedFuture.class);
-        Mockito.doAnswer(new Answer<Void>() {
-            @Override
-            public Void answer(final InvocationOnMock invocation) throws Throwable {
-                final Runnable callback = (Runnable) invocation.getArguments()[0];
-                callback.run();
-                return null;
-            }
+        Mockito.doAnswer(invocation -> {
+            final Runnable callback = (Runnable) invocation.getArguments()[0];
+            callback.run();
+            return null;
         }).when(future).addListener(Mockito.any(Runnable.class), Mockito.any(Executor.class));
         Mockito.doReturn(future).when(this.tx).submit();
         Mockito.doReturn(mock(Optional.class)).when(future).checkedGet();
index 2215b66009738bde3ca72a1144f97e5c79de6108..22c8d543ecb9a7540712b42fc86dfbda1a821bea 100644 (file)
@@ -124,13 +124,10 @@ class AbstractConfig {
         Mockito.doNothing().when(this.domDW).delete(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class));
         Mockito.doNothing().when(this.domDW).merge(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
         final CheckedFuture checkedFuture = mock(CheckedFuture.class);
-        Mockito.doAnswer(new Answer<Void>() {
-            @Override
-            public Void answer(final InvocationOnMock invocation) throws Throwable {
-                final Runnable callback = (Runnable) invocation.getArguments()[0];
-                callback.run();
-                return null;
-            }
+        Mockito.doAnswer(invocation -> {
+            final Runnable callback = (Runnable) invocation.getArguments()[0];
+            callback.run();
+            return null;
         }).when(checkedFuture).addListener(Mockito.any(Runnable.class), Mockito.any(Executor.class));
         Mockito.doReturn(checkedFuture).when(this.domDW).submit();
         Mockito.doReturn(null).when(checkedFuture).checkedGet();
index 475379d4ca0bcb76c5dcceff1cd24fa93497628e..968956288bd244b2468dc1689cd4b7ab509238b6 100644 (file)
@@ -90,12 +90,9 @@ public class RibImplTest extends AbstractConfig {
     @Before
     public void setUp() throws Exception {
         super.setUp();
-        Mockito.doAnswer(new Answer<ClusterSingletonServiceRegistration>() {
-            @Override
-            public ClusterSingletonServiceRegistration answer(final InvocationOnMock invocationOnMock) throws Throwable {
-                RibImplTest.this.singletonService = (ClusterSingletonService) invocationOnMock.getArguments()[0];
-                return RibImplTest.this.singletonServiceRegistration;
-            }
+        Mockito.doAnswer(invocationOnMock -> {
+            RibImplTest.this.singletonService = (ClusterSingletonService) invocationOnMock.getArguments()[0];
+            return RibImplTest.this.singletonServiceRegistration;
         }).when(this.clusterSingletonServiceProvider).registerClusterSingletonService(any(ClusterSingletonService.class));
 
         Mockito.doReturn(mock(GeneratedClassLoadingStrategy.class)).when(this.extension).getClassLoadingStrategy();
index cbff9130af071081d809cf14b0001dc6a0817b49..1f73b04aef952397888ecc1e83c01b4af03d0578 100644 (file)
@@ -91,22 +91,16 @@ public abstract class AbstractRIBSupportTest {
     @Before
     public void setUp() throws Exception {
         MockitoAnnotations.initMocks(this);
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                AbstractRIBSupportTest.this.insertedRoutes.add(AbstractRIBSupportTest.this.mappingService.fromNormalizedNode((YangInstanceIdentifier) args[1], (NormalizedNode<?, ?>) args[2]));
-                return args[1];
-            }
+        Mockito.doAnswer(invocation -> {
+            final Object[] args = invocation.getArguments();
+            AbstractRIBSupportTest.this.insertedRoutes.add(AbstractRIBSupportTest.this.mappingService.fromNormalizedNode((YangInstanceIdentifier) args[1], (NormalizedNode<?, ?>) args[2]));
+            return args[1];
         }).when(this.tx).put(Mockito.any(LogicalDatastoreType.class), Mockito.any(YangInstanceIdentifier.class), Mockito.any(NormalizedNode.class));
 
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                AbstractRIBSupportTest.this.deletedRoutes.add(AbstractRIBSupportTest.this.mappingService.fromYangInstanceIdentifier((YangInstanceIdentifier) args[1]));
-                return args[1];
-            }
+        Mockito.doAnswer(invocation -> {
+            final Object[] args = invocation.getArguments();
+            AbstractRIBSupportTest.this.deletedRoutes.add(AbstractRIBSupportTest.this.mappingService.fromYangInstanceIdentifier((YangInstanceIdentifier) args[1]));
+            return args[1];
         }).when(this.tx).delete(Mockito.any(LogicalDatastoreType.class), Mockito.any(YangInstanceIdentifier.class));
         this.deletedRoutes = new ArrayList<>();
         this.insertedRoutes = new ArrayList<>();
index 97434d79165d4823b4e1fa918a0731c8afcc6bbf..30f16db62cbd9babfe6c30219b2fbd5b5c89ab06 100644 (file)
@@ -205,7 +205,7 @@ public class LinkstateTopologyBuilder extends AbstractTopologyBuilder<LinkstateR
             }
 
             // Re-generate termination points
-            this.nb.setTerminationPoint(Lists.newArrayList(Collections2.transform(this.tps.values(), input -> input.getTp())));
+            this.nb.setTerminationPoint(Lists.newArrayList(Collections2.transform(this.tps.values(), TpHolder::getTp)));
 
             // Re-generate prefixes
             this.inab.setPrefix(Lists.newArrayList(this.prefixes.values()));
index 6346b7f8261ee747dba4f0f2f87bd9ad202178d5..d4a7889472c16288ae4254ff3b81804e5d6e889a 100644 (file)
@@ -22,12 +22,7 @@ public abstract class AbstractTopologyBuilderModuleTest extends AbstractRIBImplM
     @Override
     public final void setUp() throws Exception {
         super.setUp();
-        setupMockService(TopologyReference.class, new TopologyReference() {
-            @Override
-            public InstanceIdentifier<Topology> getInstanceIdentifier() {
-                return null;
-            }
-        });
+        setupMockService(TopologyReference.class, (TopologyReference) () -> null);
         setupMockService(BgpTopologyDeployer.class, new BgpTopologyDeployer() {
             @Override
             public AbstractRegistration registerTopologyProvider(final BgpTopologyProvider topologyBuilder) {
index 06a8ea0f7f16e2f176f3349eb37181d1e1560e4c..af933e15c6ed3b91c1b7fcd951d5029475d84f72 100644 (file)
@@ -148,31 +148,28 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
     }
 
     private void scheduleFailTimer() {
-        this.failTimer = this.channel.eventLoop().schedule(new Runnable() {
-            @Override
-            public void run() {
-                switch (AbstractPCEPSessionNegotiator.this.state) {
-                case FINISHED:
-                case IDLE:
-                    break;
-                case START_TLS_WAIT:
-                    sendErrorMessage(PCEPErrors.STARTTLS_TIMER_EXP);
-                    negotiationFailed(new TimeoutException("StartTLSWait timer expired"));
-                    AbstractPCEPSessionNegotiator.this.state = State.FINISHED;
-                    break;
-                case KEEP_WAIT:
-                    sendErrorMessage(PCEPErrors.NO_MSG_BEFORE_EXP_KEEPWAIT);
-                    negotiationFailed(new TimeoutException("KeepWait timer expired"));
-                    AbstractPCEPSessionNegotiator.this.state = State.FINISHED;
-                    break;
-                case OPEN_WAIT:
-                    sendErrorMessage(PCEPErrors.NO_OPEN_BEFORE_EXP_OPENWAIT);
-                    negotiationFailed(new TimeoutException("OpenWait timer expired"));
-                    AbstractPCEPSessionNegotiator.this.state = State.FINISHED;
-                    break;
-                default:
-                    break;
-                }
+        this.failTimer = this.channel.eventLoop().schedule((Runnable) () -> {
+            switch (AbstractPCEPSessionNegotiator.this.state) {
+            case FINISHED:
+            case IDLE:
+                break;
+            case START_TLS_WAIT:
+                sendErrorMessage(PCEPErrors.STARTTLS_TIMER_EXP);
+                negotiationFailed(new TimeoutException("StartTLSWait timer expired"));
+                AbstractPCEPSessionNegotiator.this.state = State.FINISHED;
+                break;
+            case KEEP_WAIT:
+                sendErrorMessage(PCEPErrors.NO_MSG_BEFORE_EXP_KEEPWAIT);
+                negotiationFailed(new TimeoutException("KeepWait timer expired"));
+                AbstractPCEPSessionNegotiator.this.state = State.FINISHED;
+                break;
+            case OPEN_WAIT:
+                sendErrorMessage(PCEPErrors.NO_OPEN_BEFORE_EXP_OPENWAIT);
+                negotiationFailed(new TimeoutException("OpenWait timer expired"));
+                AbstractPCEPSessionNegotiator.this.state = State.FINISHED;
+                break;
+            default:
+                break;
             }
         }, FAIL_TIMER_VALUE, TimeUnit.SECONDS);
     }
@@ -188,12 +185,7 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
         } else {
             startNegotiationWithOpen();
         }
-        this.channel.closeFuture().addListener(new ChannelFutureListener() {
-            @Override
-            public void operationComplete(final ChannelFuture f) {
-                cancelTimers();
-            }
-        });
+        this.channel.closeFuture().addListener((ChannelFutureListener) f -> cancelTimers());
     }
 
     private void cancelTimers() {
index 690fe6425f0008fd550e83914d799b6484a52d2b..b3b8163b60176117edf54bfa2e5d97a11909156b 100644 (file)
@@ -43,17 +43,14 @@ public abstract class AbstractSessionNegotiator extends ChannelInboundHandlerAda
     }
 
     protected final void sendMessage(final Message msg) {
-        this.channel.writeAndFlush(msg).addListener(new ChannelFutureListener() {
-            @Override
-            public void operationComplete(final ChannelFuture f) {
-                if (!f.isSuccess()) {
-                    LOG.info("Failed to send message {}", msg, f.cause());
-                    negotiationFailed(f.cause());
-                } else {
-                    LOG.trace("Message {} sent to socket", msg);
-                }
-
+        this.channel.writeAndFlush(msg).addListener((ChannelFutureListener) f -> {
+            if (!f.isSuccess()) {
+                LOG.info("Failed to send message {}", msg, f.cause());
+                negotiationFailed(f.cause());
+            } else {
+                LOG.trace("Message {} sent to socket", msg);
             }
+
         });
     }
 
index 2b3809ead0a98fb5120b03b8b8a897b256acb16c..261e2aaab910965e81c1ca0a0050fb3b791a5a1a 100644 (file)
@@ -57,14 +57,11 @@ public final class PCEPByteToMessageDecoder extends ByteToMessageDecoder {
         if (!errors.isEmpty()) {
             // We have a bunch of messages, send them out
             for (final Object e : errors) {
-                ctx.channel().writeAndFlush(e).addListener(new ChannelFutureListener() {
-                    @Override
-                    public void operationComplete(final ChannelFuture f) {
-                        if (!f.isSuccess()) {
-                            LOG.warn("Failed to send message {} to socket {}", e, ctx.channel(), f.cause());
-                        } else {
-                            LOG.trace("Message {} sent to socket {}", e, ctx.channel());
-                        }
+                ctx.channel().writeAndFlush(e).addListener((ChannelFutureListener) f -> {
+                    if (!f.isSuccess()) {
+                        LOG.warn("Failed to send message {} to socket {}", e, ctx.channel(), f.cause());
+                    } else {
+                        LOG.trace("Message {} sent to socket {}", e, ctx.channel());
                     }
                 });
             }
index dfb732b9dfad75b1e9b33a3ed691e74c442bad4f..49c3ca41c495cebe5303c24a6efeabb3acfad713 100644 (file)
@@ -73,23 +73,13 @@ final class PCEPPeerRegistry {
     }
 
     protected synchronized Short nextSession(final byte[] clientAddress) throws ExecutionException {
-        final PeerRecord peer = this.formerClients.get(new ByteArrayWrapper(clientAddress), new Callable<PeerRecord>() {
-            @Override
-            public PeerRecord call() {
-                return new PeerRecord(ID_CACHE_SECONDS, null);
-            }
-        });
+        final PeerRecord peer = this.formerClients.get(new ByteArrayWrapper(clientAddress), () -> new PeerRecord(ID_CACHE_SECONDS, null));
 
         return peer.allocId();
     }
 
     protected synchronized void releaseSession(final byte[] clientAddress, final short sessionId) throws ExecutionException {
-        this.formerClients.get(new ByteArrayWrapper(clientAddress), new Callable<PeerRecord>() {
-            @Override
-            public PeerRecord call() {
-                return new PeerRecord(ID_CACHE_SECONDS, sessionId);
-            }
-        });
+        this.formerClients.get(new ByteArrayWrapper(clientAddress), () -> new PeerRecord(ID_CACHE_SECONDS, sessionId));
     }
 
     private static final class ByteArrayWrapper {
index f1daf29119e4337cffe001e79d47e7dae57cfa23..d8de880e076ab396a53f9af139e3285c2d44dfe5 100755 (executable)
@@ -111,14 +111,11 @@ public final class PCEPProtocolSessionPromise<S extends PCEPSession> extends Def
                     }
 
                     final EventLoop loop = cf.channel().eventLoop();
-                    loop.schedule(new Runnable() {
-                        @Override
-                        public void run() {
-                            PCEPProtocolSessionPromise.LOG.debug("Attempting to connect to {}", PCEPProtocolSessionPromise.this.address);
-                            final Future reconnectFuture = PCEPProtocolSessionPromise.this.b.connect();
-                            reconnectFuture.addListener(PCEPProtocolSessionPromise.BootstrapConnectListener.this);
-                            PCEPProtocolSessionPromise.this.pending = reconnectFuture;
-                        }
+                    loop.schedule(() -> {
+                        PCEPProtocolSessionPromise.LOG.debug("Attempting to connect to {}", PCEPProtocolSessionPromise.this.address);
+                        final Future reconnectFuture = PCEPProtocolSessionPromise.this.b.connect();
+                        reconnectFuture.addListener(BootstrapConnectListener.this);
+                        PCEPProtocolSessionPromise.this.pending = reconnectFuture;
                     }, PCEPProtocolSessionPromise.this.retryTimer, TimeUnit.SECONDS);
                     PCEPProtocolSessionPromise.LOG.debug("Next reconnection attempt in {}s", PCEPProtocolSessionPromise.this.retryTimer);
                 }
index 8c01919f59ba53f31f244e4ee989768098917d33..46004e0faddec1c4e452ade8ac0f52000afa3e0d 100644 (file)
@@ -94,12 +94,9 @@ public class PCEPSessionNegotiator extends AbstractSessionNegotiator {
                 }
             });
 
-            this.channel.closeFuture().addListener(new ChannelFutureListener() {
-                @Override
-                public void operationComplete(final ChannelFuture future) {
-                    synchronized (lock) {
-                        sessionReg.removeSessionReference(clientAddress);
-                    }
+            this.channel.closeFuture().addListener((ChannelFutureListener) future -> {
+                synchronized (lock) {
+                    sessionReg.removeSessionReference(clientAddress);
                 }
             });
 
index f42aca5f751e7da532709349d888e931f2337b0b..933ffac672a003d8d25e61fd4b254ded1c3d2750 100644 (file)
@@ -82,13 +82,10 @@ public class AbstractPCEPSessionTest {
     public final void setUp() {
         MockitoAnnotations.initMocks(this);
         final ChannelFuture future = new DefaultChannelPromise(this.channel);
-        doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) {
-                final Object[] args = invocation.getArguments();
-                AbstractPCEPSessionTest.this.msgsSend.add((Notification) args[0]);
-                return future;
-            }
+        doAnswer(invocation -> {
+            final Object[] args = invocation.getArguments();
+            AbstractPCEPSessionTest.this.msgsSend.add((Notification) args[0]);
+            return future;
         }).when(this.channel).writeAndFlush(any(Notification.class));
         doReturn(this.channelFuture).when(this.channel).closeFuture();
         doReturn(this.channelFuture).when(this.channelFuture).addListener(any(GenericFutureListener.class));
index 59d2bb8e5b87fe8b24beff7ed8d825a08b736b58..4721e82baf5c1a58a34feca8f7ce499ede758df4 100755 (executable)
@@ -140,11 +140,6 @@ public final class Main {
     }
 
     private static ch.qos.logback.classic.Logger getRootLogger(final LoggerContext lc) {
-        return Iterables.find(lc.getLoggerList(), new Predicate<Logger>() {
-            @Override
-            public boolean apply(final Logger input) {
-                return (input != null) ? input.getName().equals(Logger.ROOT_LOGGER_NAME) : false;
-            }
-        });
+        return Iterables.find(lc.getLoggerList(), input -> (input != null) ? input.getName().equals(Logger.ROOT_LOGGER_NAME) : false);
     }
 }
index 62ae0f80b48afadc4ea8bfba6670b31f136f6604..f63a8e6a069bd770f51b61411b93b2503c386b95 100644 (file)
@@ -404,15 +404,12 @@ public final class PCCTunnelManagerImpl implements PCCTunnelManager {
 
     private void startStateTimeout(final PCCTunnel tunnel, final PlspId plspId) {
         if (this.stateTimeout > -1) {
-            final Timeout newStateTimeout = this.timer.newTimeout(new TimerTask() {
-                @Override
-                public void run(final Timeout timeout) throws Exception {
-                    if (tunnel.getType() == LspType.PCE_LSP) {
-                        PCCTunnelManagerImpl.this.tunnels.remove(plspId);
-                        //report tunnel removal to all
-                        sendToAll(tunnel, plspId, Collections.emptyList(), createSrp(0), new PathBuilder().build(),
-                            createLsp(plspId.getValue(), false, Optional.absent(), false, true));
-                    }
+            final Timeout newStateTimeout = this.timer.newTimeout(timeout -> {
+                if (tunnel.getType() == LspType.PCE_LSP) {
+                    PCCTunnelManagerImpl.this.tunnels.remove(plspId);
+                    //report tunnel removal to all
+                    sendToAll(tunnel, plspId, Collections.emptyList(), createSrp(0), new PathBuilder().build(),
+                        createLsp(plspId.getValue(), false, Optional.absent(), false, true));
                 }
             }, this.stateTimeout, TimeUnit.SECONDS);
             tunnel.setStateTimeout(newStateTimeout);
@@ -420,29 +417,26 @@ public final class PCCTunnelManagerImpl implements PCCTunnelManager {
     }
 
     private void startRedelegationTimer(final PCCTunnel tunnel, final PlspId plspId, final PCCSession session) {
-        final Timeout newRedelegationTimeout = this.timer.newTimeout(new TimerTask() {
-            @Override
-            public void run(final Timeout timeout) throws Exception {
-                //remove delegation
-                PCCTunnelManagerImpl.this.setDelegation(plspId, null);
-                //delegate to another PCE
-                int index = session.getId();
-                for (int i = 1; i < PCCTunnelManagerImpl.this.sessions.size(); i++) {
-                    index++;
-                    if (index == PCCTunnelManagerImpl.this.sessions.size()) {
-                        index = 0;
-                    }
-                    final PCCSession nextSession = PCCTunnelManagerImpl.this.sessions.get(index);
-                    if (nextSession != null) {
-                        tunnel.cancelTimeouts();
-                        final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.absent());
-
-                        nextSession.sendReport(createPcRtpMessage(
-                            createLsp(plspId.getValue(), true, Optional.fromNullable(tlvs), true, false), NO_SRP,
-                            tunnel.getLspState()));
-                        tunnel.setDelegationHolder(nextSession.getId());
-                        break;
-                    }
+        final Timeout newRedelegationTimeout = this.timer.newTimeout(timeout -> {
+            //remove delegation
+            PCCTunnelManagerImpl.this.setDelegation(plspId, null);
+            //delegate to another PCE
+            int index = session.getId();
+            for (int i = 1; i < PCCTunnelManagerImpl.this.sessions.size(); i++) {
+                index++;
+                if (index == PCCTunnelManagerImpl.this.sessions.size()) {
+                    index = 0;
+                }
+                final PCCSession nextSession = PCCTunnelManagerImpl.this.sessions.get(index);
+                if (nextSession != null) {
+                    tunnel.cancelTimeouts();
+                    final Tlvs tlvs = buildTlvs(tunnel, plspId.getValue(), Optional.absent());
+
+                    nextSession.sendReport(createPcRtpMessage(
+                        createLsp(plspId.getValue(), true, Optional.fromNullable(tlvs), true, false), NO_SRP,
+                        tunnel.getLspState()));
+                    tunnel.setDelegationHolder(nextSession.getId());
+                    break;
                 }
             }
         }, this.redelegationTimeout, TimeUnit.SECONDS);
index aa960dad85cc7b917bdd8305a71ab9ad9f73267c..12b630728b8b2b337879e19838609a6c2560ccd7 100644 (file)
@@ -76,21 +76,15 @@ public class PCCTunnelManagerImplTest {
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         Mockito.doNothing().when(this.session1).sendReport(Mockito.any(Pcrpt.class));
-        Mockito.doAnswer(new Answer<Void>() {
-            @Override
-            public Void answer(final InvocationOnMock invocation) throws Throwable {
-                PCCTunnelManagerImplTest.this.errorsSession1.add(getError((Pcerr) invocation.getArguments()[0]));
-                return null;
-            }
+        Mockito.doAnswer(invocation -> {
+            PCCTunnelManagerImplTest.this.errorsSession1.add(getError((Pcerr) invocation.getArguments()[0]));
+            return null;
         }).when(this.session1).sendError(Mockito.any(Pcerr.class));
         Mockito.doReturn(0).when(this.session1).getId();
         Mockito.doNothing().when(this.session2).sendReport(Mockito.any(Pcrpt.class));
-        Mockito.doAnswer(new Answer<Void>() {
-            @Override
-            public Void answer(final InvocationOnMock invocation) throws Throwable {
-                PCCTunnelManagerImplTest.this.errorsSession2.add(getError((Pcerr) invocation.getArguments()[0]));
-                return null;
-            }
+        Mockito.doAnswer(invocation -> {
+            PCCTunnelManagerImplTest.this.errorsSession2.add(getError((Pcerr) invocation.getArguments()[0]));
+            return null;
         }).when(this.session2).sendError(Mockito.any(Pcerr.class));
         Mockito.doReturn(1).when(this.session2).getId();
     }
index 50bd8c09f1456ac442dea2697356d468e6082e8e..00a4d3e9c85bfea0779199cf02cfe40950125233 100644 (file)
@@ -37,12 +37,7 @@ public class PCCMock {
         final InetSocketAddress clientAddr = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(0);
 
         try (final PCCDispatcherImpl pccDispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry())) {
-            pccDispatcher.createClient(serverAddr, -1, new PCEPSessionListenerFactory() {
-                @Override
-                public PCEPSessionListener getSessionListener() {
-                    return new SimpleSessionListener();
-                }
-            }, snf, null, clientAddr).get();
+            pccDispatcher.createClient(serverAddr, -1, SimpleSessionListener::new, snf, null, clientAddr).get();
         }
     }
 }
index 8f804cfbc6a61f1bc8fc97ed48bcc422a60fad50..2dce4eece3e7e30d0ab0bc4749e60ac976f916fa 100755 (executable)
@@ -352,19 +352,16 @@ public abstract class AbstractTopologySessionListener<S, L> implements PCEPSessi
             setupTimeoutHandler(requestId, req, rpcTimeout);
         }
 
-        f.addListener(new FutureListener<Void>() {
-            @Override
-            public void operationComplete(final io.netty.util.concurrent.Future<Void> future) {
-                if (!future.isSuccess()) {
-                    synchronized (AbstractTopologySessionListener.this) {
-                        AbstractTopologySessionListener.this.requests.remove(requestId);
-                    }
-                    req.done(OperationResults.UNSENT);
-                    LOG.info("Failed to send request {}, instruction cancelled", requestId, future.cause());
-                } else {
-                    req.sent();
-                    LOG.trace("Request {} sent to peer (object {})", requestId, req);
+        f.addListener((FutureListener<Void>) future -> {
+            if (!future.isSuccess()) {
+                synchronized (AbstractTopologySessionListener.this) {
+                    AbstractTopologySessionListener.this.requests.remove(requestId);
                 }
+                req.done(OperationResults.UNSENT);
+                LOG.info("Failed to send request {}, instruction cancelled", requestId, future.cause());
+            } else {
+                req.sent();
+                LOG.trace("Request {} sent to peer (object {})", requestId, req);
             }
         });
 
index f12997cee9f5087ed7d8689f736b5677d0c6d2e2..66f69f8a2e8408943ea6dd29aa9511a8eb555200 100644 (file)
@@ -31,12 +31,7 @@ final class OperationResults implements OperationResult {
     static final OperationResults SUCCESS = new OperationResults((FailureType)null);
     static final OperationResults UNSENT = new OperationResults(FailureType.Unsent);
 
-    private static final Function<Errors, Error> CONVERT_ERRORS = new Function<Errors, Error>() {
-        @Override
-        public Error apply(final Errors input) {
-            return new ErrorBuilder(input).build();
-        }
-    };
+    private static final Function<Errors, Error> CONVERT_ERRORS = input -> new ErrorBuilder(input).build();
 
     private final FailureType failure;
     private final List<Error> error;
index 7d34cdf3e88b33b3f86e43ea68deedd0838afdc7..7ce02e810086d07a2099c4b69557a7c837550bfa 100644 (file)
@@ -514,18 +514,15 @@ class Stateful07TopologySessionListener extends AbstractTopologySessionListener<
         if (f == null) {
             return OperationResults.createUnsent(PCEPErrors.LSP_INTERNAL_ERROR).future();
         }
-        return Futures.transform(f, new AsyncFunction<Optional<ReportedLsp>, OperationResult>() {
-            @Override
-            public ListenableFuture<OperationResult> apply(final Optional<ReportedLsp> rep) {
-                final Lsp reportedLsp = validateReportedLsp(rep, input);
-                if (reportedLsp == null) {
-                    return OperationResults.createUnsent(PCEPErrors.UNKNOWN_PLSP_ID).future();
-                }
-                final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
-                final Requests rb = buildRequest(rep, reportedLsp);
-                ib.setRequests(Collections.singletonList(rb));
-                return sendMessage(new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build(), rb.getSrp().getOperationId(), null);
+        return Futures.transform(f, (AsyncFunction<Optional<ReportedLsp>, OperationResult>) rep -> {
+            final Lsp reportedLsp = validateReportedLsp(rep, input);
+            if (reportedLsp == null) {
+                return OperationResults.createUnsent(PCEPErrors.UNKNOWN_PLSP_ID).future();
             }
+            final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
+            final Requests rb = buildRequest(rep, reportedLsp);
+            ib.setRequests(Collections.singletonList(rb));
+            return sendMessage(new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build(), rb.getSrp().getOperationId(), null);
         });
     }
 
@@ -659,26 +656,23 @@ class Stateful07TopologySessionListener extends AbstractTopologySessionListener<
     }
 
     private ListenableFuture<OperationResult> listenableFuture(final ListenableFuture<Optional<ReportedLsp>> f, final EnsureLspOperationalInput input, final OperationalStatus op) {
-        return Futures.transform(f, new Function<Optional<ReportedLsp>, OperationResult>() {
-            @Override
-            public OperationResult apply(final Optional<ReportedLsp> rep) {
-                if (!rep.isPresent()) {
-                    LOG.debug("Node {} does not contain LSP {}", input.getNode(), input.getName());
+        return Futures.transform(f, (Function<Optional<ReportedLsp>, OperationResult>) rep -> {
+            if (!rep.isPresent()) {
+                LOG.debug("Node {} does not contain LSP {}", input.getNode(), input.getName());
+                return OperationResults.UNSENT;
+            }
+            // check if at least one of the paths has the same status as requested
+            for (final Path p : rep.get().getPath()) {
+                final Path1 p1 = p.getAugmentation(Path1.class);
+                if (p1 == null) {
+                    LOG.warn("Node {} LSP {} does not contain data", input.getNode(), input.getName());
                     return OperationResults.UNSENT;
                 }
-                // check if at least one of the paths has the same status as requested
-                for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.Path p : rep.get().getPath()) {
-                    final Path1 p1 = p.getAugmentation(Path1.class);
-                    if (p1 == null) {
-                        LOG.warn("Node {} LSP {} does not contain data", input.getNode(), input.getName());
-                        return OperationResults.UNSENT;
-                    }
-                    if (op.equals(p1.getLsp().getOperational())) {
-                        return OperationResults.SUCCESS;
-                    }
+                if (op.equals(p1.getLsp().getOperational())) {
+                    return OperationResults.SUCCESS;
                 }
-                return OperationResults.UNSENT;
             }
+            return OperationResults.UNSENT;
         });
     }
 
index 1bbbe365e891881b7f6b7cf3194dfc7475d439ab..03f67c3dac7e0e2ba1751808675a2bc21a2592f7 100644 (file)
@@ -40,52 +40,27 @@ final class TopologyRPCs implements NetworkTopologyPcepService {
 
     @Override
     public Future<RpcResult<AddLspOutput>> addLsp(final AddLspInput input) {
-        return Futures.transform(manager.addLsp(input), new Function<OperationResult, RpcResult<AddLspOutput>>() {
-            @Override
-            public RpcResult<AddLspOutput> apply(final OperationResult input) {
-                return SuccessfulRpcResult.create(new AddLspOutputBuilder(input).build());
-            }
-        });
+        return Futures.transform(manager.addLsp(input), (Function<OperationResult, RpcResult<AddLspOutput>>) input1 -> SuccessfulRpcResult.create(new AddLspOutputBuilder(input1).build()));
     }
 
     @Override
     public Future<RpcResult<RemoveLspOutput>> removeLsp(final RemoveLspInput input) {
-        return Futures.transform(manager.removeLsp(input), new Function<OperationResult, RpcResult<RemoveLspOutput>>() {
-            @Override
-            public RpcResult<RemoveLspOutput> apply(final OperationResult input) {
-                return SuccessfulRpcResult.create(new RemoveLspOutputBuilder(input).build());
-            }
-        });
+        return Futures.transform(manager.removeLsp(input), (Function<OperationResult, RpcResult<RemoveLspOutput>>) input1 -> SuccessfulRpcResult.create(new RemoveLspOutputBuilder(input1).build()));
     }
 
     @Override
     public Future<RpcResult<TriggerSyncOutput>> triggerSync(final TriggerSyncInput input) {
-        return Futures.transform(manager.triggerSync(input), new Function<OperationResult, RpcResult<TriggerSyncOutput>>() {
-            @Override
-            public RpcResult<TriggerSyncOutput> apply(final OperationResult input) {
-                return SuccessfulRpcResult.create(new TriggerSyncOutputBuilder(input).build());
-            }
-        });
+        return Futures.transform(manager.triggerSync(input), (Function<OperationResult, RpcResult<TriggerSyncOutput>>) input1 -> SuccessfulRpcResult.create(new TriggerSyncOutputBuilder(input1).build()));
     }
 
     @Override
     public Future<RpcResult<UpdateLspOutput>> updateLsp(final UpdateLspInput input) {
-        return Futures.transform(manager.updateLsp(input), new Function<OperationResult, RpcResult<UpdateLspOutput>>() {
-            @Override
-            public RpcResult<UpdateLspOutput> apply(final OperationResult input) {
-                return SuccessfulRpcResult.create(new UpdateLspOutputBuilder(input).build());
-            }
-        });
+        return Futures.transform(manager.updateLsp(input), (Function<OperationResult, RpcResult<UpdateLspOutput>>) input1 -> SuccessfulRpcResult.create(new UpdateLspOutputBuilder(input1).build()));
     }
 
     @Override
     public Future<RpcResult<EnsureLspOperationalOutput>> ensureLspOperational(final EnsureLspOperationalInput input) {
         return Futures.transform(manager.ensureLspOperational(input),
-                new Function<OperationResult, RpcResult<EnsureLspOperationalOutput>>() {
-                    @Override
-                    public RpcResult<EnsureLspOperationalOutput> apply(final OperationResult input) {
-                        return SuccessfulRpcResult.create(new EnsureLspOperationalOutputBuilder(input).build());
-                    }
-                });
+            (Function<OperationResult, RpcResult<EnsureLspOperationalOutput>>) input1 -> SuccessfulRpcResult.create(new EnsureLspOperationalOutputBuilder(input1).build()));
     }
 }
index 5ba578d2e0dc50dd9877fd8debe188a1d0659aac..1ba365350ca5255277ed590eae6fdd6930738721 100644 (file)
@@ -107,12 +107,7 @@ final class CreateTunnelInstructionExecutor extends AbstractInstructionExecutor
 
             return Futures.transform(
                 (ListenableFuture<RpcResult<AddLspOutput>>) this.topologyService.addLsp(addLspInput),
-                new Function<RpcResult<AddLspOutput>, OperationResult>() {
-                    @Override
-                    public OperationResult apply(final RpcResult<AddLspOutput> input) {
-                        return input.getResult();
-                    }
-                });
+                (Function<RpcResult<AddLspOutput>, OperationResult>) RpcResult::getResult);
         }
     }
 
index 8c67f65acdd529a0a5e3d38893e721e675696ad3..d906dce77d627f84c25c16364707788592d04972 100644 (file)
@@ -67,12 +67,7 @@ final class DestroyTunnelInstructionExecutor extends AbstractInstructionExecutor
             ab.setNode(node.getSupportingNode().get(0).getKey().getNodeRef());
             return Futures.transform(
                 (ListenableFuture<RpcResult<RemoveLspOutput>>) this.topologyService.removeLsp(ab.build()),
-                new Function<RpcResult<RemoveLspOutput>, OperationResult>() {
-                    @Override
-                    public OperationResult apply(final RpcResult<RemoveLspOutput> input) {
-                        return input.getResult();
-                    }
-                });
+                (Function<RpcResult<RemoveLspOutput>, OperationResult>) RpcResult::getResult);
         }
     }
 }
index e7fba2bc7e9305bdfe72771f8f24195a89173db0..7e9ff4298ed15f06ac7a7a625afc59cdaaeeaad0 100644 (file)
@@ -74,12 +74,7 @@ final class UpdateTunnelInstructionExecutor extends AbstractInstructionExecutor
             }
             return Futures.transform(
                 (ListenableFuture<RpcResult<UpdateLspOutput>>) this.topologyService.updateLsp(buildUpdateInput(link, node)),
-                new Function<RpcResult<UpdateLspOutput>, OperationResult>() {
-                    @Override
-                    public OperationResult apply(final RpcResult<UpdateLspOutput> input) {
-                        return input.getResult();
-                    }
-                });
+                (Function<RpcResult<UpdateLspOutput>, OperationResult>) RpcResult::getResult);
         }
     }
 
index 5cd68a060516cba1a0dc3b4fbeb6a7c8ad0d8121..417f62764c06f43aa8ef59c7cfa63984c47c0f73 100644 (file)
@@ -46,13 +46,10 @@ public class SimpleEROSubobjectRegistryTest {
         Mockito.doReturn(new SubobjectContainerBuilder().build()).when(this.rroSubobjectParser).parseSubobject(this.input, false);
         final ArgumentCaptor<SubobjectContainer> arg = ArgumentCaptor.forClass(SubobjectContainer.class);
         final ArgumentCaptor<ByteBuf> bufArg = ArgumentCaptor.forClass(ByteBuf.class);
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                ((ByteBuf) args[1]).writeBoolean(Boolean.TRUE);
-                return null;
-            }
+        Mockito.doAnswer(invocation -> {
+            final Object[] args = invocation.getArguments();
+            ((ByteBuf) args[1]).writeBoolean(Boolean.TRUE);
+            return null;
         }).when(this.rroSubobjectSerializer).serializeSubobject(arg.capture(), bufArg.capture());
     }
 
index 4866e1ca70731a701b2624e92acfb6a0053acd62..273965e2ee2d9fb70eb4f039e7d317864ff8f0f2 100644 (file)
@@ -47,13 +47,10 @@ public class SimpleRROSubobjectRegistryTest {
         Mockito.doReturn(new SubobjectContainerBuilder().build()).when(this.rroSubobjectParser).parseSubobject(this.input);
         final ArgumentCaptor<SubobjectContainer> arg = ArgumentCaptor.forClass(SubobjectContainer.class);
         final ArgumentCaptor<ByteBuf> bufArg = ArgumentCaptor.forClass(ByteBuf.class);
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                ((ByteBuf) args[1]).writeBoolean(Boolean.TRUE);
-                return null;
-            }
+        Mockito.doAnswer(invocation -> {
+            final Object[] args = invocation.getArguments();
+            ((ByteBuf) args[1]).writeBoolean(Boolean.TRUE);
+            return null;
         }).when(this.rroSubobjectSerializer).serializeSubobject(arg.capture(), bufArg.capture());
     }
 
index e1c33ded7d2fc88351512f8d3838389f10fa93a3..396f1da7b639c74c6603a7ab1112427818acdaf8 100644 (file)
@@ -47,13 +47,10 @@ public class SimpleXROSubobjectRegistryTest {
             .input, false);
         final ArgumentCaptor<SubobjectContainer> arg = ArgumentCaptor.forClass(SubobjectContainer.class);
         final ArgumentCaptor<ByteBuf> bufArg = ArgumentCaptor.forClass(ByteBuf.class);
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                final Object[] args = invocation.getArguments();
-                ((ByteBuf) args[1]).writeBoolean(Boolean.TRUE);
-                return null;
-            }
+        Mockito.doAnswer(invocation -> {
+            final Object[] args = invocation.getArguments();
+            ((ByteBuf) args[1]).writeBoolean(Boolean.TRUE);
+            return null;
         }).when(this.rroSubobjectSerializer).serializeSubobject(arg.capture(), bufArg.capture());
     }
 
index cf5d21babcfb1d987700f80e21da6c02be17e38b..d00575f309059e0ec8a93497ce4c17036cc84ad3 100644 (file)
@@ -39,22 +39,16 @@ public class EROSubobjectListParserTest {
 
     @Before
     public void setUp() throws RSVPParsingException {
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                if (((ByteBuf) invocation.getArguments()[1]).readableBytes() == 0) {
-                    return null;
-                }
-                return EROSubobjectListParserTest.this.subObj;
+        Mockito.doAnswer(invocation -> {
+            if (((ByteBuf) invocation.getArguments()[1]).readableBytes() == 0) {
+                return null;
             }
+            return EROSubobjectListParserTest.this.subObj;
         }).when(this.registry).parseSubobject(Mockito.anyInt(), Mockito.any(ByteBuf.class), Mockito.anyBoolean());
         Mockito.doReturn("lala").when(this.subObj).toString();
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                ((ByteBuf) invocation.getArguments()[1]).writeByte(1);
-                return null;
-            }
+        Mockito.doAnswer(invocation -> {
+            ((ByteBuf) invocation.getArguments()[1]).writeByte(1);
+            return null;
         }).when(this.registry).serializeSubobject(Mockito.any(SubobjectContainer.class), Mockito.any(ByteBuf.class));
     }
 
index 9d935da94d500dc55436d87ecaad774ead76235b..ffbaeec6f4dfbc0a20a9b2f0875d0cc9db73262b 100644 (file)
@@ -34,22 +34,16 @@ public class RROSubobjectListParserTest {
 
     @Before
     public void setUp() throws RSVPParsingException {
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                if (((ByteBuf) invocation.getArguments()[1]).readableBytes() == 0) {
-                    return null;
-                }
-                return RROSubobjectListParserTest.this.subObj;
+        Mockito.doAnswer(invocation -> {
+            if (((ByteBuf) invocation.getArguments()[1]).readableBytes() == 0) {
+                return null;
             }
+            return RROSubobjectListParserTest.this.subObj;
         }).when(this.registry).parseSubobject(Mockito.anyInt(), Mockito.any(ByteBuf.class));
         Mockito.doReturn("lala").when(this.subObj).toString();
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                ((ByteBuf) invocation.getArguments()[1]).writeByte(1);
-                return null;
-            }
+        Mockito.doAnswer(invocation -> {
+            ((ByteBuf) invocation.getArguments()[1]).writeByte(1);
+            return null;
         }).when(this.registry).serializeSubobject(Mockito.any(SubobjectContainer.class), Mockito.any(ByteBuf.class));
     }
 
index 5794532ee781564cda9e793de74f4244b20faa3f..ec82d97b4ced7983d6210d807159445f98e4b2c5 100644 (file)
@@ -34,22 +34,16 @@ public class XROSubobjectListParserTest {
 
     @Before
     public void setUp() throws RSVPParsingException {
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                if (((ByteBuf) invocation.getArguments()[1]).readableBytes() == 0) {
-                    return null;
-                }
-                return XROSubobjectListParserTest.this.subObj;
+        Mockito.doAnswer(invocation -> {
+            if (((ByteBuf) invocation.getArguments()[1]).readableBytes() == 0) {
+                return null;
             }
+            return XROSubobjectListParserTest.this.subObj;
         }).when(this.registry).parseSubobject(Mockito.anyInt(), Mockito.any(ByteBuf.class), Mockito.anyBoolean());
         Mockito.doReturn("lala").when(this.subObj).toString();
-        Mockito.doAnswer(new Answer<Object>() {
-            @Override
-            public Object answer(final InvocationOnMock invocation) throws Throwable {
-                ((ByteBuf) invocation.getArguments()[1]).writeByte(1);
-                return null;
-            }
+        Mockito.doAnswer(invocation -> {
+            ((ByteBuf) invocation.getArguments()[1]).writeByte(1);
+            return null;
         }).when(this.registry).serializeSubobject(Mockito.any(SubobjectContainer.class), Mockito.any(ByteBuf.class));
     }