@Override
    public ObjectNode encode(LinkInfo info, CodecContext context) {
        checkNotNull(info, "LinkInfo cannot be null");

        ObjectNode result = context.mapper().createObjectNode()
                .put(LINK_ID, info.linkId())
                .put(SRC_IP, info.srcIp())
                .put(DST_IP, info.dstIp())
                .put(SRC_PORT, info.srcPort())
                .put(DST_PORT, info.dstPort())
                .put(PROTOCOL, info.protocol());

        ObjectNode statsInfoJson =
                context.codec(LinkStatsInfo.class).encode(info.linkStats(), context);

        result.set(STATS_INFO, statsInfoJson);
        return result;
    }
@Test
    public void testLinkInfoEncode() {
        LinkInfo linkInfo = DefaultLinkInfo.builder()
                .withLinkId(LINK_ID)
                .withSrcIp(SRC_IP)
                .withDstIp(DST_IP)
                .withSrcPort(SRC_PORT)
                .withDstPort(DST_PORT)
                .withProtocol(PROTOCOL)
                .withLinkStats(LINK_STATS)
                .build();

        ObjectNode nodeJson = linkInfoCodec.encode(linkInfo, context);
        assertThat(nodeJson, matchesLinkInfo(linkInfo));
    }