Apply Null Object pattern
Change-Id: I9b4d30114b22dcd32b228e4f17bb541beed4ebed
diff --git a/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperations.java b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperations.java
index 5456513..1bf8007 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperations.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleOperations.java
@@ -23,6 +23,7 @@
import java.util.List;
import java.util.Set;
+import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.net.flow.FlowRuleOperation.Type.*;
/**
@@ -32,7 +33,7 @@
public class FlowRuleOperations {
private final List<Set<FlowRuleOperation>> stages;
- private final FlowRuleOperationsContext callback; // TODO consider Optional
+ private final FlowRuleOperationsContext callback;
private FlowRuleOperations(List<Set<FlowRuleOperation>> stages,
FlowRuleOperationsContext cb) {
@@ -164,7 +165,7 @@
* @return flow rule operations
*/
public FlowRuleOperations build() {
- return build(null);
+ return build(NullFlowRuleOperationsContext.getInstance());
}
/**
@@ -174,6 +175,8 @@
* @return flow rule operations
*/
public FlowRuleOperations build(FlowRuleOperationsContext cb) {
+ checkNotNull(cb);
+
closeStage();
return new FlowRuleOperations(listBuilder.build(), cb);
}