HIGUCHI Yuta
Committed by Ray Milkey

Deprecate ModMplsLabelInstruction#label()

Change-Id: I1324747adaa8ccb28077aa14b208df1083f39a3f
......@@ -342,7 +342,13 @@ public abstract class L2ModificationInstruction implements Instruction {
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();
}
......
......@@ -577,12 +577,13 @@ public class InstructionsTest {
*/
@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)));
}
......
......@@ -113,7 +113,7 @@ public final class EncodeInstructionCodecHelper {
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:
......
......@@ -246,8 +246,8 @@ public class FlowRuleCodecTest {
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());
......
......@@ -372,7 +372,7 @@ public final class InstructionJsonMatcher extends TypeSafeDiagnosingMatcher<Json
}
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;
......
......@@ -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"},
......
......@@ -342,8 +342,7 @@ public class FlowModBuilderVer13 extends FlowModBuilder {
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;
......
......@@ -284,8 +284,7 @@ public final class GroupModBuilder {
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 =
......