Sho SHIMIZU
Committed by Brian O'Connor

Use lambda expression to simplify statements

Change-Id: Ib8ddac6e93327ade9d42984d8eba66be7047d051
Showing 23 changed files with 43 additions and 205 deletions
...@@ -300,9 +300,7 @@ public class BgpSessionManager implements BgpInfoService, BgpService { ...@@ -300,9 +300,7 @@ public class BgpSessionManager implements BgpInfoService, BgpService {
300 ChannelFactory channelFactory = new NioServerSocketChannelFactory( 300 ChannelFactory channelFactory = new NioServerSocketChannelFactory(
301 newCachedThreadPool(groupedThreads("onos/bgp", "sm-boss-%d")), 301 newCachedThreadPool(groupedThreads("onos/bgp", "sm-boss-%d")),
302 newCachedThreadPool(groupedThreads("onos/bgp", "sm-worker-%d"))); 302 newCachedThreadPool(groupedThreads("onos/bgp", "sm-worker-%d")));
303 - ChannelPipelineFactory pipelineFactory = new ChannelPipelineFactory() { 303 + ChannelPipelineFactory pipelineFactory = () -> {
304 - @Override
305 - public ChannelPipeline getPipeline() throws Exception {
306 // Allocate a new session per connection 304 // Allocate a new session per connection
307 BgpSession bgpSessionHandler = 305 BgpSession bgpSessionHandler =
308 new BgpSession(BgpSessionManager.this); 306 new BgpSession(BgpSessionManager.this);
...@@ -314,7 +312,6 @@ public class BgpSessionManager implements BgpInfoService, BgpService { ...@@ -314,7 +312,6 @@ public class BgpSessionManager implements BgpInfoService, BgpService {
314 pipeline.addLast("BgpFrameDecoder", bgpFrameDecoder); 312 pipeline.addLast("BgpFrameDecoder", bgpFrameDecoder);
315 pipeline.addLast("BgpSession", bgpSessionHandler); 313 pipeline.addLast("BgpSession", bgpSessionHandler);
316 return pipeline; 314 return pipeline;
317 - }
318 }; 315 };
319 InetSocketAddress listenAddress = 316 InetSocketAddress listenAddress =
320 new InetSocketAddress(bgpPort); 317 new InetSocketAddress(bgpPort);
......
...@@ -159,12 +159,7 @@ public class Router implements RoutingService { ...@@ -159,12 +159,7 @@ public class Router implements RoutingService {
159 159
160 bgpService.start(new InternalRouteListener()); 160 bgpService.start(new InternalRouteListener());
161 161
162 - bgpUpdatesExecutor.execute(new Runnable() { 162 + bgpUpdatesExecutor.execute(this::doUpdatesThread);
163 - @Override
164 - public void run() {
165 - doUpdatesThread();
166 - }
167 - });
168 } 163 }
169 164
170 @Override 165 @Override
......
...@@ -151,10 +151,7 @@ public class BgpSessionManagerTest { ...@@ -151,10 +151,7 @@ public class BgpSessionManagerTest {
151 new NioClientSocketChannelFactory( 151 new NioClientSocketChannelFactory(
152 Executors.newCachedThreadPool(), 152 Executors.newCachedThreadPool(),
153 Executors.newCachedThreadPool()); 153 Executors.newCachedThreadPool());
154 - ChannelPipelineFactory pipelineFactory = 154 + ChannelPipelineFactory pipelineFactory = () -> {
155 - new ChannelPipelineFactory() {
156 - @Override
157 - public ChannelPipeline getPipeline() throws Exception {
158 // Setup the transmitting pipeline 155 // Setup the transmitting pipeline
159 ChannelPipeline pipeline = Channels.pipeline(); 156 ChannelPipeline pipeline = Channels.pipeline();
160 pipeline.addLast("TestBgpPeerFrameDecoder", 157 pipeline.addLast("TestBgpPeerFrameDecoder",
...@@ -162,7 +159,6 @@ public class BgpSessionManagerTest { ...@@ -162,7 +159,6 @@ public class BgpSessionManagerTest {
162 pipeline.addLast("TestBgpPeerChannelHandler", 159 pipeline.addLast("TestBgpPeerChannelHandler",
163 peerChannelHandler); 160 peerChannelHandler);
164 return pipeline; 161 return pipeline;
165 - }
166 }; 162 };
167 163
168 peerBootstrap = new ClientBootstrap(channelFactory); 164 peerBootstrap = new ClientBootstrap(channelFactory);
......
...@@ -393,14 +393,9 @@ public class DemoInstaller implements DemoAPI { ...@@ -393,14 +393,9 @@ public class DemoInstaller implements DemoAPI {
393 } 393 }
394 394
395 private Predicate<? super Host> hasLocalMaster() { 395 private Predicate<? super Host> hasLocalMaster() {
396 - return new Predicate<Host>() { 396 + return host -> mastershipService.getLocalRole(
397 - @Override
398 - public boolean apply(Host host) {
399 - return mastershipService.getLocalRole(
400 host.location().deviceId()).equals(MastershipRole.MASTER); 397 host.location().deviceId()).equals(MastershipRole.MASTER);
401 } 398 }
402 - };
403 - }
404 399
405 400
406 /** 401 /**
......
...@@ -25,7 +25,6 @@ import org.onosproject.net.flow.TrafficSelector; ...@@ -25,7 +25,6 @@ import org.onosproject.net.flow.TrafficSelector;
25 import org.onosproject.net.flow.TrafficTreatment; 25 import org.onosproject.net.flow.TrafficTreatment;
26 26
27 import com.google.common.base.MoreObjects; 27 import com.google.common.base.MoreObjects;
28 -import com.google.common.base.Predicate;
29 import com.google.common.collect.Iterables; 28 import com.google.common.collect.Iterables;
30 29
31 import static com.google.common.base.Preconditions.checkArgument; 30 import static com.google.common.base.Preconditions.checkArgument;
...@@ -159,12 +158,8 @@ public class PathIntent extends ConnectivityIntent { ...@@ -159,12 +158,8 @@ public class PathIntent extends ConnectivityIntent {
159 * @param links links to be validated 158 * @param links links to be validated
160 */ 159 */
161 public static void validate(List<Link> links) { 160 public static void validate(List<Link> links) {
162 - checkArgument(Iterables.all(links, new Predicate<Link>() { 161 + checkArgument(Iterables.all(links, link -> !link.src().elementId().equals(link.dst().elementId())),
163 - @Override 162 + "element of src and dst in a link must be different: {}", links);
164 - public boolean apply(Link link) {
165 - return !link.src().elementId().equals(link.dst().elementId());
166 - }
167 - }), "element of src and dst in a link must be different: {}", links);
168 163
169 boolean adjacentSame = true; 164 boolean adjacentSame = true;
170 for (int i = 0; i < links.size() - 1; i++) { 165 for (int i = 0; i < links.size() - 1; i++) {
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 */ 15 */
16 package org.onosproject.net.device; 16 package org.onosproject.net.device;
17 17
18 -import com.google.common.base.Predicate;
19 import com.google.common.collect.FluentIterable; 18 import com.google.common.collect.FluentIterable;
20 19
21 import org.onosproject.net.Device; 20 import org.onosproject.net.Device;
...@@ -45,13 +44,7 @@ public class DeviceServiceAdapter implements DeviceService { ...@@ -45,13 +44,7 @@ public class DeviceServiceAdapter implements DeviceService {
45 @Override 44 @Override
46 public Iterable<Device> getAvailableDevices() { 45 public Iterable<Device> getAvailableDevices() {
47 return FluentIterable.from(getDevices()) 46 return FluentIterable.from(getDevices())
48 - .filter(new Predicate<Device>() { 47 + .filter(input -> isAvailable(input.id()));
49 -
50 - @Override
51 - public boolean apply(Device input) {
52 - return isAvailable(input.id());
53 - }
54 - });
55 } 48 }
56 49
57 @Override 50 @Override
......
...@@ -49,31 +49,24 @@ public class FakeIntentManager implements TestableIntentService { ...@@ -49,31 +49,24 @@ public class FakeIntentManager implements TestableIntentService {
49 // Provides an out-of-thread simulation of intent submit life-cycle 49 // Provides an out-of-thread simulation of intent submit life-cycle
50 private void executeSubmit(final Intent intent) { 50 private void executeSubmit(final Intent intent) {
51 registerSubclassCompilerIfNeeded(intent); 51 registerSubclassCompilerIfNeeded(intent);
52 - executor.execute(new Runnable() { 52 + executor.execute(() -> {
53 - @Override
54 - public void run() {
55 try { 53 try {
56 executeCompilingPhase(intent); 54 executeCompilingPhase(intent);
57 } catch (IntentException e) { 55 } catch (IntentException e) {
58 exceptions.add(e); 56 exceptions.add(e);
59 } 57 }
60 - }
61 }); 58 });
62 } 59 }
63 60
64 // Provides an out-of-thread simulation of intent withdraw life-cycle 61 // Provides an out-of-thread simulation of intent withdraw life-cycle
65 private void executeWithdraw(final Intent intent) { 62 private void executeWithdraw(final Intent intent) {
66 - executor.execute(new Runnable() { 63 + executor.execute(() -> {
67 - @Override
68 - public void run() {
69 try { 64 try {
70 List<Intent> installable = getInstallable(intent.key()); 65 List<Intent> installable = getInstallable(intent.key());
71 executeWithdrawingPhase(intent, installable); 66 executeWithdrawingPhase(intent, installable);
72 } catch (IntentException e) { 67 } catch (IntentException e) {
73 exceptions.add(e); 68 exceptions.add(e);
74 } 69 }
75 -
76 - }
77 }); 70 });
78 } 71 }
79 72
......
...@@ -79,13 +79,8 @@ public class IntentServiceTest { ...@@ -79,13 +79,8 @@ public class IntentServiceTest {
79 service.submit(intent); 79 service.submit(intent);
80 80
81 // Allow a small window of time until the intent is in the expected state 81 // Allow a small window of time until the intent is in the expected state
82 - TestTools.assertAfter(GRACE_MS, new Runnable() { 82 + TestTools.assertAfter(GRACE_MS, () ->
83 - @Override 83 + assertEquals("incorrect intent state", IntentState.INSTALLED, service.getIntentState(intent.key())));
84 - public void run() {
85 - assertEquals("incorrect intent state", IntentState.INSTALLED,
86 - service.getIntentState(intent.key()));
87 - }
88 - });
89 84
90 // Make sure that all expected events have been emitted 85 // Make sure that all expected events have been emitted
91 validateEvents(intent, INSTALL_REQ, INSTALLED); 86 validateEvents(intent, INSTALL_REQ, INSTALLED);
...@@ -100,13 +95,8 @@ public class IntentServiceTest { ...@@ -100,13 +95,8 @@ public class IntentServiceTest {
100 service.withdraw(intent); 95 service.withdraw(intent);
101 96
102 // Allow a small window of time until the event is in the expected state 97 // Allow a small window of time until the event is in the expected state
103 - TestTools.assertAfter(GRACE_MS, new Runnable() { 98 + TestTools.assertAfter(GRACE_MS, () ->
104 - @Override 99 + assertEquals("incorrect intent state", IntentState.WITHDRAWN, service.getIntentState(intent.key())));
105 - public void run() {
106 - assertEquals("incorrect intent state", IntentState.WITHDRAWN,
107 - service.getIntentState(intent.key()));
108 - }
109 - });
110 100
111 // Make sure that all expected events have been emitted 101 // Make sure that all expected events have been emitted
112 validateEvents(intent, WITHDRAWN); 102 validateEvents(intent, WITHDRAWN);
...@@ -128,13 +118,8 @@ public class IntentServiceTest { ...@@ -128,13 +118,8 @@ public class IntentServiceTest {
128 service.submit(intent); 118 service.submit(intent);
129 119
130 // Allow a small window of time until the intent is in the expected state 120 // Allow a small window of time until the intent is in the expected state
131 - TestTools.assertAfter(GRACE_MS, new Runnable() { 121 + TestTools.assertAfter(GRACE_MS, () ->
132 - @Override 122 + assertEquals("incorrect intent state", IntentState.FAILED, service.getIntentState(intent.key())));
133 - public void run() {
134 - assertEquals("incorrect intent state", IntentState.FAILED,
135 - service.getIntentState(intent.key()));
136 - }
137 - });
138 123
139 // Make sure that all expected events have been emitted 124 // Make sure that all expected events have been emitted
140 validateEvents(intent, INSTALL_REQ, FAILED); 125 validateEvents(intent, INSTALL_REQ, FAILED);
...@@ -196,13 +181,8 @@ public class IntentServiceTest { ...@@ -196,13 +181,8 @@ public class IntentServiceTest {
196 service.submit(intent); 181 service.submit(intent);
197 182
198 // Allow some time for the intent to be compiled and installed 183 // Allow some time for the intent to be compiled and installed
199 - TestTools.assertAfter(GRACE_MS, new Runnable() { 184 + TestTools.assertAfter(GRACE_MS, () ->
200 - @Override 185 + assertEquals("incorrect intent state", IntentState.INSTALLED, service.getIntentState(intent.key())));
201 - public void run() {
202 - assertEquals("incorrect intent state", IntentState.INSTALLED,
203 - service.getIntentState(intent.key()));
204 - }
205 - });
206 186
207 // Make sure that now we have an implicit registration of the compiler 187 // Make sure that now we have an implicit registration of the compiler
208 // under the intent subclass 188 // under the intent subclass
......
...@@ -22,7 +22,6 @@ import org.onosproject.net.DeviceId; ...@@ -22,7 +22,6 @@ import org.onosproject.net.DeviceId;
22 import org.onosproject.net.Link; 22 import org.onosproject.net.Link;
23 import org.onosproject.net.Link.State; 23 import org.onosproject.net.Link.State;
24 24
25 -import com.google.common.base.Predicate;
26 import com.google.common.collect.FluentIterable; 25 import com.google.common.collect.FluentIterable;
27 26
28 /** 27 /**
...@@ -42,13 +41,7 @@ public class LinkServiceAdapter implements LinkService { ...@@ -42,13 +41,7 @@ public class LinkServiceAdapter implements LinkService {
42 @Override 41 @Override
43 public Iterable<Link> getActiveLinks() { 42 public Iterable<Link> getActiveLinks() {
44 return FluentIterable.from(getLinks()) 43 return FluentIterable.from(getLinks())
45 - .filter(new Predicate<Link>() { 44 + .filter(input -> input.state() == State.ACTIVE);
46 -
47 - @Override
48 - public boolean apply(Link input) {
49 - return input.state() == State.ACTIVE;
50 - }
51 - });
52 } 45 }
53 46
54 @Override 47 @Override
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 */ 15 */
16 package org.onosproject.store.trivial; 16 package org.onosproject.store.trivial;
17 17
18 -import com.google.common.base.Predicate;
19 import com.google.common.collect.FluentIterable; 18 import com.google.common.collect.FluentIterable;
20 import com.google.common.collect.ImmutableList; 19 import com.google.common.collect.ImmutableList;
21 import com.google.common.collect.Maps; 20 import com.google.common.collect.Maps;
...@@ -134,13 +133,7 @@ public class SimpleDeviceStore ...@@ -134,13 +133,7 @@ public class SimpleDeviceStore
134 @Override 133 @Override
135 public Iterable<Device> getAvailableDevices() { 134 public Iterable<Device> getAvailableDevices() {
136 return FluentIterable.from(getDevices()) 135 return FluentIterable.from(getDevices())
137 - .filter(new Predicate<Device>() { 136 + .filter(input -> isAvailable(input.id()));
138 -
139 - @Override
140 - public boolean apply(Device input) {
141 - return isAvailable(input.id());
142 - }
143 - });
144 } 137 }
145 138
146 @Override 139 @Override
......
...@@ -479,31 +479,22 @@ public class SimpleDeviceStoreTest { ...@@ -479,31 +479,22 @@ public class SimpleDeviceStoreTest {
479 @Test 479 @Test
480 public final void testEvents() throws InterruptedException { 480 public final void testEvents() throws InterruptedException {
481 final CountDownLatch addLatch = new CountDownLatch(1); 481 final CountDownLatch addLatch = new CountDownLatch(1);
482 - DeviceStoreDelegate checkAdd = new DeviceStoreDelegate() { 482 + DeviceStoreDelegate checkAdd = event -> {
483 - @Override
484 - public void notify(DeviceEvent event) {
485 assertEquals(DEVICE_ADDED, event.type()); 483 assertEquals(DEVICE_ADDED, event.type());
486 assertDevice(DID1, SW1, event.subject()); 484 assertDevice(DID1, SW1, event.subject());
487 addLatch.countDown(); 485 addLatch.countDown();
488 - }
489 }; 486 };
490 final CountDownLatch updateLatch = new CountDownLatch(1); 487 final CountDownLatch updateLatch = new CountDownLatch(1);
491 - DeviceStoreDelegate checkUpdate = new DeviceStoreDelegate() { 488 + DeviceStoreDelegate checkUpdate = event -> {
492 - @Override
493 - public void notify(DeviceEvent event) {
494 assertEquals(DEVICE_UPDATED, event.type()); 489 assertEquals(DEVICE_UPDATED, event.type());
495 assertDevice(DID1, SW2, event.subject()); 490 assertDevice(DID1, SW2, event.subject());
496 updateLatch.countDown(); 491 updateLatch.countDown();
497 - }
498 }; 492 };
499 final CountDownLatch removeLatch = new CountDownLatch(1); 493 final CountDownLatch removeLatch = new CountDownLatch(1);
500 - DeviceStoreDelegate checkRemove = new DeviceStoreDelegate() { 494 + DeviceStoreDelegate checkRemove = event -> {
501 - @Override
502 - public void notify(DeviceEvent event) {
503 assertEquals(DEVICE_REMOVED, event.type()); 495 assertEquals(DEVICE_REMOVED, event.type());
504 assertDevice(DID1, SW2, event.subject()); 496 assertDevice(DID1, SW2, event.subject());
505 removeLatch.countDown(); 497 removeLatch.countDown();
506 - }
507 }; 498 };
508 499
509 DeviceDescription description = 500 DeviceDescription description =
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 */ 15 */
16 package org.onosproject.store.trivial; 16 package org.onosproject.store.trivial;
17 17
18 -import com.google.common.base.Function;
19 import com.google.common.cache.Cache; 18 import com.google.common.cache.Cache;
20 import com.google.common.cache.CacheBuilder; 19 import com.google.common.cache.CacheBuilder;
21 import com.google.common.cache.RemovalListener; 20 import com.google.common.cache.RemovalListener;
...@@ -162,15 +161,7 @@ public class SimpleFlowRuleStore ...@@ -162,15 +161,7 @@ public class SimpleFlowRuleStore
162 public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) { 161 public Iterable<FlowEntry> getFlowEntries(DeviceId deviceId) {
163 // flatten and make iterator unmodifiable 162 // flatten and make iterator unmodifiable
164 return FluentIterable.from(getFlowTable(deviceId).values()) 163 return FluentIterable.from(getFlowTable(deviceId).values())
165 - .transformAndConcat( 164 + .transformAndConcat(Collections::unmodifiableList);
166 - new Function<List<StoredFlowEntry>, Iterable<? extends FlowEntry>>() {
167 -
168 - @Override
169 - public Iterable<? extends FlowEntry> apply(
170 - List<StoredFlowEntry> input) {
171 - return Collections.unmodifiableList(input);
172 - }
173 - });
174 } 165 }
175 166
176 @Override 167 @Override
......
...@@ -55,7 +55,6 @@ import org.onosproject.net.group.StoredGroupEntry; ...@@ -55,7 +55,6 @@ import org.onosproject.net.group.StoredGroupEntry;
55 import org.onosproject.store.AbstractStore; 55 import org.onosproject.store.AbstractStore;
56 import org.slf4j.Logger; 56 import org.slf4j.Logger;
57 57
58 -import com.google.common.base.Function;
59 import com.google.common.collect.FluentIterable; 58 import com.google.common.collect.FluentIterable;
60 import com.google.common.collect.Sets; 59 import com.google.common.collect.Sets;
61 60
...@@ -188,15 +187,7 @@ public class SimpleGroupStore ...@@ -188,15 +187,7 @@ public class SimpleGroupStore
188 public Iterable<Group> getGroups(DeviceId deviceId) { 187 public Iterable<Group> getGroups(DeviceId deviceId) {
189 // flatten and make iterator unmodifiable 188 // flatten and make iterator unmodifiable
190 return FluentIterable.from(getGroupKeyTable(deviceId).values()) 189 return FluentIterable.from(getGroupKeyTable(deviceId).values())
191 - .transform( 190 + .transform(input -> input);
192 - new Function<StoredGroupEntry, Group>() {
193 -
194 - @Override
195 - public Group apply(
196 - StoredGroupEntry input) {
197 - return input;
198 - }
199 - });
200 } 191 }
201 192
202 /** 193 /**
......
...@@ -498,31 +498,22 @@ public class SimpleLinkStoreTest { ...@@ -498,31 +498,22 @@ public class SimpleLinkStoreTest {
498 final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2); 498 final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
499 499
500 final CountDownLatch addLatch = new CountDownLatch(1); 500 final CountDownLatch addLatch = new CountDownLatch(1);
501 - LinkStoreDelegate checkAdd = new LinkStoreDelegate() { 501 + LinkStoreDelegate checkAdd = event -> {
502 - @Override
503 - public void notify(LinkEvent event) {
504 assertEquals(LINK_ADDED, event.type()); 502 assertEquals(LINK_ADDED, event.type());
505 assertLink(linkId1, INDIRECT, event.subject()); 503 assertLink(linkId1, INDIRECT, event.subject());
506 addLatch.countDown(); 504 addLatch.countDown();
507 - }
508 }; 505 };
509 final CountDownLatch updateLatch = new CountDownLatch(1); 506 final CountDownLatch updateLatch = new CountDownLatch(1);
510 - LinkStoreDelegate checkUpdate = new LinkStoreDelegate() { 507 + LinkStoreDelegate checkUpdate = event -> {
511 - @Override
512 - public void notify(LinkEvent event) {
513 assertEquals(LINK_UPDATED, event.type()); 508 assertEquals(LINK_UPDATED, event.type());
514 assertLink(linkId1, DIRECT, event.subject()); 509 assertLink(linkId1, DIRECT, event.subject());
515 updateLatch.countDown(); 510 updateLatch.countDown();
516 - }
517 }; 511 };
518 final CountDownLatch removeLatch = new CountDownLatch(1); 512 final CountDownLatch removeLatch = new CountDownLatch(1);
519 - LinkStoreDelegate checkRemove = new LinkStoreDelegate() { 513 + LinkStoreDelegate checkRemove = event -> {
520 - @Override
521 - public void notify(LinkEvent event) {
522 assertEquals(LINK_REMOVED, event.type()); 514 assertEquals(LINK_REMOVED, event.type());
523 assertLink(linkId1, DIRECT, event.subject()); 515 assertLink(linkId1, DIRECT, event.subject());
524 removeLatch.countDown(); 516 removeLatch.countDown();
525 - }
526 }; 517 };
527 518
528 linkStore.setDelegate(checkAdd); 519 linkStore.setDelegate(checkAdd);
......
...@@ -51,7 +51,6 @@ import org.onosproject.net.resource.link.LinkResourceRequest; ...@@ -51,7 +51,6 @@ import org.onosproject.net.resource.link.LinkResourceRequest;
51 import org.onosproject.net.resource.link.LinkResourceService; 51 import org.onosproject.net.resource.link.LinkResourceService;
52 import org.onosproject.net.topology.LinkWeight; 52 import org.onosproject.net.topology.LinkWeight;
53 import org.onosproject.net.topology.Topology; 53 import org.onosproject.net.topology.Topology;
54 -import org.onosproject.net.topology.TopologyEdge;
55 import org.onosproject.net.topology.TopologyService; 54 import org.onosproject.net.topology.TopologyService;
56 import org.slf4j.Logger; 55 import org.slf4j.Logger;
57 import org.slf4j.LoggerFactory; 56 import org.slf4j.LoggerFactory;
...@@ -265,9 +264,7 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical ...@@ -265,9 +264,7 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical
265 private Set<Path> getOpticalPaths(OpticalConnectivityIntent intent) { 264 private Set<Path> getOpticalPaths(OpticalConnectivityIntent intent) {
266 // Route in WDM topology 265 // Route in WDM topology
267 Topology topology = topologyService.currentTopology(); 266 Topology topology = topologyService.currentTopology();
268 - LinkWeight weight = new LinkWeight() { 267 + LinkWeight weight = edge -> {
269 - @Override
270 - public double weight(TopologyEdge edge) {
271 // Disregard inactive or non-optical links 268 // Disregard inactive or non-optical links
272 if (edge.link().state() == Link.State.INACTIVE) { 269 if (edge.link().state() == Link.State.INACTIVE) {
273 return -1; 270 return -1;
...@@ -292,7 +289,6 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical ...@@ -292,7 +289,6 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical
292 } 289 }
293 290
294 return 1; 291 return 1;
295 - }
296 }; 292 };
297 293
298 ConnectPoint start = intent.getSrc(); 294 ConnectPoint start = intent.getSrc();
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 */ 15 */
16 package org.onosproject.net.link.impl; 16 package org.onosproject.net.link.impl;
17 17
18 -import com.google.common.base.Predicate;
19 import com.google.common.collect.FluentIterable; 18 import com.google.common.collect.FluentIterable;
20 import com.google.common.collect.Sets; 19 import com.google.common.collect.Sets;
21 20
...@@ -126,13 +125,7 @@ public class LinkManager ...@@ -126,13 +125,7 @@ public class LinkManager
126 public Iterable<Link> getActiveLinks() { 125 public Iterable<Link> getActiveLinks() {
127 checkPermission(LINK_READ); 126 checkPermission(LINK_READ);
128 return FluentIterable.from(getLinks()) 127 return FluentIterable.from(getLinks())
129 - .filter(new Predicate<Link>() { 128 + .filter(input -> input.state() == State.ACTIVE);
130 -
131 - @Override
132 - public boolean apply(Link input) {
133 - return input.state() == State.ACTIVE;
134 - }
135 - });
136 } 129 }
137 130
138 @Override 131 @Override
......
...@@ -348,12 +348,7 @@ public class StatisticManager implements StatisticService { ...@@ -348,12 +348,7 @@ public class StatisticManager implements StatisticService {
348 * @return predicate 348 * @return predicate
349 */ 349 */
350 private static Predicate<FlowEntry> hasApplicationId(ApplicationId appId) { 350 private static Predicate<FlowEntry> hasApplicationId(ApplicationId appId) {
351 - return new Predicate<FlowEntry>() { 351 + return flowEntry -> flowEntry.appId() == appId.id();
352 - @Override
353 - public boolean apply(FlowEntry flowEntry) {
354 - return flowEntry.appId() == appId.id();
355 - }
356 - };
357 } 352 }
358 353
359 /** 354 /**
...@@ -364,16 +359,13 @@ public class StatisticManager implements StatisticService { ...@@ -364,16 +359,13 @@ public class StatisticManager implements StatisticService {
364 * @return predicate 359 * @return predicate
365 */ 360 */
366 private static Predicate<FlowEntry> hasGroupId(Optional<GroupId> groupId) { 361 private static Predicate<FlowEntry> hasGroupId(Optional<GroupId> groupId) {
367 - return new Predicate<FlowEntry>() { 362 + return flowEntry -> {
368 - @Override
369 - public boolean apply(FlowEntry flowEntry) {
370 if (!groupId.isPresent()) { 363 if (!groupId.isPresent()) {
371 return false; 364 return false;
372 } 365 }
373 // FIXME: The left hand type and right hand type don't match 366 // FIXME: The left hand type and right hand type don't match
374 // FlowEntry.groupId() still returns a short value, not int. 367 // FlowEntry.groupId() still returns a short value, not int.
375 return flowEntry.groupId().equals(groupId.get()); 368 return flowEntry.groupId().equals(groupId.get());
376 - }
377 }; 369 };
378 } 370 }
379 } 371 }
......
...@@ -24,7 +24,6 @@ import java.net.URI; ...@@ -24,7 +24,6 @@ import java.net.URI;
24 import org.junit.Before; 24 import org.junit.Before;
25 import org.junit.Test; 25 import org.junit.Test;
26 import org.onlab.packet.ChassisId; 26 import org.onlab.packet.ChassisId;
27 -import org.onosproject.net.config.Config;
28 import org.onosproject.net.config.ConfigApplyDelegate; 27 import org.onosproject.net.config.ConfigApplyDelegate;
29 import org.onosproject.net.config.basics.BasicDeviceConfig; 28 import org.onosproject.net.config.basics.BasicDeviceConfig;
30 import org.onosproject.net.AnnotationKeys; 29 import org.onosproject.net.AnnotationKeys;
...@@ -55,11 +54,7 @@ public class BasicDeviceOperatorTest { ...@@ -55,11 +54,7 @@ public class BasicDeviceOperatorTest {
55 private static final DeviceDescription DEV1 = new DefaultDeviceDescription( 54 private static final DeviceDescription DEV1 = new DefaultDeviceDescription(
56 DURI, SWITCH, MFR, HW, SW, SN, CID, SA); 55 DURI, SWITCH, MFR, HW, SW, SN, CID, SA);
57 56
58 - private final ConfigApplyDelegate delegate = new ConfigApplyDelegate() { 57 + private final ConfigApplyDelegate delegate = config -> { };
59 - @Override
60 - public void onApply(Config config) {
61 - }
62 - };
63 private final ObjectMapper mapper = new ObjectMapper(); 58 private final ObjectMapper mapper = new ObjectMapper();
64 59
65 private static final BasicDeviceConfig SW_BDC = new BasicDeviceConfig(); 60 private static final BasicDeviceConfig SW_BDC = new BasicDeviceConfig();
......
...@@ -22,7 +22,6 @@ import org.junit.Test; ...@@ -22,7 +22,6 @@ import org.junit.Test;
22 import org.onlab.packet.IpAddress; 22 import org.onlab.packet.IpAddress;
23 import org.onlab.packet.MacAddress; 23 import org.onlab.packet.MacAddress;
24 import org.onlab.packet.VlanId; 24 import org.onlab.packet.VlanId;
25 -import org.onosproject.net.config.Config;
26 import org.onosproject.net.config.ConfigApplyDelegate; 25 import org.onosproject.net.config.ConfigApplyDelegate;
27 import org.onosproject.net.config.basics.BasicHostConfig; 26 import org.onosproject.net.config.basics.BasicHostConfig;
28 import org.onosproject.net.AnnotationKeys; 27 import org.onosproject.net.AnnotationKeys;
...@@ -49,11 +48,7 @@ public class BasicHostOperatorTest { ...@@ -49,11 +48,7 @@ public class BasicHostOperatorTest {
49 ); 48 );
50 private static final HostDescription HOST = new DefaultHostDescription(MAC, VLAN, LOC, IP); 49 private static final HostDescription HOST = new DefaultHostDescription(MAC, VLAN, LOC, IP);
51 50
52 - private final ConfigApplyDelegate delegate = new ConfigApplyDelegate() { 51 + private final ConfigApplyDelegate delegate = config -> { };
53 - @Override
54 - public void onApply(Config config) {
55 - }
56 - };
57 private final ObjectMapper mapper = new ObjectMapper(); 52 private final ObjectMapper mapper = new ObjectMapper();
58 53
59 private static final BasicHostConfig BHC = new BasicHostConfig(); 54 private static final BasicHostConfig BHC = new BasicHostConfig();
......
...@@ -22,7 +22,6 @@ import static org.junit.Assert.assertEquals; ...@@ -22,7 +22,6 @@ import static org.junit.Assert.assertEquals;
22 import java.time.Duration; 22 import java.time.Duration;
23 import org.junit.Before; 23 import org.junit.Before;
24 import org.junit.Test; 24 import org.junit.Test;
25 -import org.onosproject.net.config.Config;
26 import org.onosproject.net.config.ConfigApplyDelegate; 25 import org.onosproject.net.config.ConfigApplyDelegate;
27 import org.onosproject.net.config.basics.BasicLinkConfig; 26 import org.onosproject.net.config.basics.BasicLinkConfig;
28 import org.onosproject.net.AnnotationKeys; 27 import org.onosproject.net.AnnotationKeys;
...@@ -53,11 +52,7 @@ public class BasicLinkOperatorTest { ...@@ -53,11 +52,7 @@ public class BasicLinkOperatorTest {
53 private static final SparseAnnotations SA = DefaultAnnotations.builder() 52 private static final SparseAnnotations SA = DefaultAnnotations.builder()
54 .set(AnnotationKeys.DURABLE, "true").build(); 53 .set(AnnotationKeys.DURABLE, "true").build();
55 private static final LinkDescription LD = new DefaultLinkDescription(SRC, DST, Link.Type.DIRECT, SA); 54 private static final LinkDescription LD = new DefaultLinkDescription(SRC, DST, Link.Type.DIRECT, SA);
56 - private final ConfigApplyDelegate delegate = new ConfigApplyDelegate() { 55 + private final ConfigApplyDelegate delegate = config -> { };
57 - @Override
58 - public void onApply(Config config) {
59 - }
60 - };
61 private final ObjectMapper mapper = new ObjectMapper(); 56 private final ObjectMapper mapper = new ObjectMapper();
62 57
63 private static final BasicLinkConfig BLC = new BasicLinkConfig(); 58 private static final BasicLinkConfig BLC = new BasicLinkConfig();
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
15 */ 15 */
16 package org.onosproject.store.device.impl; 16 package org.onosproject.store.device.impl;
17 17
18 -import com.google.common.base.Function;
19 import com.google.common.collect.FluentIterable; 18 import com.google.common.collect.FluentIterable;
20 import com.google.common.collect.ImmutableList; 19 import com.google.common.collect.ImmutableList;
21 import com.google.common.collect.Maps; 20 import com.google.common.collect.Maps;
...@@ -564,13 +563,10 @@ public class GossipDeviceStore ...@@ -564,13 +563,10 @@ public class GossipDeviceStore
564 final DeviceDescriptions descs = device.get(providerId); 563 final DeviceDescriptions descs = device.get(providerId);
565 List<PortDescription> mergedList = 564 List<PortDescription> mergedList =
566 FluentIterable.from(portDescriptions) 565 FluentIterable.from(portDescriptions)
567 - .transform(new Function<PortDescription, PortDescription>() { 566 + .transform(input ->
568 - @Override
569 - public PortDescription apply(PortDescription input) {
570 // lookup merged port description 567 // lookup merged port description
571 - return descs.getPortDesc(input.portNumber()).value(); 568 + descs.getPortDesc(input.portNumber()).value()
572 - } 569 + ).toList();
573 - }).toList();
574 merged = new Timestamped<>(mergedList, newTimestamp); 570 merged = new Timestamped<>(mergedList, newTimestamp);
575 } 571 }
576 572
......
...@@ -802,31 +802,22 @@ public class GossipDeviceStoreTest { ...@@ -802,31 +802,22 @@ public class GossipDeviceStoreTest {
802 @Test 802 @Test
803 public final void testEvents() throws InterruptedException { 803 public final void testEvents() throws InterruptedException {
804 final CountDownLatch addLatch = new CountDownLatch(1); 804 final CountDownLatch addLatch = new CountDownLatch(1);
805 - DeviceStoreDelegate checkAdd = new DeviceStoreDelegate() { 805 + DeviceStoreDelegate checkAdd = event -> {
806 - @Override
807 - public void notify(DeviceEvent event) {
808 assertEquals(DEVICE_ADDED, event.type()); 806 assertEquals(DEVICE_ADDED, event.type());
809 assertDevice(DID1, SW1, event.subject()); 807 assertDevice(DID1, SW1, event.subject());
810 addLatch.countDown(); 808 addLatch.countDown();
811 - }
812 }; 809 };
813 final CountDownLatch updateLatch = new CountDownLatch(1); 810 final CountDownLatch updateLatch = new CountDownLatch(1);
814 - DeviceStoreDelegate checkUpdate = new DeviceStoreDelegate() { 811 + DeviceStoreDelegate checkUpdate = event -> {
815 - @Override
816 - public void notify(DeviceEvent event) {
817 assertEquals(DEVICE_UPDATED, event.type()); 812 assertEquals(DEVICE_UPDATED, event.type());
818 assertDevice(DID1, SW2, event.subject()); 813 assertDevice(DID1, SW2, event.subject());
819 updateLatch.countDown(); 814 updateLatch.countDown();
820 - }
821 }; 815 };
822 final CountDownLatch removeLatch = new CountDownLatch(1); 816 final CountDownLatch removeLatch = new CountDownLatch(1);
823 - DeviceStoreDelegate checkRemove = new DeviceStoreDelegate() { 817 + DeviceStoreDelegate checkRemove = event -> {
824 - @Override
825 - public void notify(DeviceEvent event) {
826 assertEquals(DEVICE_REMOVED, event.type()); 818 assertEquals(DEVICE_REMOVED, event.type());
827 assertDevice(DID1, SW2, event.subject()); 819 assertDevice(DID1, SW2, event.subject());
828 removeLatch.countDown(); 820 removeLatch.countDown();
829 - }
830 }; 821 };
831 822
832 DeviceDescription description = 823 DeviceDescription description =
......
...@@ -548,31 +548,22 @@ public class GossipLinkStoreTest { ...@@ -548,31 +548,22 @@ public class GossipLinkStoreTest {
548 final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2); 548 final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2);
549 549
550 final CountDownLatch addLatch = new CountDownLatch(1); 550 final CountDownLatch addLatch = new CountDownLatch(1);
551 - LinkStoreDelegate checkAdd = new LinkStoreDelegate() { 551 + LinkStoreDelegate checkAdd = event -> {
552 - @Override
553 - public void notify(LinkEvent event) {
554 assertEquals(LINK_ADDED, event.type()); 552 assertEquals(LINK_ADDED, event.type());
555 assertLink(linkId1, INDIRECT, event.subject()); 553 assertLink(linkId1, INDIRECT, event.subject());
556 addLatch.countDown(); 554 addLatch.countDown();
557 - }
558 }; 555 };
559 final CountDownLatch updateLatch = new CountDownLatch(1); 556 final CountDownLatch updateLatch = new CountDownLatch(1);
560 - LinkStoreDelegate checkUpdate = new LinkStoreDelegate() { 557 + LinkStoreDelegate checkUpdate = event -> {
561 - @Override
562 - public void notify(LinkEvent event) {
563 assertEquals(LINK_UPDATED, event.type()); 558 assertEquals(LINK_UPDATED, event.type());
564 assertLink(linkId1, DIRECT, event.subject()); 559 assertLink(linkId1, DIRECT, event.subject());
565 updateLatch.countDown(); 560 updateLatch.countDown();
566 - }
567 }; 561 };
568 final CountDownLatch removeLatch = new CountDownLatch(1); 562 final CountDownLatch removeLatch = new CountDownLatch(1);
569 - LinkStoreDelegate checkRemove = new LinkStoreDelegate() { 563 + LinkStoreDelegate checkRemove = event -> {
570 - @Override
571 - public void notify(LinkEvent event) {
572 assertEquals(LINK_REMOVED, event.type()); 564 assertEquals(LINK_REMOVED, event.type());
573 assertLink(linkId1, DIRECT, event.subject()); 565 assertLink(linkId1, DIRECT, event.subject());
574 removeLatch.countDown(); 566 removeLatch.countDown();
575 - }
576 }; 567 };
577 568
578 linkStore.setDelegate(checkAdd); 569 linkStore.setDelegate(checkAdd);
......