Make use of Optional more idiomatic
Change-Id: I42b3261169e7cb8408f46c5831f72115f77fd779
diff --git a/drivers/default/src/main/java/org/onosproject/driver/pipeline/DefaultSingleTablePipeline.java b/drivers/default/src/main/java/org/onosproject/driver/pipeline/DefaultSingleTablePipeline.java
index 7e22501..baa08b8 100644
--- a/drivers/default/src/main/java/org/onosproject/driver/pipeline/DefaultSingleTablePipeline.java
+++ b/drivers/default/src/main/java/org/onosproject/driver/pipeline/DefaultSingleTablePipeline.java
@@ -156,16 +156,13 @@
flowRuleService.apply(flowBuilder.build(new FlowRuleOperationsContext() {
@Override
public void onSuccess(FlowRuleOperations ops) {
- if (objective.context().isPresent()) {
- objective.context().get().onSuccess(objective);
- }
+ objective.context().ifPresent(context -> context.onSuccess(objective));
}
@Override
public void onError(FlowRuleOperations ops) {
- if (objective.context().isPresent()) {
- objective.context().get().onError(objective, ObjectiveError.FLOWINSTALLATIONFAILED);
- }
+ objective.context()
+ .ifPresent(context -> context.onError(objective, ObjectiveError.FLOWINSTALLATIONFAILED));
}
}));
}