private static MatchEntryBuilder prepareHeader(boolean hasMask) {
   MatchEntryBuilder builder = new MatchEntryBuilder();
   builder.setOxmClass(OpenflowBasicClass.class);
   builder.setOxmMatchField(SctpDst.class);
   builder.setHasMask(hasMask);
   return builder;
 }
 private static MatchEntryBuilder prepareMatchEntry(int value) {
   MatchEntryBuilder builder = prepareHeader(false);
   SctpDstCaseBuilder casebuilder = new SctpDstCaseBuilder();
   SctpDstBuilder valueBuilder = new SctpDstBuilder();
   valueBuilder.setPort(new PortNumber(value));
   casebuilder.setSctpDst(valueBuilder.build());
   builder.setMatchEntryValue(casebuilder.build());
   return builder;
 }
  /** Test correct header serialization */
  @Test
  public void testSerializeHeader() {
    MatchEntryBuilder builder = prepareHeader(false);

    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serializeHeader(builder.build(), buffer);

    checkHeader(buffer, false);
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
  }
  /** Test correct serialization */
  @Test
  public void testSerialize() {
    MatchEntryBuilder builder = prepareMatchEntry(4096);

    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serialize(builder.build(), buffer);

    checkHeader(buffer, false);
    assertEquals("Wrong value", 4096, buffer.readUnsignedShort());
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
  }
 private static void addIcmpv6TypeValue(ByteBuf input, MatchEntryBuilder builder) {
   Icmpv6TypeCaseBuilder caseBuilder = new Icmpv6TypeCaseBuilder();
   Icmpv6TypeBuilder icmpBuilder = new Icmpv6TypeBuilder();
   icmpBuilder.setIcmpv6Type(input.readUnsignedByte());
   caseBuilder.setIcmpv6Type(icmpBuilder.build());
   builder.setMatchEntryValue(caseBuilder.build());
 }
 @Override
 public MatchEntry deserialize(ByteBuf input) {
   MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input);
   addIcmpv6TypeValue(input, builder);
   return builder.build();
 }