Add DefaultLinkResourceRequest implementation.
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/DefaultLinkResourceRequest.java b/core/api/src/main/java/org/onlab/onos/net/resource/DefaultLinkResourceRequest.java
new file mode 100644
index 0000000..38f90c1
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/DefaultLinkResourceRequest.java
@@ -0,0 +1,118 @@
+package org.onlab.onos.net.resource;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.onlab.onos.net.Link;
+import org.onlab.onos.net.intent.IntentId;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Implementation of {@link LinkResourceRequest}.
+ */
+public final class DefaultLinkResourceRequest implements LinkResourceRequest {
+
+ private final IntentId intentId;
+ private final Collection<Link> links;
+ private final Set<ResourceRequest> resources;
+
+ /**
+ * Creates a new link resource request with the given ID, links, and
+ * resource requests.
+ *
+ * @param intentId intent ID related to this request
+ * @param links a set of links for the request
+ * @param resources a set of resources to be requested
+ */
+ private DefaultLinkResourceRequest(IntentId intentId,
+ Collection<Link> links,
+ Set<ResourceRequest> resources) {
+ this.intentId = intentId;
+ this.links = ImmutableSet.copyOf(links);
+ this.resources = ImmutableSet.copyOf(resources);
+ }
+
+ @Override
+ public IntentId intendId() {
+ return intentId;
+ }
+
+ @Override
+ public Collection<Link> links() {
+ return links;
+ }
+
+ @Override
+ public Set<ResourceRequest> resources() {
+ return resources;
+ }
+
+ /**
+ * Returns builder of link resource request.
+ *
+ * @param intentId intent ID related to this request
+ * @param links a set of links for the request
+ * @return builder of link resource request
+ */
+ public static LinkResourceRequest.Builder builder(
+ IntentId intentId, Collection<Link> links) {
+ return new Builder(intentId, links);
+ }
+
+ /**
+ * Builder of link resource request.
+ */
+ public static final class Builder implements LinkResourceRequest.Builder {
+ private IntentId intentId;
+ private Collection<Link> links;
+ private Set<ResourceRequest> resources;
+
+ /**
+ * Creates a new link resource request.
+ *
+ * @param intentId intent ID related to this request
+ * @param links a set of links for the request
+ */
+ private Builder(IntentId intentId, Collection<Link> links) {
+ this.intentId = intentId;
+ this.links = links;
+ this.resources = new HashSet<>();
+ }
+
+ /**
+ * Adds lambda request.
+ *
+ * @return self
+ */
+ @Override
+ public Builder addLambdaRequest() {
+ resources.add(new LambdaResourceRequest());
+ return this;
+ }
+
+ /**
+ * Adds bandwidth request with bandwidth value.
+ *
+ * @param bandwidth bandwidth value to be requested
+ * @return self
+ */
+ @Override
+ public Builder addBandwidthRequest(double bandwidth) {
+ resources.add(new BandwidthResourceRequest(bandwidth));
+ return this;
+ }
+
+ /**
+ * Returns link resource request.
+ *
+ * @return link resource request
+ */
+ @Override
+ public LinkResourceRequest build() {
+ return new DefaultLinkResourceRequest(intentId, links, resources);
+ }
+ }
+
+}
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceAllocations.java b/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceAllocations.java
index 3dce62f..a3d3e87 100644
--- a/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceAllocations.java
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceAllocations.java
@@ -5,7 +5,7 @@
/**
* Representation of allocated link resources.
*/
-public interface LinkResourceAllocations {
+public interface LinkResourceAllocations extends LinkResourceRequest {
/**
* Returns allocated resource for the given link.
*
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceRequest.java b/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceRequest.java
index 331bf83..3f32b06 100644
--- a/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceRequest.java
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceRequest.java
@@ -1,108 +1,47 @@
package org.onlab.onos.net.resource;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Set;
import org.onlab.onos.net.Link;
import org.onlab.onos.net.intent.IntentId;
-import com.google.common.collect.ImmutableSet;
-
/**
* Representation of a request for link resource.
*/
-public final class LinkResourceRequest implements ResourceRequest {
- // TODO: should this class be interface?
-
- private final IntentId intentId;
- private final Collection<Link> links;
- private final Set<ResourceRequest> resources;
-
- /**
- * Creates a new link resource request with the given ID, links, and
- * resource requests.
- *
- * @param intentId intent ID related to this request
- * @param links a set of links for the request
- * @param resources a set of resources to be requested
- */
- private LinkResourceRequest(IntentId intentId,
- Collection<Link> links,
- Set<ResourceRequest> resources) {
- this.intentId = intentId;
- this.links = ImmutableSet.copyOf(links);
- this.resources = ImmutableSet.copyOf(resources);
- }
+public interface LinkResourceRequest extends ResourceRequest {
/**
* Returns the {@link IntentId} associated with the request.
*
* @return the {@link IntentId} associated with the request
*/
- IntentId intendId() {
- return intentId;
- }
+ IntentId intendId();
/**
* Returns the set of target links.
*
* @return the set of target links
*/
- Collection<Link> links() {
- return links;
- }
+ Collection<Link> links();
/**
* Returns the set of resource requests.
*
* @return the set of resource requests
*/
- Set<ResourceRequest> resources() {
- return resources;
- }
-
- /**
- * Returns builder of link resource request.
- *
- * @param intentId intent ID related to this request
- * @param links a set of links for the request
- * @return builder of link resource request
- */
- public static LinkResourceRequest.Builder builder(
- IntentId intentId, Collection<Link> links) {
- return new Builder(intentId, links);
- }
+ Set<ResourceRequest> resources();
/**
* Builder of link resource request.
*/
- public static final class Builder {
- private IntentId intentId;
- private Collection<Link> links;
- private Set<ResourceRequest> resources;
-
- /**
- * Creates a new link resource request.
- *
- * @param intentId intent ID related to this request
- * @param links a set of links for the request
- */
- private Builder(IntentId intentId, Collection<Link> links) {
- this.intentId = intentId;
- this.links = links;
- this.resources = new HashSet<>();
- }
-
- /**
+ interface Builder {
+ /**
* Adds lambda request.
*
* @return self
*/
- public Builder addLambdaRequest() {
- resources.add(new LambdaResourceRequest());
- return this;
- }
+ public Builder addLambdaRequest();
/**
* Adds bandwidth request with bandwidth value.
@@ -110,18 +49,13 @@
* @param bandwidth bandwidth value to be requested
* @return self
*/
- public Builder addBandwidthRequest(double bandwidth) {
- resources.add(new BandwidthResourceRequest(bandwidth));
- return this;
- }
+ public Builder addBandwidthRequest(double bandwidth);
/**
* Returns link resource request.
*
* @return link resource request
*/
- public LinkResourceRequest build() {
- return new LinkResourceRequest(intentId, links, resources);
- }
+ public LinkResourceRequest build();
}
}