]> git.basschouten.com Git - openhab-addons.git/blob
1ae88280dc7b6ca9d6ac600f58f5141807354a89
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.lifx.internal.dto;
14
15 import java.nio.ByteBuffer;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 /**
20  * A packet handler responsible for converting a ByteBuffer into a Packet
21  * instance.
22  *
23  * @param <T> the generic packet type
24  *
25  * @author Tim Buckley - Initial contribution
26  * @author Karel Goderis - Enhancement for the V2 LIFX Firmware and LAN Protocol Specification
27  */
28 @NonNullByDefault
29 public interface PacketHandler<T extends Packet> {
30
31     /**
32      * Creates a packet from the given buffer.
33      *
34      * @param buf the buffer used for creating the packet
35      * @return the packet created from the buffer
36      * @throws IllegalArgumentException when an empty packet could not be created or the data in the buffer
37      *             could not be parsed
38      */
39     T handle(ByteBuffer buf);
40 }