Refactor connectivity intent creation to use builders
- Each connectivity intent now has only one constructor
- Intent constructors are now private for leaf classes and
protected for classes that can be derived from
- Each intent class has a Builder class that accumulates
parameters for intent creation
- Each intent class has a public static builder() method
to create a builder
- Each Builder class has a build() method to create the
intent from the accumulated parameters
- Added keys to a few intent types that were missing them
- Tightened up usage of checkNotNull(), taking advantage of
the return value to save some lines of code
- Modified callers to use the builders instead of directly
calling the constructors
Change-Id: I713185d5ecbadbf51f87ef7f68fec41102106c78
diff --git a/core/api/src/main/java/org/onosproject/net/intent/OpticalPathIntent.java b/core/api/src/main/java/org/onosproject/net/intent/OpticalPathIntent.java
index 6804c86..4843877 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/OpticalPathIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/OpticalPathIntent.java
@@ -24,6 +24,8 @@
import java.util.Collection;
+import static com.google.common.base.Preconditions.checkNotNull;
+
public final class OpticalPathIntent extends Intent {
private final ConnectPoint src;
@@ -35,10 +37,11 @@
ConnectPoint src,
ConnectPoint dst,
Path path) {
- super(appId, ImmutableSet.copyOf(path.links()));
- this.src = src;
- this.dst = dst;
- this.path = path;
+ super(appId, null, ImmutableSet.copyOf(path.links()),
+ Intent.DEFAULT_INTENT_PRIORITY);
+ this.src = checkNotNull(src);
+ this.dst = checkNotNull(dst);
+ this.path = checkNotNull(path);
}
protected OpticalPathIntent() {
@@ -69,6 +72,7 @@
return MoreObjects.toStringHelper(getClass())
.add("id", id())
.add("appId", appId())
+ .add("key", key())
.add("resources", resources())
.add("ingressPort", src)
.add("egressPort", dst)