@Override
    public ObjectNode encode(MappingKey key, CodecContext context) {
        checkNotNull(key, "Mapping key cannot be null");

        final ObjectNode result = context.mapper().createObjectNode();
        final JsonCodec<MappingAddress> addressCodec =
                context.codec(MappingAddress.class);

        result.set(ADDRESS, addressCodec.encode(key.address(), context));

        return result;
    }
@Test
    public void testMappingKeyEncode() {

        MappingAddress address = MappingAddresses.ipv4MappingAddress(IPV4_PREFIX);

        MappingKey key = DefaultMappingKey.builder()
                                .withAddress(address)
                                .build();

        ObjectNode keyJson = keyCodec.encode(key, context);
        assertThat(keyJson, MappingKeyJsonMatcher.matchesMappingKey(key));
    }