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

        final ObjectNode result = context.mapper().createObjectNode()
                                    .put(AS_NUMBER, address.getAsNumber());

        if (address.getAddress() != null) {
            final JsonCodec<MappingAddress> addressCodec =
                    context.codec(MappingAddress.class);
            ObjectNode addressNode = addressCodec.encode(address.getAddress(), context);
            result.set(ADDRESS, addressNode);
        }

        return result;
    }
@Test
    public void testLispAsAddressEncode() {
        LispAsAddress address = new LispAsAddress.Builder()
                .withAsNumber(AS_NUMBER)
                .withAddress(MappingAddresses.ipv4MappingAddress(IPV4_PREFIX))
                .build();
        ObjectNode addressJson = asAddressCodec.encode(address, context);
        assertThat("errors in encoding AS address JSON",
                addressJson, LispAsAddressJsonMatcher.matchesAsAddress(address));
    }