[Cardinal] Add builders for Intents and remove extra constructors.
Starting with PointToPoint intent to see how it looks
Change-Id: I5366a05d657ceaad18c03b95cd71f5d1107200e2
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
index 3c93fa6..4ca0ebd 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
@@ -67,11 +67,16 @@
List<Constraint> constraints = buildConstraints();
- Intent intent = new PointToPointIntent(appId(),
- key(),
- selector, treatment,
- ingress, egress, constraints,
- priority());
+ Intent intent = PointToPointIntent.builder()
+ .appId(appId())
+ .key(key())
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(ingress)
+ .egressPoint(egress)
+ .constraints(constraints)
+ .priority(priority())
+ .build();
service.submit(intent);
print("Point to point intent submitted:\n%s", intent.toString());
}
diff --git a/cli/src/main/java/org/onosproject/cli/net/IntentCycleCommand.java b/cli/src/main/java/org/onosproject/cli/net/IntentCycleCommand.java
index 6a61295..1c01c5b 100644
--- a/cli/src/main/java/org/onosproject/cli/net/IntentCycleCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/IntentCycleCommand.java
@@ -15,7 +15,11 @@
*/
package org.onosproject.cli.net;
-import com.google.common.collect.Lists;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicLong;
+
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.onlab.packet.Ethernet;
@@ -36,11 +40,7 @@
import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.PointToPointIntent;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicLong;
+import com.google.common.collect.Lists;
import static org.onlab.util.Tools.delay;
import static org.onosproject.net.DeviceId.deviceId;
@@ -127,11 +127,16 @@
TrafficSelector selector = selectorBldr
.matchEthSrc(MacAddress.valueOf(i + keyOffset))
.build();
- intents.add(new PointToPointIntent(appId(), Key.of(i + keyOffset, appId()),
- selector, treatment,
- ingress, egress,
- Collections.emptyList(),
- Intent.DEFAULT_INTENT_PRIORITY));
+ intents.add(
+ PointToPointIntent.builder()
+ .appId(appId())
+ .key(Key.of(i + keyOffset, appId()))
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(ingress)
+ .egressPoint(egress)
+ .build());
+
}
return intents;
diff --git a/cli/src/main/java/org/onosproject/cli/net/IntentPushTestCommand.java b/cli/src/main/java/org/onosproject/cli/net/IntentPushTestCommand.java
index 20af27d..b31ad68 100644
--- a/cli/src/main/java/org/onosproject/cli/net/IntentPushTestCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/IntentPushTestCommand.java
@@ -15,7 +15,11 @@
*/
package org.onosproject.cli.net;
-import com.google.common.collect.Lists;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
@@ -37,11 +41,7 @@
import org.onosproject.net.intent.Key;
import org.onosproject.net.intent.PointToPointIntent;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import com.google.common.collect.Lists;
import static org.onosproject.net.DeviceId.deviceId;
import static org.onosproject.net.PortNumber.portNumber;
@@ -136,11 +136,15 @@
TrafficSelector selector = selectorBldr
.matchEthSrc(MacAddress.valueOf(i + keyOffset))
.build();
- intents.add(new PointToPointIntent(appId(), Key.of(i + keyOffset, appId()),
- selector, treatment,
- ingress, egress,
- Collections.emptyList(),
- Intent.DEFAULT_INTENT_PRIORITY));
+ intents.add(PointToPointIntent.builder()
+ .appId(appId())
+ .key(Key.of(i + keyOffset, appId()))
+ .selector(selector)
+ .treatment(treatment)
+ .ingressPoint(ingress)
+ .egressPoint(egress)
+ .build());
+
}
return intents;