@Override
    public MepLbCreate decode(ObjectNode json, CodecContext context) {
        if (json == null || !json.isObject()) {
            return null;
        }

        JsonNode loopbackNode = json.get(LOOPBACK);

        JsonNode remoteMepIdNode = loopbackNode.get(REMOTE_MEP_ID);
        JsonNode remoteMepMacNode = loopbackNode.get(REMOTE_MEP_MAC);

        MepLbCreate.MepLbCreateBuilder lbCreateBuilder;
        if (remoteMepIdNode != null) {
            MepId remoteMepId = MepId.valueOf((short) remoteMepIdNode.asInt());
            lbCreateBuilder = DefaultMepLbCreate.builder(remoteMepId);
        } else if (remoteMepMacNode != null) {
            MacAddress remoteMepMac = MacAddress.valueOf(
                                            remoteMepMacNode.asText());
            lbCreateBuilder = DefaultMepLbCreate.builder(remoteMepMac);
        } else {
            throw new IllegalArgumentException(
                    "Either a remoteMepId or a remoteMepMac");
        }

        JsonNode numMessagesNode = loopbackNode.get(NUMBER_MESSAGES);
        if (numMessagesNode != null) {
            int numMessages = numMessagesNode.asInt();
            lbCreateBuilder.numberMessages(numMessages);
        }

        JsonNode vlanDropEligibleNode = loopbackNode.get(VLAN_DROP_ELIGIBLE);
        if (vlanDropEligibleNode != null) {
            boolean vlanDropEligible = vlanDropEligibleNode.asBoolean();
            lbCreateBuilder.vlanDropEligible(vlanDropEligible);
        }

        JsonNode vlanPriorityNode = loopbackNode.get(VLAN_PRIORITY);
        if (vlanPriorityNode != null) {
            short vlanPriority = (short) vlanPriorityNode.asInt();
            lbCreateBuilder.vlanPriority(Priority.values()[vlanPriority]);
        }

        JsonNode dataTlvHexNode = loopbackNode.get(DATA_TLV_HEX);
        if (dataTlvHexNode != null) {
            String dataTlvHex = loopbackNode.get(DATA_TLV_HEX).asText();
            if (!dataTlvHex.isEmpty()) {
                lbCreateBuilder.dataTlv(HexString.fromHexString(dataTlvHex));
            }
        }

        return lbCreateBuilder.build();
    }
@Test
    public void testDecodeMepLbCreateMepMac() throws JsonProcessingException, IOException {
        String loopbackString = "{\"loopback\": {    " +
                "\"remoteMepMac\": \"AA:BB:CC:DD:EE:FF\" }}";
        InputStream input = new ByteArrayInputStream(
                loopbackString.getBytes(StandardCharsets.UTF_8));
        JsonNode cfg = mapper.readTree(input);
        MepLbCreate mepLbCreate = context
                .codec(MepLbCreate.class).decode((ObjectNode) cfg, context);

        assertNull(mepLbCreate.remoteMepId());
        assertEquals("AA:BB:CC:DD:EE:FF", mepLbCreate.remoteMepAddress().toString());
        assertNull(mepLbCreate.dataTlvHex());
    }