Committed by
Ray Milkey
Use Optional instead of null to remove FIXME comment
Change-Id: I21c0cd954eaff4441392205aede95b34285f1402
Showing
2 changed files
with
10 additions
and
8 deletions
... | @@ -17,23 +17,25 @@ package org.onosproject.net.flow; | ... | @@ -17,23 +17,25 @@ package org.onosproject.net.flow; |
17 | 17 | ||
18 | import org.onosproject.net.flow.FlowRuleBatchEntry.FlowRuleOperation; | 18 | import org.onosproject.net.flow.FlowRuleBatchEntry.FlowRuleOperation; |
19 | 19 | ||
20 | +import java.util.Optional; | ||
21 | + | ||
20 | 22 | ||
21 | public class FlowRuleBatchEntry | 23 | public class FlowRuleBatchEntry |
22 | extends BatchOperationEntry<FlowRuleOperation, FlowRule> { | 24 | extends BatchOperationEntry<FlowRuleOperation, FlowRule> { |
23 | 25 | ||
24 | - private final Long id; // FIXME: consider using Optional<Long> | 26 | + private final Optional<Long> id; |
25 | 27 | ||
26 | public FlowRuleBatchEntry(FlowRuleOperation operator, FlowRule target) { | 28 | public FlowRuleBatchEntry(FlowRuleOperation operator, FlowRule target) { |
27 | super(operator, target); | 29 | super(operator, target); |
28 | - this.id = null; | 30 | + this.id = Optional.empty(); |
29 | } | 31 | } |
30 | 32 | ||
31 | - public FlowRuleBatchEntry(FlowRuleOperation operator, FlowRule target, Long id) { | 33 | + public FlowRuleBatchEntry(FlowRuleOperation operator, FlowRule target, long id) { |
32 | super(operator, target); | 34 | super(operator, target); |
33 | - this.id = id; | 35 | + this.id = Optional.of(id); |
34 | } | 36 | } |
35 | 37 | ||
36 | - public Long id() { | 38 | + public Optional<Long> id() { |
37 | return id; | 39 | return id; |
38 | } | 40 | } |
39 | 41 | ... | ... |
... | @@ -385,7 +385,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -385,7 +385,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
385 | 385 | ||
386 | private final Set<FlowEntry> offendingFlowMods = Sets.newHashSet(); | 386 | private final Set<FlowEntry> offendingFlowMods = Sets.newHashSet(); |
387 | // Failed batch operation id | 387 | // Failed batch operation id |
388 | - private Long failedId; | 388 | + private Optional<Long> failedId; |
389 | 389 | ||
390 | private final CountDownLatch countDownLatch; | 390 | private final CountDownLatch countDownLatch; |
391 | private BatchState state; | 391 | private BatchState state; |
... | @@ -509,7 +509,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -509,7 +509,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
509 | public CompletedBatchOperation get() throws InterruptedException, ExecutionException { | 509 | public CompletedBatchOperation get() throws InterruptedException, ExecutionException { |
510 | countDownLatch.await(); | 510 | countDownLatch.await(); |
511 | this.state = BatchState.FINISHED; | 511 | this.state = BatchState.FINISHED; |
512 | - Set<Long> failedIds = (failedId != null) ? Sets.newHashSet(failedId) : Collections.emptySet(); | 512 | + Set<Long> failedIds = (failedId.isPresent()) ? Sets.newHashSet(failedId.get()) : Collections.emptySet(); |
513 | CompletedBatchOperation result = | 513 | CompletedBatchOperation result = |
514 | new CompletedBatchOperation(ok.get(), offendingFlowMods, failedIds); | 514 | new CompletedBatchOperation(ok.get(), offendingFlowMods, failedIds); |
515 | //FIXME do cleanup here (moved by BOC) | 515 | //FIXME do cleanup here (moved by BOC) |
... | @@ -523,7 +523,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -523,7 +523,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
523 | TimeoutException { | 523 | TimeoutException { |
524 | if (countDownLatch.await(timeout, unit)) { | 524 | if (countDownLatch.await(timeout, unit)) { |
525 | this.state = BatchState.FINISHED; | 525 | this.state = BatchState.FINISHED; |
526 | - Set<Long> failedIds = (failedId != null) ? Sets.newHashSet(failedId) : Collections.emptySet(); | 526 | + Set<Long> failedIds = (failedId.isPresent()) ? Sets.newHashSet(failedId.get()) : Collections.emptySet(); |
527 | CompletedBatchOperation result = | 527 | CompletedBatchOperation result = |
528 | new CompletedBatchOperation(ok.get(), offendingFlowMods, failedIds); | 528 | new CompletedBatchOperation(ok.get(), offendingFlowMods, failedIds); |
529 | // FIXME do cleanup here (moved by BOC) | 529 | // FIXME do cleanup here (moved by BOC) | ... | ... |
-
Please register or login to post a comment