Implement IntentCompilers
For the following Intent types
- PointToPointIntent
- PathIntent
- MultiPointToSinglePointIntent
This resolves ONOS-1657, ONOS-1659, and ONOS-1660.
Change-Id: I7c68cec4b025a59f9c97bae4488801bea2716baf
diff --git a/src/main/java/net/onrc/onos/core/newintent/AbstractFlowGeneratingIntentCompiler.java b/src/main/java/net/onrc/onos/core/newintent/AbstractFlowGeneratingIntentCompiler.java
new file mode 100644
index 0000000..07041e9
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/newintent/AbstractFlowGeneratingIntentCompiler.java
@@ -0,0 +1,41 @@
+package net.onrc.onos.core.newintent;
+
+import net.onrc.onos.api.flowmanager.FlowId;
+import net.onrc.onos.api.flowmanager.FlowIdGenerator;
+import net.onrc.onos.api.newintent.Intent;
+import net.onrc.onos.api.newintent.IntentIdGenerator;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * A base class of {@link net.onrc.onos.api.newintent.IntentCompiler},
+ * which generates Flow objects.
+ * @param <T>
+ */
+public abstract class AbstractFlowGeneratingIntentCompiler<T extends Intent>
+ extends AbstractIntentCompiler<T> {
+
+ private final FlowIdGenerator flowIdGenerator;
+
+ /**
+ * Constructs an object with the specified {@link IntentIdGenerator}
+ * and {@link FlowIdGenerator}.
+ *
+ * @param intentIdGenerator
+ * @param flowIdGenerator
+ */
+ protected AbstractFlowGeneratingIntentCompiler(IntentIdGenerator intentIdGenerator,
+ FlowIdGenerator flowIdGenerator) {
+ super(intentIdGenerator);
+ this.flowIdGenerator = checkNotNull(flowIdGenerator);
+ }
+
+ /**
+ * Returns the next {@link FlowId}.
+ *
+ * @return the next {@link FlowId}
+ */
+ protected FlowId getNextFlowId() {
+ return flowIdGenerator.getNewId();
+ }
+}