Simplify creation of PiActionParam from primitive types

Change-Id: I52053cbe60c4cba3746de1cbf67b16a47ce053bc
This commit is contained in:
Carmelo Cascone 2018-04-18 18:58:56 +09:00
parent 2690face00
commit 4efa498fab

View File

@ -23,9 +23,11 @@ import org.onosproject.net.pi.model.PiActionParamId;
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 @@ public final class PiActionParam {
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
@ -45,6 +48,61 @@ public final class PiActionParam {
checkArgument(value.size() > 0, "Value can't have size 0");
}
/**
* 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.
*