Yuta HIGUCHI

L2/L3 modification instruction bug fixes

- Fixed instanceOf with wrong type (ONOS-974)
- Aligned #toString() format to be the same as other instructions

Change-Id: I526c2ef8d92660e0b821a10f0cf87ee72a84cdf3
......@@ -304,13 +304,13 @@ public abstract class L2ModificationInstruction implements Instruction {
@Override
public String toString() {
return toStringHelper(type().toString())
return toStringHelper(subtype().toString())
.add("mpls", mplsLabel.intValue()).toString();
}
@Override
public int hashCode() {
return Objects.hash(mplsLabel);
return Objects.hash(type(), subtype(), mplsLabel);
}
@Override
......@@ -330,7 +330,7 @@ public abstract class L2ModificationInstruction implements Instruction {
}
/**
* Represents a MPLS label modification.
* Represents a MPLS TTL modification.
*/
public static final class ModMplsTtlInstruction extends
L2ModificationInstruction {
......@@ -345,12 +345,13 @@ public abstract class L2ModificationInstruction implements Instruction {
@Override
public String toString() {
return type().toString();
return toStringHelper(subtype().toString())
.toString();
}
@Override
public int hashCode() {
return Objects.hash(type(), L2SubType.DEC_MPLS_TTL);
return Objects.hash(type(), subtype());
}
@Override
......@@ -358,9 +359,8 @@ public abstract class L2ModificationInstruction implements Instruction {
if (this == obj) {
return true;
}
if (obj instanceof ModMplsLabelInstruction) {
ModMplsTtlInstruction that = (ModMplsTtlInstruction) obj;
return Objects.equals(this.type(), that.type());
if (obj instanceof ModMplsTtlInstruction) {
return true;
}
return false;
}
......
......@@ -119,6 +119,9 @@ public abstract class L3ModificationInstruction implements Instruction {
}
}
/**
* Represents a L3 TTL modification instruction.
*/
public static final class ModTtlInstruction extends L3ModificationInstruction {
private final L3SubType subtype;
......@@ -134,7 +137,8 @@ public abstract class L3ModificationInstruction implements Instruction {
@Override
public String toString() {
return subtype().toString();
return toStringHelper(subtype().toString())
.toString();
}
@Override
......@@ -147,10 +151,10 @@ public abstract class L3ModificationInstruction implements Instruction {
if (this == obj) {
return true;
}
if (obj instanceof ModIPInstruction) {
ModIPInstruction that = (ModIPInstruction) obj;
return Objects.equals(this.type(), that.type()) &&
Objects.equals(this.subtype(), that.subtype());
if (obj instanceof ModTtlInstruction) {
ModTtlInstruction that = (ModTtlInstruction) obj;
return Objects.equals(this.subtype(), that.subtype()) &&
Objects.equals(this.type(), that.type());
}
return false;
......