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

        final ObjectNode result = context.mapper().createObjectNode()
                .put(PROTOCOL, address.getProtocol())
                .put(IP_TOS, address.getIpTos())
                .put(LOCAL_PORT_LOW, address.getLocalPortLow())
                .put(LOCAL_PORT_HIGH, address.getLocalPortHigh())
                .put(REMOTE_PORT_LOW, address.getRemotePortLow())
                .put(REMOTE_PORT_HIGH, address.getRemotePortHigh());

        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 testLispAppDataAddressEncode() {

        LispAppDataAddress address = new LispAppDataAddress.Builder()
                .withProtocol(PROTOCOL)
                .withIpTos(IP_TOS)
                .withLocalPortLow(LOCAL_PORT_LOW)
                .withLocalPortHigh(LOCAL_PORT_HIGH)
                .withRemotePortLow(REMOTE_PORT_LOW)
                .withRemotePortHigh(REMOTE_PORT_HIGH)
                .withAddress(MappingAddresses.ipv4MappingAddress(IPV4_PREFIX))
                .build();
        ObjectNode addressJson = appDataAddressCodec.encode(address, context);
        assertThat(addressJson, LispAppDataAddressJsonMatcher.matchesAppDataAddress(address));
    }