@Override
    public ObjectNode encode(Criterion criterion, CodecContext context) {
        EncodeCriterionCodecHelper encoder = new EncodeCriterionCodecHelper(criterion, context);
        return encoder.encode();
    }
@Test
    public void matchPiTypeEncodingTest() {

        PiMatchFieldId ethMatchFieldId = PiMatchFieldId.of("ethernet_t.etherType");
        byte[] matchExactBytes1 = {0x08, 0x00};
        Criterion exactBytesCriterion = PiCriterion.builder().matchExact(ethMatchFieldId, matchExactBytes1).build();
        ObjectNode exactResult = criterionCodec.encode(exactBytesCriterion, context);
        assertThat(exactResult, matchesCriterion(exactBytesCriterion));

        PiMatchFieldId ipv4MatchFieldId = PiMatchFieldId.of("ipv4_t.dstAddr");
        int mask = 0x00ffffff;
        byte[] matchLpmBytes1 = {0x0a, 0x01, 0x01, 0x01};
        Criterion lpmBytesCriterion = PiCriterion.builder().matchLpm(ipv4MatchFieldId, matchLpmBytes1, mask).build();
        ObjectNode lpmResult = criterionCodec.encode(lpmBytesCriterion, context);
        assertThat(lpmResult, matchesCriterion(lpmBytesCriterion));

        byte[] matchTernaryBytes1 = {0x0a, 0x01, 0x01, 0x01};
        byte[] matchTernaryMaskBytes = {0x7f, 0x7f, 0x7f, 0x00};
        Criterion ternaryBytesCriterion = PiCriterion.builder().matchTernary(ipv4MatchFieldId, matchTernaryBytes1,
                                                                    matchTernaryMaskBytes).build();
        ObjectNode ternaryResult = criterionCodec.encode(ternaryBytesCriterion, context);
        assertThat(ternaryResult, matchesCriterion(ternaryBytesCriterion));

        byte[] matchRangeBytes1 = {0x10};
        byte[] matchRangeHighBytes = {0x30};
        Criterion rangeBytesCriterion = PiCriterion.builder()
                .matchRange(ipv4MatchFieldId, matchRangeBytes1, matchRangeHighBytes).build();
        ObjectNode rangeResult = criterionCodec.encode(rangeBytesCriterion, context);
        assertThat(rangeResult, matchesCriterion(rangeBytesCriterion));

        byte[] matchOptionalBytes = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55};
        Criterion optionalBytesCriterion = PiCriterion.builder().matchOptional(ethMatchFieldId,
                                                                               matchOptionalBytes).build();
        ObjectNode optionalResult = criterionCodec.encode(optionalBytesCriterion, context);
        assertThat(optionalResult, matchesCriterion(optionalBytesCriterion));
    }