Sho SHIMIZU
Committed by Ray Milkey

Use Optional instead of null to remove FIXME comment

Change-Id: I21c0cd954eaff4441392205aede95b34285f1402
......@@ -17,23 +17,25 @@ package org.onosproject.net.flow;
import org.onosproject.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
import java.util.Optional;
public class FlowRuleBatchEntry
extends BatchOperationEntry<FlowRuleOperation, FlowRule> {
private final Long id; // FIXME: consider using Optional<Long>
private final Optional<Long> id;
public FlowRuleBatchEntry(FlowRuleOperation operator, FlowRule target) {
super(operator, target);
this.id = null;
this.id = Optional.empty();
}
public FlowRuleBatchEntry(FlowRuleOperation operator, FlowRule target, Long id) {
public FlowRuleBatchEntry(FlowRuleOperation operator, FlowRule target, long id) {
super(operator, target);
this.id = id;
this.id = Optional.of(id);
}
public Long id() {
public Optional<Long> id() {
return id;
}
......
......@@ -385,7 +385,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
private final Set<FlowEntry> offendingFlowMods = Sets.newHashSet();
// Failed batch operation id
private Long failedId;
private Optional<Long> failedId;
private final CountDownLatch countDownLatch;
private BatchState state;
......@@ -509,7 +509,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
public CompletedBatchOperation get() throws InterruptedException, ExecutionException {
countDownLatch.await();
this.state = BatchState.FINISHED;
Set<Long> failedIds = (failedId != null) ? Sets.newHashSet(failedId) : Collections.emptySet();
Set<Long> failedIds = (failedId.isPresent()) ? Sets.newHashSet(failedId.get()) : Collections.emptySet();
CompletedBatchOperation result =
new CompletedBatchOperation(ok.get(), offendingFlowMods, failedIds);
//FIXME do cleanup here (moved by BOC)
......@@ -523,7 +523,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
TimeoutException {
if (countDownLatch.await(timeout, unit)) {
this.state = BatchState.FINISHED;
Set<Long> failedIds = (failedId != null) ? Sets.newHashSet(failedId) : Collections.emptySet();
Set<Long> failedIds = (failedId.isPresent()) ? Sets.newHashSet(failedId.get()) : Collections.emptySet();
CompletedBatchOperation result =
new CompletedBatchOperation(ok.get(), offendingFlowMods, failedIds);
// FIXME do cleanup here (moved by BOC)
......