Implement builders for optical intents
Change-Id: Ide728a943eb0ec3d3ba995f63c016e7d52bff65c
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 4843877..754d433 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
@@ -15,14 +15,15 @@
*/
package org.onosproject.net.intent;
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableSet;
+import java.util.Collection;
+
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
-import java.util.Collection;
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableSet;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -33,12 +34,16 @@
private final Path path;
- public OpticalPathIntent(ApplicationId appId,
- ConnectPoint src,
- ConnectPoint dst,
- Path path) {
- super(appId, null, ImmutableSet.copyOf(path.links()),
- Intent.DEFAULT_INTENT_PRIORITY);
+ private OpticalPathIntent(ApplicationId appId,
+ Key key,
+ ConnectPoint src,
+ ConnectPoint dst,
+ Path path,
+ int priority) {
+ super(appId,
+ key,
+ ImmutableSet.copyOf(path.links()),
+ priority);
this.src = checkNotNull(src);
this.dst = checkNotNull(dst);
this.path = checkNotNull(path);
@@ -50,6 +55,92 @@
this.path = null;
}
+ /**
+ * Returns a new optical connectivity intent builder.
+ *
+ * @return host to host intent builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+
+ /**
+ * Builder for optical path intents.
+ */
+ public static class Builder extends Intent.Builder {
+ private ConnectPoint src;
+ private ConnectPoint dst;
+ private Path path;
+ Key key;
+
+ @Override
+ public Builder appId(ApplicationId appId) {
+ return (Builder) super.appId(appId);
+ }
+
+ @Override
+ public Builder key(Key key) {
+ return (Builder) super.key(key);
+ }
+
+ @Override
+ public Builder priority(int priority) {
+ return (Builder) super.priority(priority);
+ }
+
+ /**
+ * Sets the source for the intent that will be built.
+ *
+ * @param src source to use for built intent
+ * @return this builder
+ */
+ public Builder src(ConnectPoint src) {
+ this.src = src;
+ return this;
+ }
+
+ /**
+ * Sets the destination for the intent that will be built.
+ *
+ * @param dst dest to use for built intent
+ * @return this builder
+ */
+ public Builder dst(ConnectPoint dst) {
+ this.dst = dst;
+ return this;
+ }
+
+ /**
+ * Sets the path for the intent that will be built.
+ *
+ * @param path path to use for built intent
+ * @return this builder
+ */
+ public Builder path(Path path) {
+ this.path = path;
+ return this;
+ }
+
+ /**
+ * Builds an optical path intent from the accumulated parameters.
+ *
+ * @return optical path intent
+ */
+ public OpticalPathIntent build() {
+
+ return new OpticalPathIntent(
+ appId,
+ key,
+ src,
+ dst,
+ path,
+ priority
+ );
+ }
+ }
+
+
public ConnectPoint src() {
return src;
}