Inline static factory methods in BandwidthResource
Change-Id: I8ac7fbaea5c81c9558f88f6ac88bcf581466d073
diff --git a/core/api/src/main/java/org/onosproject/net/resource/BandwidthResource.java b/core/api/src/main/java/org/onosproject/net/resource/BandwidthResource.java
index 0f39198..3c8ebea 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/BandwidthResource.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/BandwidthResource.java
@@ -33,7 +33,7 @@
*
* @param bandwidth bandwidth value to be assigned
*/
- private BandwidthResource(Bandwidth bandwidth) {
+ public BandwidthResource(Bandwidth bandwidth) {
this.bandwidth = checkNotNull(bandwidth);
}
@@ -43,61 +43,6 @@
}
/**
- * Creates a new instance with given bandwidth in bps.
- *
- * @param bandwidth bandwidth value to be assigned
- * @return {@link BandwidthResource} instance with given bandwidth
- */
- @Deprecated
- public static BandwidthResource valueOf(double bandwidth) {
- return bps(bandwidth);
- }
-
- public static BandwidthResource from(Bandwidth bandwidth) {
- return new BandwidthResource(bandwidth);
- }
-
- /**
- * Creates a new instance with given bandwidth in bps.
- *
- * @param bps bandwidth value to be assigned
- * @return {@link BandwidthResource} instance with given bandwidth
- */
- public static BandwidthResource bps(double bps) {
- return from(Bandwidth.bps(bps));
- }
-
- /**
- * Creates a new instance with given bandwidth in Kbps.
- *
- * @param kbps bandwidth value to be assigned
- * @return {@link BandwidthResource} instance with given bandwidth
- */
- public static BandwidthResource kbps(double kbps) {
- return from(Bandwidth.kbps(kbps));
- }
-
- /**
- * Creates a new instance with given bandwidth in Mbps.
- *
- * @param mbps bandwidth value to be assigned
- * @return {@link BandwidthResource} instance with given bandwidth
- */
- public static BandwidthResource mbps(double mbps) {
- return from(Bandwidth.mbps(mbps));
- }
-
- /**
- * Creates a new instance with given bandwidth in Gbps.
- *
- * @param gbps bandwidth value to be assigned
- * @return {@link BandwidthResource} instance with given bandwidth
- */
- public static BandwidthResource gbps(double gbps) {
- return from(Bandwidth.gbps(gbps));
- }
-
- /**
* Returns bandwidth as a double value.
*
* @return bandwidth as a double value
diff --git a/core/api/src/main/java/org/onosproject/net/resource/DefaultLinkResourceRequest.java b/core/api/src/main/java/org/onosproject/net/resource/DefaultLinkResourceRequest.java
index 1ec1fc4..8d08e3b 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/DefaultLinkResourceRequest.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/DefaultLinkResourceRequest.java
@@ -20,6 +20,7 @@
import java.util.Set;
import java.util.Objects;
+import org.onlab.util.Bandwidth;
import org.onosproject.net.Link;
import org.onosproject.net.intent.Constraint;
import org.onosproject.net.intent.IntentId;
@@ -137,7 +138,7 @@
*/
@Override
public Builder addBandwidthRequest(double bandwidth) {
- resources.add(new BandwidthResourceRequest(BandwidthResource.bps(bandwidth)));
+ resources.add(new BandwidthResourceRequest(new BandwidthResource(Bandwidth.bps(bandwidth))));
return this;
}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
index 37bea8d..47faf4a 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
@@ -18,6 +18,7 @@
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableSet;
+import org.onlab.util.Bandwidth;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.core.GroupId;
import org.onosproject.net.DeviceId;
@@ -302,7 +303,7 @@
final List<ResourceRequest> result = new LinkedList<>();
if (availableBandwidth > 0.0) {
result.add(new BandwidthResourceRequest(
- BandwidthResource.bps(availableBandwidth)));
+ new BandwidthResource(Bandwidth.bps(availableBandwidth))));
}
if (availableLambda > 0) {
result.add(new LambdaResourceRequest());
diff --git a/core/api/src/test/java/org/onosproject/net/intent/constraint/ConstraintObjectsTest.java b/core/api/src/test/java/org/onosproject/net/intent/constraint/ConstraintObjectsTest.java
index 5505e13..cc29a25 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/constraint/ConstraintObjectsTest.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/constraint/ConstraintObjectsTest.java
@@ -16,6 +16,7 @@
package org.onosproject.net.intent.constraint;
import org.junit.Test;
+import org.onlab.util.Bandwidth;
import org.onosproject.net.Link;
import org.onosproject.net.resource.BandwidthResource;
import org.onosproject.net.resource.LambdaResource;
@@ -34,12 +35,16 @@
// Bandwidth Constraint
+ private final Bandwidth bandwidth1 = Bandwidth.bps(100.0);
+ private final Bandwidth sameAsBandwidth1 = Bandwidth.bps(100.0);
+ private final Bandwidth bandwidth2 = Bandwidth.bps(200.0);
+
final BandwidthConstraint bandwidthConstraint1 =
- new BandwidthConstraint(BandwidthResource.bps(100.0));
+ new BandwidthConstraint(new BandwidthResource(bandwidth1));
final BandwidthConstraint bandwidthConstraintSameAs1 =
- new BandwidthConstraint(BandwidthResource.bps(100.0));
+ new BandwidthConstraint(new BandwidthResource(sameAsBandwidth1));
final BandwidthConstraint bandwidthConstraint2 =
- new BandwidthConstraint(BandwidthResource.bps(200.0));
+ new BandwidthConstraint(new BandwidthResource(bandwidth2));
/**
* Checks that the objects were created properly.