public static Deserializer<Lacp> deserializer() {
        return (data, offset, length) -> {
            checkInput(data, offset, length, HEADER_LENGTH);

            Lacp lacp = new Lacp();
            ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
            lacp.setLacpVersion(bb.get());

            while (bb.limit() - bb.position() > 0) {
                byte nextType = bb.get();
                int nextLength = Byte.toUnsignedInt(bb.get());
                int parseLength = nextLength == 0 ?
                        LacpTerminatorTlv.PADDING_LENGTH : // Special case for LacpTerminatorTlv
                        nextLength - 2;

                Deserializer<? extends LacpTlv> deserializer;
                if (Lacp.PROTOCOL_DESERIALIZER_MAP.containsKey(nextType)) {
                    deserializer = Lacp.PROTOCOL_DESERIALIZER_MAP.get(nextType);
                } else {
                    throw new DeserializationException("Unsupported LACP subtype " + Byte.toString(nextType));
                }

                LacpTlv tlv = deserializer.deserialize(data, bb.position(), parseLength);
                LacpTlv previousTlv = lacp.tlv.put(nextType, tlv);
                if (previousTlv != null) {
                    throw new DeserializationException("Duplicated type " + Byte.toString(nextType)
                            + "in LACP TLV");
                }

                bb.position(bb.position() + parseLength);
            }

            return lacp;
        };
    }
@Test
    public void deserializer() throws Exception {
        Lacp lacp = Lacp.deserializer().deserialize(data, 0, data.length);
        assertEquals(LACP_VERSION, lacp.getLacpVersion());
        assertEquals(LACP_TLV, lacp.getTlv());
    }