Simplify creation of PiActionParam from primitive types
Change-Id: I52053cbe60c4cba3746de1cbf67b16a47ce053bc
diff --git a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionParam.java b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionParam.java
index 4498109..a8d565c 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionParam.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/runtime/PiActionParam.java
@@ -23,9 +23,11 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.ImmutableByteSequence.copyFrom;
/**
- * Instance of an action runtime parameter in a match+action table of a protocol-independent pipeline.
+ * Instance of an action runtime parameter in a match+action table of a
+ * protocol-independent pipeline.
*/
@Beta
public final class PiActionParam {
@@ -34,7 +36,8 @@
private final ImmutableByteSequence value;
/**
- * Creates an action's runtime parameter.
+ * Creates an action's runtime parameter for the given param ID and byte
+ * sequence value.
*
* @param id parameter identifier
* @param value value
@@ -46,6 +49,61 @@
}
/**
+ * Creates an action's runtime parameter for the given param ID and byte
+ * value.
+ *
+ * @param id parameter identifier
+ * @param value value
+ */
+ public PiActionParam(PiActionParamId id, byte value) {
+ this(id, copyFrom(value));
+ }
+
+ /**
+ * Creates an action's runtime parameter for the given param ID and short
+ * value.
+ *
+ * @param id parameter identifier
+ * @param value value
+ */
+ public PiActionParam(PiActionParamId id, short value) {
+ this(id, copyFrom(value));
+ }
+
+ /**
+ * Creates an action's runtime parameter for the given param ID and int
+ * value.
+ *
+ * @param id parameter identifier
+ * @param value value
+ */
+ public PiActionParam(PiActionParamId id, int value) {
+ this(id, copyFrom(value));
+ }
+
+ /**
+ * Creates an action's runtime parameter for the given param ID and long
+ * value.
+ *
+ * @param id parameter identifier
+ * @param value value
+ */
+ public PiActionParam(PiActionParamId id, long value) {
+ this(id, copyFrom(value));
+ }
+
+ /**
+ * Creates an action's runtime parameter for the given param ID and byte
+ * array value.
+ *
+ * @param id parameter identifier
+ * @param value value
+ */
+ public PiActionParam(PiActionParamId id, byte[] value) {
+ this(id, copyFrom(value));
+ }
+
+ /**
* Returns the identifier of this parameter.
*
* @return parameter identifier