]> git.basschouten.com Git - openhab-addons.git/blob
b7c65186092442fd35678ee4e956a939e1eafc01
[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.homematic.internal.communicator.parser;
14
15 import java.io.IOException;
16 import java.util.ArrayList;
17 import java.util.List;
18
19 import org.openhab.binding.homematic.internal.misc.MiscUtils;
20
21 /**
22  * Parses a delete device event received from a Homematic gateway.
23  *
24  * @author Gerhard Riegler - Initial contribution
25  */
26 public class DeleteDevicesParser extends CommonRpcParser<Object[], List<String>> {
27     @Override
28     public List<String> parse(Object[] message) throws IOException {
29         List<String> adresses = new ArrayList<>();
30         if (message != null && message.length > 1) {
31             Object[] data = (Object[]) message[1];
32             for (int i = 0; i < message.length; i++) {
33                 String address = getSanitizedAddress(data[i]);
34                 if (MiscUtils.isDevice(address)) {
35                     adresses.add(address);
36                 }
37             }
38         }
39         return adresses;
40     }
41 }