Deprecate ModMplsLabelInstruction#label()
Change-Id: I1324747adaa8ccb28077aa14b208df1083f39a3f
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java
index b4ec0d3..a4176b1 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/L2ModificationInstruction.java
@@ -342,7 +342,13 @@
this.mplsLabel = mplsLabel;
}
- // might want to deprecate this in the long run
+ /**
+ * @deprecated in Drake Release.
+ */
+ // Consider changing return value to MplsLabel
+ // after deprecation process so that it'll be symmetric to
+ // MplsCriterion#label()
+ @Deprecated
public Integer label() {
return mplsLabel.toInt();
}
diff --git a/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java b/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
index d365e92..410349b 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/instructions/InstructionsTest.java
@@ -577,12 +577,13 @@
*/
@Test
public void testModMplsMethod() {
- final Instruction instruction = Instructions.modMplsLabel(MplsLabel.mplsLabel(33));
+ final MplsLabel mplsLabel = MplsLabel.mplsLabel(33);
+ final Instruction instruction = Instructions.modMplsLabel(mplsLabel);
final L2ModificationInstruction.ModMplsLabelInstruction modMplsLabelInstruction =
checkAndConvert(instruction,
Instruction.Type.L2MODIFICATION,
L2ModificationInstruction.ModMplsLabelInstruction.class);
- assertThat(modMplsLabelInstruction.label(), is(equalTo(33)));
+ assertThat(modMplsLabelInstruction.mplsLabel(), is(equalTo(mplsLabel)));
assertThat(modMplsLabelInstruction.subtype(),
is(equalTo(L2ModificationInstruction.L2SubType.MPLS_LABEL)));
}
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java b/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java
index 8a4dfa5..d61cf38 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/EncodeInstructionCodecHelper.java
@@ -113,7 +113,7 @@
case MPLS_LABEL:
final L2ModificationInstruction.ModMplsLabelInstruction modMplsLabelInstruction =
(L2ModificationInstruction.ModMplsLabelInstruction) instruction;
- result.put(InstructionCodec.MPLS_LABEL, modMplsLabelInstruction.label());
+ result.put(InstructionCodec.MPLS_LABEL, modMplsLabelInstruction.mplsLabel().toInt());
break;
case MPLS_PUSH:
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/FlowRuleCodecTest.java b/core/common/src/test/java/org/onosproject/codec/impl/FlowRuleCodecTest.java
index 2ae8cb5..6c88ac1 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/FlowRuleCodecTest.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/FlowRuleCodecTest.java
@@ -246,8 +246,8 @@
L2ModificationInstruction.L2SubType.MPLS_LABEL.name());
assertThat(instruction.type(), is(Instruction.Type.L2MODIFICATION));
assertThat(((L2ModificationInstruction.ModMplsLabelInstruction) instruction)
- .label().shortValue(),
- is((short) 777));
+ .mplsLabel().toInt(),
+ is(MplsLabel.MAX_MPLS));
instruction = getInstruction(Instruction.Type.L2MODIFICATION,
L2ModificationInstruction.L2SubType.MPLS_PUSH.name());
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/InstructionJsonMatcher.java b/core/common/src/test/java/org/onosproject/codec/impl/InstructionJsonMatcher.java
index dbb3bd0..72081e6 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/InstructionJsonMatcher.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/InstructionJsonMatcher.java
@@ -372,7 +372,7 @@
}
final int jsonLabel = instructionJson.get("label").intValue();
- final int label = instructionToMatch.label();
+ final int label = instructionToMatch.mplsLabel().toInt();
if (label != jsonLabel) {
description.appendText("MPLS label was " + jsonLabel);
return false;
diff --git a/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json b/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json
index dbb8f51..74b9546 100644
--- a/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json
+++ b/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json
@@ -13,7 +13,7 @@
{"type":"L2MODIFICATION","subtype":"ETH_DST","mac":"98:76:54:32:01:00"},
{"type":"L2MODIFICATION","subtype":"VLAN_ID","vlanId":22},
{"type":"L2MODIFICATION","subtype":"VLAN_PCP","vlanPcp":1},
- {"type":"L2MODIFICATION","subtype":"MPLS_LABEL","label":777},
+ {"type":"L2MODIFICATION","subtype":"MPLS_LABEL","label":1048575},
{"type":"L2MODIFICATION","subtype":"MPLS_PUSH"},
{"type":"L2MODIFICATION","subtype":"MPLS_POP"},
{"type":"L2MODIFICATION","subtype":"DEC_MPLS_TTL"},
diff --git a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
index 5650dff..8918d33 100644
--- a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
+++ b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer13.java
@@ -342,8 +342,7 @@
case MPLS_LABEL:
ModMplsLabelInstruction mplsLabel =
(ModMplsLabelInstruction) l2m;
- oxm = factory().oxms().mplsLabel(U32.of(mplsLabel.label()
- .longValue()));
+ oxm = factory().oxms().mplsLabel(U32.of(mplsLabel.mplsLabel().toInt()));
break;
case MPLS_BOS:
ModMplsBosInstruction mplsBos = (ModMplsBosInstruction) l2m;
diff --git a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupModBuilder.java b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupModBuilder.java
index 76d7ee0..d5804f4 100644
--- a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupModBuilder.java
+++ b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupModBuilder.java
@@ -284,8 +284,7 @@
case MPLS_LABEL:
L2ModificationInstruction.ModMplsLabelInstruction mplsLabel =
(L2ModificationInstruction.ModMplsLabelInstruction) l2m;
- oxm = factory.oxms().mplsLabel(U32.of(mplsLabel.label()
- .longValue()));
+ oxm = factory.oxms().mplsLabel(U32.of(mplsLabel.mplsLabel().toInt()));
break;
case MPLS_BOS:
L2ModificationInstruction.ModMplsBosInstruction mplsBos =