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

        final JsonCodec<MappingAddress> addressCodec =
                context.codec(MappingAddress.class);

        final ObjectNode result = context.mapper().createObjectNode()
                .put(SRC_MASK_LENGTH, address.getSrcMaskLength())
                .put(DST_MASK_LENGTH, address.getDstMaskLength());

        if (address.getSrcPrefix() != null) {
            ObjectNode srcPrefix = addressCodec.encode(address.getSrcPrefix(), context);
            result.set(SRC_PREFIX, srcPrefix);
        }

        if (address.getDstPrefix() != null) {
            ObjectNode dstPrefix = addressCodec.encode(address.getDstPrefix(), context);
            result.set(DST_PREFIX, dstPrefix);
        }

        return result;
    }
@Test
    public void testLispSrcDstAddressEncode() {
        LispSrcDstAddress address = new LispSrcDstAddress.Builder()
                .withSrcMaskLength(SRC_MASK_LENGTH)
                .withDstMaskLength(DST_MASK_LENGTH)
                .withSrcPrefix(MappingAddresses.ipv4MappingAddress(IPV4_SRC_PREFIX))
                .withDstPrefix(MappingAddresses.ipv4MappingAddress(IPV4_DST_PREFIX))
                .build();
        ObjectNode addressJson = srcDstAddressCodec.encode(address, context);
        assertThat("errors in encoding Source and Destination address JSON",
                addressJson, LispSrcDstAddressJsonMatcher.matchesSrcDstAddress(address));
    }