Use lambda expression to simplify statements
Change-Id: Ib8ddac6e93327ade9d42984d8eba66be7047d051
diff --git a/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java b/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java
index 57481c2..ab8a049 100644
--- a/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java
+++ b/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java
@@ -300,21 +300,18 @@
ChannelFactory channelFactory = new NioServerSocketChannelFactory(
newCachedThreadPool(groupedThreads("onos/bgp", "sm-boss-%d")),
newCachedThreadPool(groupedThreads("onos/bgp", "sm-worker-%d")));
- ChannelPipelineFactory pipelineFactory = new ChannelPipelineFactory() {
- @Override
- public ChannelPipeline getPipeline() throws Exception {
- // Allocate a new session per connection
- BgpSession bgpSessionHandler =
- new BgpSession(BgpSessionManager.this);
- BgpFrameDecoder bgpFrameDecoder =
- new BgpFrameDecoder(bgpSessionHandler);
+ ChannelPipelineFactory pipelineFactory = () -> {
+ // Allocate a new session per connection
+ BgpSession bgpSessionHandler =
+ new BgpSession(BgpSessionManager.this);
+ BgpFrameDecoder bgpFrameDecoder =
+ new BgpFrameDecoder(bgpSessionHandler);
- // Setup the processing pipeline
- ChannelPipeline pipeline = Channels.pipeline();
- pipeline.addLast("BgpFrameDecoder", bgpFrameDecoder);
- pipeline.addLast("BgpSession", bgpSessionHandler);
- return pipeline;
- }
+ // Setup the processing pipeline
+ ChannelPipeline pipeline = Channels.pipeline();
+ pipeline.addLast("BgpFrameDecoder", bgpFrameDecoder);
+ pipeline.addLast("BgpSession", bgpSessionHandler);
+ return pipeline;
};
InetSocketAddress listenAddress =
new InetSocketAddress(bgpPort);
diff --git a/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java b/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java
index c4f291ba..6700d53 100644
--- a/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java
+++ b/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java
@@ -159,12 +159,7 @@
bgpService.start(new InternalRouteListener());
- bgpUpdatesExecutor.execute(new Runnable() {
- @Override
- public void run() {
- doUpdatesThread();
- }
- });
+ bgpUpdatesExecutor.execute(this::doUpdatesThread);
}
@Override
diff --git a/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java b/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java
index 634e87b..3f5a6b8 100644
--- a/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java
+++ b/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java
@@ -151,19 +151,15 @@
new NioClientSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool());
- ChannelPipelineFactory pipelineFactory =
- new ChannelPipelineFactory() {
- @Override
- public ChannelPipeline getPipeline() throws Exception {
- // Setup the transmitting pipeline
- ChannelPipeline pipeline = Channels.pipeline();
- pipeline.addLast("TestBgpPeerFrameDecoder",
- peerFrameDecoder);
- pipeline.addLast("TestBgpPeerChannelHandler",
- peerChannelHandler);
- return pipeline;
- }
- };
+ ChannelPipelineFactory pipelineFactory = () -> {
+ // Setup the transmitting pipeline
+ ChannelPipeline pipeline = Channels.pipeline();
+ pipeline.addLast("TestBgpPeerFrameDecoder",
+ peerFrameDecoder);
+ pipeline.addLast("TestBgpPeerChannelHandler",
+ peerChannelHandler);
+ return pipeline;
+ };
peerBootstrap = new ClientBootstrap(channelFactory);
peerBootstrap.setOption("child.keepAlive", true);
diff --git a/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java b/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java
index 27d1ca9..a408e69 100644
--- a/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java
+++ b/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java
@@ -393,13 +393,8 @@
}
private Predicate<? super Host> hasLocalMaster() {
- return new Predicate<Host>() {
- @Override
- public boolean apply(Host host) {
- return mastershipService.getLocalRole(
- host.location().deviceId()).equals(MastershipRole.MASTER);
- }
- };
+ return host -> mastershipService.getLocalRole(
+ host.location().deviceId()).equals(MastershipRole.MASTER);
}
diff --git a/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java b/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
index dffbabf..0c831fd 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/PathIntent.java
@@ -25,7 +25,6 @@
import org.onosproject.net.flow.TrafficTreatment;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import static com.google.common.base.Preconditions.checkArgument;
@@ -159,12 +158,8 @@
* @param links links to be validated
*/
public static void validate(List<Link> links) {
- checkArgument(Iterables.all(links, new Predicate<Link>() {
- @Override
- public boolean apply(Link link) {
- return !link.src().elementId().equals(link.dst().elementId());
- }
- }), "element of src and dst in a link must be different: {}", links);
+ checkArgument(Iterables.all(links, link -> !link.src().elementId().equals(link.dst().elementId())),
+ "element of src and dst in a link must be different: {}", links);
boolean adjacentSame = true;
for (int i = 0; i < links.size() - 1; i++) {
diff --git a/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java b/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java
index 795e4c0..5f52f6d 100644
--- a/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/net/device/DeviceServiceAdapter.java
@@ -15,7 +15,6 @@
*/
package org.onosproject.net.device;
-import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import org.onosproject.net.Device;
@@ -45,13 +44,7 @@
@Override
public Iterable<Device> getAvailableDevices() {
return FluentIterable.from(getDevices())
- .filter(new Predicate<Device>() {
-
- @Override
- public boolean apply(Device input) {
- return isAvailable(input.id());
- }
- });
+ .filter(input -> isAvailable(input.id()));
}
@Override
diff --git a/core/api/src/test/java/org/onosproject/net/intent/FakeIntentManager.java b/core/api/src/test/java/org/onosproject/net/intent/FakeIntentManager.java
index 9b9f7ce..a33d369 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/FakeIntentManager.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/FakeIntentManager.java
@@ -49,30 +49,23 @@
// Provides an out-of-thread simulation of intent submit life-cycle
private void executeSubmit(final Intent intent) {
registerSubclassCompilerIfNeeded(intent);
- executor.execute(new Runnable() {
- @Override
- public void run() {
- try {
- executeCompilingPhase(intent);
- } catch (IntentException e) {
- exceptions.add(e);
- }
+ executor.execute(() -> {
+ try {
+ executeCompilingPhase(intent);
+ } catch (IntentException e) {
+ exceptions.add(e);
}
});
}
// Provides an out-of-thread simulation of intent withdraw life-cycle
private void executeWithdraw(final Intent intent) {
- executor.execute(new Runnable() {
- @Override
- public void run() {
- try {
- List<Intent> installable = getInstallable(intent.key());
- executeWithdrawingPhase(intent, installable);
- } catch (IntentException e) {
- exceptions.add(e);
- }
-
+ executor.execute(() -> {
+ try {
+ List<Intent> installable = getInstallable(intent.key());
+ executeWithdrawingPhase(intent, installable);
+ } catch (IntentException e) {
+ exceptions.add(e);
}
});
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java b/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java
index 60857ca..0067fb2 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/IntentServiceTest.java
@@ -79,13 +79,8 @@
service.submit(intent);
// Allow a small window of time until the intent is in the expected state
- TestTools.assertAfter(GRACE_MS, new Runnable() {
- @Override
- public void run() {
- assertEquals("incorrect intent state", IntentState.INSTALLED,
- service.getIntentState(intent.key()));
- }
- });
+ TestTools.assertAfter(GRACE_MS, () ->
+ assertEquals("incorrect intent state", IntentState.INSTALLED, service.getIntentState(intent.key())));
// Make sure that all expected events have been emitted
validateEvents(intent, INSTALL_REQ, INSTALLED);
@@ -100,13 +95,8 @@
service.withdraw(intent);
// Allow a small window of time until the event is in the expected state
- TestTools.assertAfter(GRACE_MS, new Runnable() {
- @Override
- public void run() {
- assertEquals("incorrect intent state", IntentState.WITHDRAWN,
- service.getIntentState(intent.key()));
- }
- });
+ TestTools.assertAfter(GRACE_MS, () ->
+ assertEquals("incorrect intent state", IntentState.WITHDRAWN, service.getIntentState(intent.key())));
// Make sure that all expected events have been emitted
validateEvents(intent, WITHDRAWN);
@@ -128,13 +118,8 @@
service.submit(intent);
// Allow a small window of time until the intent is in the expected state
- TestTools.assertAfter(GRACE_MS, new Runnable() {
- @Override
- public void run() {
- assertEquals("incorrect intent state", IntentState.FAILED,
- service.getIntentState(intent.key()));
- }
- });
+ TestTools.assertAfter(GRACE_MS, () ->
+ assertEquals("incorrect intent state", IntentState.FAILED, service.getIntentState(intent.key())));
// Make sure that all expected events have been emitted
validateEvents(intent, INSTALL_REQ, FAILED);
@@ -196,13 +181,8 @@
service.submit(intent);
// Allow some time for the intent to be compiled and installed
- TestTools.assertAfter(GRACE_MS, new Runnable() {
- @Override
- public void run() {
- assertEquals("incorrect intent state", IntentState.INSTALLED,
- service.getIntentState(intent.key()));
- }
- });
+ TestTools.assertAfter(GRACE_MS, () ->
+ assertEquals("incorrect intent state", IntentState.INSTALLED, service.getIntentState(intent.key())));
// Make sure that now we have an implicit registration of the compiler
// under the intent subclass
diff --git a/core/api/src/test/java/org/onosproject/net/link/LinkServiceAdapter.java b/core/api/src/test/java/org/onosproject/net/link/LinkServiceAdapter.java
index 5cb84b3..7cd87cd 100644
--- a/core/api/src/test/java/org/onosproject/net/link/LinkServiceAdapter.java
+++ b/core/api/src/test/java/org/onosproject/net/link/LinkServiceAdapter.java
@@ -22,7 +22,6 @@
import org.onosproject.net.Link;
import org.onosproject.net.Link.State;
-import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
/**
@@ -42,13 +41,7 @@
@Override
public Iterable<Link> getActiveLinks() {
return FluentIterable.from(getLinks())
- .filter(new Predicate<Link>() {
-
- @Override
- public boolean apply(Link input) {
- return input.state() == State.ACTIVE;
- }
- });
+ .filter(input -> input.state() == State.ACTIVE);
}
@Override
diff --git a/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java b/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java
index fc90dfa..72fc1b0 100644
--- a/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java
+++ b/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStore.java
@@ -15,7 +15,6 @@
*/
package org.onosproject.store.trivial;
-import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
@@ -134,13 +133,7 @@
@Override
public Iterable<Device> getAvailableDevices() {
return FluentIterable.from(getDevices())
- .filter(new Predicate<Device>() {
-
- @Override
- public boolean apply(Device input) {
- return isAvailable(input.id());
- }
- });
+ .filter(input -> isAvailable(input.id()));
}
@Override
diff --git a/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStoreTest.java b/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStoreTest.java
index 562e6f3..c9e135d 100644
--- a/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStoreTest.java
+++ b/core/common/src/test/java/org/onosproject/store/trivial/SimpleDeviceStoreTest.java
@@ -479,31 +479,22 @@
@Test
public final void testEvents() throws InterruptedException {
final CountDownLatch addLatch = new CountDownLatch(1);
- DeviceStoreDelegate checkAdd = new DeviceStoreDelegate() {
- @Override
- public void notify(DeviceEvent event) {
- assertEquals(DEVICE_ADDED, event.type());
- assertDevice(DID1, SW1, event.subject());
- addLatch.countDown();
- }
+ DeviceStoreDelegate checkAdd = event -> {
+ assertEquals(DEVICE_ADDED, event.type());
+ assertDevice(DID1, SW1, event.subject());
+ addLatch.countDown();
};
final CountDownLatch updateLatch = new CountDownLatch(1);
- DeviceStoreDelegate checkUpdate = new DeviceStoreDelegate() {
- @Override
- public void notify(DeviceEvent event) {
- assertEquals(DEVICE_UPDATED, event.type());
- assertDevice(DID1, SW2, event.subject());
- updateLatch.countDown();
- }
+ DeviceStoreDelegate checkUpdate = event -> {
+ assertEquals(DEVICE_UPDATED, event.type());
+ assertDevice(DID1, SW2, event.subject());
+ updateLatch.countDown();
};
final CountDownLatch removeLatch = new CountDownLatch(1);
- DeviceStoreDelegate checkRemove = new DeviceStoreDelegate() {
- @Override
- public void notify(DeviceEvent event) {
- assertEquals(DEVICE_REMOVED, event.type());
- assertDevice(DID1, SW2, event.subject());
- removeLatch.countDown();
- }
+ DeviceStoreDelegate checkRemove = event -> {
+ assertEquals(DEVICE_REMOVED, event.type());
+ assertDevice(DID1, SW2, event.subject());
+ removeLatch.countDown();
};
DeviceDescription description =
diff --git a/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java b/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java
index 3b8f1d3..c8c92aa 100644
--- a/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java
+++ b/core/common/src/test/java/org/onosproject/store/trivial/SimpleFlowRuleStore.java
@@ -15,7 +15,6 @@
*/
package org.onosproject.store.trivial;
-import com.google.common.base.Function;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.RemovalListener;
@@ -162,15 +161,7 @@
public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) {
// flatten and make iterator unmodifiable
return FluentIterable.from(getFlowTable(deviceId).values())
- .transformAndConcat(
- new Function<List<StoredFlowEntry>, Iterable<? extends FlowEntry>>() {
-
- @Override
- public Iterable<? extends FlowEntry> apply(
- List<StoredFlowEntry> input) {
- return Collections.unmodifiableList(input);
- }
- });
+ .transformAndConcat(Collections::unmodifiableList);
}
@Override
diff --git a/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStore.java b/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStore.java
index bf7c2fc..230fa33 100644
--- a/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStore.java
+++ b/core/common/src/test/java/org/onosproject/store/trivial/SimpleGroupStore.java
@@ -55,7 +55,6 @@
import org.onosproject.store.AbstractStore;
import org.slf4j.Logger;
-import com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Sets;
@@ -188,15 +187,7 @@
public Iterable<Group> getGroups(DeviceId deviceId) {
// flatten and make iterator unmodifiable
return FluentIterable.from(getGroupKeyTable(deviceId).values())
- .transform(
- new Function<StoredGroupEntry, Group>() {
-
- @Override
- public Group apply(
- StoredGroupEntry input) {
- return input;
- }
- });
+ .transform(input -> input);
}
/**
diff --git a/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStoreTest.java b/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStoreTest.java
index 2d2b275..40649aa 100644
--- a/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStoreTest.java
+++ b/core/common/src/test/java/org/onosproject/store/trivial/SimpleLinkStoreTest.java
@@ -498,31 +498,22 @@
final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
final CountDownLatch addLatch = new CountDownLatch(1);
- LinkStoreDelegate checkAdd = new LinkStoreDelegate() {
- @Override
- public void notify(LinkEvent event) {
- assertEquals(LINK_ADDED, event.type());
- assertLink(linkId1, INDIRECT, event.subject());
- addLatch.countDown();
- }
+ LinkStoreDelegate checkAdd = event -> {
+ assertEquals(LINK_ADDED, event.type());
+ assertLink(linkId1, INDIRECT, event.subject());
+ addLatch.countDown();
};
final CountDownLatch updateLatch = new CountDownLatch(1);
- LinkStoreDelegate checkUpdate = new LinkStoreDelegate() {
- @Override
- public void notify(LinkEvent event) {
- assertEquals(LINK_UPDATED, event.type());
- assertLink(linkId1, DIRECT, event.subject());
- updateLatch.countDown();
- }
+ LinkStoreDelegate checkUpdate = event -> {
+ assertEquals(LINK_UPDATED, event.type());
+ assertLink(linkId1, DIRECT, event.subject());
+ updateLatch.countDown();
};
final CountDownLatch removeLatch = new CountDownLatch(1);
- LinkStoreDelegate checkRemove = new LinkStoreDelegate() {
- @Override
- public void notify(LinkEvent event) {
- assertEquals(LINK_REMOVED, event.type());
- assertLink(linkId1, DIRECT, event.subject());
- removeLatch.countDown();
- }
+ LinkStoreDelegate checkRemove = event -> {
+ assertEquals(LINK_REMOVED, event.type());
+ assertLink(linkId1, DIRECT, event.subject());
+ removeLatch.countDown();
};
linkStore.setDelegate(checkAdd);
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
index c60325a..05a20f9 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
@@ -51,7 +51,6 @@
import org.onosproject.net.resource.link.LinkResourceService;
import org.onosproject.net.topology.LinkWeight;
import org.onosproject.net.topology.Topology;
-import org.onosproject.net.topology.TopologyEdge;
import org.onosproject.net.topology.TopologyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -265,34 +264,31 @@
private Set<Path> getOpticalPaths(OpticalConnectivityIntent intent) {
// Route in WDM topology
Topology topology = topologyService.currentTopology();
- LinkWeight weight = new LinkWeight() {
- @Override
- public double weight(TopologyEdge edge) {
- // Disregard inactive or non-optical links
- if (edge.link().state() == Link.State.INACTIVE) {
- return -1;
- }
- if (edge.link().type() != Link.Type.OPTICAL) {
- return -1;
- }
- // Adhere to static port mappings
- DeviceId srcDeviceId = edge.link().src().deviceId();
- if (srcDeviceId.equals(intent.getSrc().deviceId())) {
- ConnectPoint srcStaticPort = staticPort(intent.getSrc());
- if (srcStaticPort != null) {
- return srcStaticPort.equals(edge.link().src()) ? 1 : -1;
- }
- }
- DeviceId dstDeviceId = edge.link().dst().deviceId();
- if (dstDeviceId.equals(intent.getDst().deviceId())) {
- ConnectPoint dstStaticPort = staticPort(intent.getDst());
- if (dstStaticPort != null) {
- return dstStaticPort.equals(edge.link().dst()) ? 1 : -1;
- }
- }
-
- return 1;
+ LinkWeight weight = edge -> {
+ // Disregard inactive or non-optical links
+ if (edge.link().state() == Link.State.INACTIVE) {
+ return -1;
}
+ if (edge.link().type() != Link.Type.OPTICAL) {
+ return -1;
+ }
+ // Adhere to static port mappings
+ DeviceId srcDeviceId = edge.link().src().deviceId();
+ if (srcDeviceId.equals(intent.getSrc().deviceId())) {
+ ConnectPoint srcStaticPort = staticPort(intent.getSrc());
+ if (srcStaticPort != null) {
+ return srcStaticPort.equals(edge.link().src()) ? 1 : -1;
+ }
+ }
+ DeviceId dstDeviceId = edge.link().dst().deviceId();
+ if (dstDeviceId.equals(intent.getDst().deviceId())) {
+ ConnectPoint dstStaticPort = staticPort(intent.getDst());
+ if (dstStaticPort != null) {
+ return dstStaticPort.equals(edge.link().dst()) ? 1 : -1;
+ }
+ }
+
+ return 1;
};
ConnectPoint start = intent.getSrc();
diff --git a/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java b/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java
index 7bdeb4f..d6f72fd 100644
--- a/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java
+++ b/core/net/src/main/java/org/onosproject/net/link/impl/LinkManager.java
@@ -15,7 +15,6 @@
*/
package org.onosproject.net.link.impl;
-import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Sets;
@@ -126,13 +125,7 @@
public Iterable<Link> getActiveLinks() {
checkPermission(LINK_READ);
return FluentIterable.from(getLinks())
- .filter(new Predicate<Link>() {
-
- @Override
- public boolean apply(Link input) {
- return input.state() == State.ACTIVE;
- }
- });
+ .filter(input -> input.state() == State.ACTIVE);
}
@Override
diff --git a/core/net/src/main/java/org/onosproject/net/statistic/impl/StatisticManager.java b/core/net/src/main/java/org/onosproject/net/statistic/impl/StatisticManager.java
index 996ad14e..57964d6 100644
--- a/core/net/src/main/java/org/onosproject/net/statistic/impl/StatisticManager.java
+++ b/core/net/src/main/java/org/onosproject/net/statistic/impl/StatisticManager.java
@@ -348,12 +348,7 @@
* @return predicate
*/
private static Predicate<FlowEntry> hasApplicationId(ApplicationId appId) {
- return new Predicate<FlowEntry>() {
- @Override
- public boolean apply(FlowEntry flowEntry) {
- return flowEntry.appId() == appId.id();
- }
- };
+ return flowEntry -> flowEntry.appId() == appId.id();
}
/**
@@ -364,16 +359,13 @@
* @return predicate
*/
private static Predicate<FlowEntry> hasGroupId(Optional<GroupId> groupId) {
- return new Predicate<FlowEntry>() {
- @Override
- public boolean apply(FlowEntry flowEntry) {
- if (!groupId.isPresent()) {
- return false;
- }
- // FIXME: The left hand type and right hand type don't match
- // FlowEntry.groupId() still returns a short value, not int.
- return flowEntry.groupId().equals(groupId.get());
+ return flowEntry -> {
+ if (!groupId.isPresent()) {
+ return false;
}
+ // FIXME: The left hand type and right hand type don't match
+ // FlowEntry.groupId() still returns a short value, not int.
+ return flowEntry.groupId().equals(groupId.get());
};
}
}
diff --git a/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java b/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java
index 8827c55..2be0df7 100644
--- a/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java
+++ b/core/net/src/test/java/org/onosproject/net/device/impl/BasicDeviceOperatorTest.java
@@ -24,7 +24,6 @@
import org.junit.Before;
import org.junit.Test;
import org.onlab.packet.ChassisId;
-import org.onosproject.net.config.Config;
import org.onosproject.net.config.ConfigApplyDelegate;
import org.onosproject.net.config.basics.BasicDeviceConfig;
import org.onosproject.net.AnnotationKeys;
@@ -55,11 +54,7 @@
private static final DeviceDescription DEV1 = new DefaultDeviceDescription(
DURI, SWITCH, MFR, HW, SW, SN, CID, SA);
- private final ConfigApplyDelegate delegate = new ConfigApplyDelegate() {
- @Override
- public void onApply(Config config) {
- }
- };
+ private final ConfigApplyDelegate delegate = config -> { };
private final ObjectMapper mapper = new ObjectMapper();
private static final BasicDeviceConfig SW_BDC = new BasicDeviceConfig();
diff --git a/core/net/src/test/java/org/onosproject/net/host/impl/BasicHostOperatorTest.java b/core/net/src/test/java/org/onosproject/net/host/impl/BasicHostOperatorTest.java
index e7f14b5..940ed91 100644
--- a/core/net/src/test/java/org/onosproject/net/host/impl/BasicHostOperatorTest.java
+++ b/core/net/src/test/java/org/onosproject/net/host/impl/BasicHostOperatorTest.java
@@ -22,7 +22,6 @@
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
-import org.onosproject.net.config.Config;
import org.onosproject.net.config.ConfigApplyDelegate;
import org.onosproject.net.config.basics.BasicHostConfig;
import org.onosproject.net.AnnotationKeys;
@@ -49,11 +48,7 @@
);
private static final HostDescription HOST = new DefaultHostDescription(MAC, VLAN, LOC, IP);
- private final ConfigApplyDelegate delegate = new ConfigApplyDelegate() {
- @Override
- public void onApply(Config config) {
- }
- };
+ private final ConfigApplyDelegate delegate = config -> { };
private final ObjectMapper mapper = new ObjectMapper();
private static final BasicHostConfig BHC = new BasicHostConfig();
diff --git a/core/net/src/test/java/org/onosproject/net/link/impl/BasicLinkOperatorTest.java b/core/net/src/test/java/org/onosproject/net/link/impl/BasicLinkOperatorTest.java
index fe9e37c..eadbb5c 100644
--- a/core/net/src/test/java/org/onosproject/net/link/impl/BasicLinkOperatorTest.java
+++ b/core/net/src/test/java/org/onosproject/net/link/impl/BasicLinkOperatorTest.java
@@ -22,7 +22,6 @@
import java.time.Duration;
import org.junit.Before;
import org.junit.Test;
-import org.onosproject.net.config.Config;
import org.onosproject.net.config.ConfigApplyDelegate;
import org.onosproject.net.config.basics.BasicLinkConfig;
import org.onosproject.net.AnnotationKeys;
@@ -53,11 +52,7 @@
private static final SparseAnnotations SA = DefaultAnnotations.builder()
.set(AnnotationKeys.DURABLE, "true").build();
private static final LinkDescription LD = new DefaultLinkDescription(SRC, DST, Link.Type.DIRECT, SA);
- private final ConfigApplyDelegate delegate = new ConfigApplyDelegate() {
- @Override
- public void onApply(Config config) {
- }
- };
+ private final ConfigApplyDelegate delegate = config -> { };
private final ObjectMapper mapper = new ObjectMapper();
private static final BasicLinkConfig BLC = new BasicLinkConfig();
diff --git a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
index 6345643..973db49 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java
@@ -15,7 +15,6 @@
*/
package org.onosproject.store.device.impl;
-import com.google.common.base.Function;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
@@ -564,13 +563,10 @@
final DeviceDescriptions descs = device.get(providerId);
List<PortDescription> mergedList =
FluentIterable.from(portDescriptions)
- .transform(new Function<PortDescription, PortDescription>() {
- @Override
- public PortDescription apply(PortDescription input) {
- // lookup merged port description
- return descs.getPortDesc(input.portNumber()).value();
- }
- }).toList();
+ .transform(input ->
+ // lookup merged port description
+ descs.getPortDesc(input.portNumber()).value()
+ ).toList();
merged = new Timestamped<>(mergedList, newTimestamp);
}
diff --git a/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java b/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java
index 43b11f5..3a16893 100644
--- a/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java
+++ b/core/store/dist/src/test/java/org/onosproject/store/device/impl/GossipDeviceStoreTest.java
@@ -802,31 +802,22 @@
@Test
public final void testEvents() throws InterruptedException {
final CountDownLatch addLatch = new CountDownLatch(1);
- DeviceStoreDelegate checkAdd = new DeviceStoreDelegate() {
- @Override
- public void notify(DeviceEvent event) {
- assertEquals(DEVICE_ADDED, event.type());
- assertDevice(DID1, SW1, event.subject());
- addLatch.countDown();
- }
+ DeviceStoreDelegate checkAdd = event -> {
+ assertEquals(DEVICE_ADDED, event.type());
+ assertDevice(DID1, SW1, event.subject());
+ addLatch.countDown();
};
final CountDownLatch updateLatch = new CountDownLatch(1);
- DeviceStoreDelegate checkUpdate = new DeviceStoreDelegate() {
- @Override
- public void notify(DeviceEvent event) {
- assertEquals(DEVICE_UPDATED, event.type());
- assertDevice(DID1, SW2, event.subject());
- updateLatch.countDown();
- }
+ DeviceStoreDelegate checkUpdate = event -> {
+ assertEquals(DEVICE_UPDATED, event.type());
+ assertDevice(DID1, SW2, event.subject());
+ updateLatch.countDown();
};
final CountDownLatch removeLatch = new CountDownLatch(1);
- DeviceStoreDelegate checkRemove = new DeviceStoreDelegate() {
- @Override
- public void notify(DeviceEvent event) {
- assertEquals(DEVICE_REMOVED, event.type());
- assertDevice(DID1, SW2, event.subject());
- removeLatch.countDown();
- }
+ DeviceStoreDelegate checkRemove = event -> {
+ assertEquals(DEVICE_REMOVED, event.type());
+ assertDevice(DID1, SW2, event.subject());
+ removeLatch.countDown();
};
DeviceDescription description =
diff --git a/core/store/dist/src/test/java/org/onosproject/store/link/impl/GossipLinkStoreTest.java b/core/store/dist/src/test/java/org/onosproject/store/link/impl/GossipLinkStoreTest.java
index bf7af46..f8b5b86 100644
--- a/core/store/dist/src/test/java/org/onosproject/store/link/impl/GossipLinkStoreTest.java
+++ b/core/store/dist/src/test/java/org/onosproject/store/link/impl/GossipLinkStoreTest.java
@@ -548,31 +548,22 @@
final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
final CountDownLatch addLatch = new CountDownLatch(1);
- LinkStoreDelegate checkAdd = new LinkStoreDelegate() {
- @Override
- public void notify(LinkEvent event) {
- assertEquals(LINK_ADDED, event.type());
- assertLink(linkId1, INDIRECT, event.subject());
- addLatch.countDown();
- }
+ LinkStoreDelegate checkAdd = event -> {
+ assertEquals(LINK_ADDED, event.type());
+ assertLink(linkId1, INDIRECT, event.subject());
+ addLatch.countDown();
};
final CountDownLatch updateLatch = new CountDownLatch(1);
- LinkStoreDelegate checkUpdate = new LinkStoreDelegate() {
- @Override
- public void notify(LinkEvent event) {
- assertEquals(LINK_UPDATED, event.type());
- assertLink(linkId1, DIRECT, event.subject());
- updateLatch.countDown();
- }
+ LinkStoreDelegate checkUpdate = event -> {
+ assertEquals(LINK_UPDATED, event.type());
+ assertLink(linkId1, DIRECT, event.subject());
+ updateLatch.countDown();
};
final CountDownLatch removeLatch = new CountDownLatch(1);
- LinkStoreDelegate checkRemove = new LinkStoreDelegate() {
- @Override
- public void notify(LinkEvent event) {
- assertEquals(LINK_REMOVED, event.type());
- assertLink(linkId1, DIRECT, event.subject());
- removeLatch.countDown();
- }
+ LinkStoreDelegate checkRemove = event -> {
+ assertEquals(LINK_REMOVED, event.type());
+ assertLink(linkId1, DIRECT, event.subject());
+ removeLatch.countDown();
};
linkStore.setDelegate(checkAdd);