]> git.basschouten.com Git - openhab-addons.git/blob
ebae8c1c5e13feadf95f71d1ec73d9906f2eac8d
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.model;
14
15 import org.apache.commons.lang.builder.ToStringBuilder;
16 import org.apache.commons.lang.builder.ToStringStyle;
17
18 /**
19  * Object that holds the rssi infos for a RF device.
20  *
21  * @author Gerhard Riegler - Initial contribution
22  */
23
24 public class HmRssiInfo {
25     private String address;
26     private Integer device;
27     private Integer peer;
28
29     public HmRssiInfo(String address, Integer device, Integer peer) {
30         this.address = address;
31         this.device = convert(device);
32         this.peer = convert(peer);
33     }
34
35     /**
36      * Converts the rssi value to null if necessary.
37      */
38     private Integer convert(Integer intValue) {
39         if (intValue == null || intValue == 65536) {
40             return 0;
41         }
42         return intValue;
43     }
44
45     /**
46      * Returns the address of the device.
47      */
48     public String getAddress() {
49         return address;
50     }
51
52     /**
53      * Returns the device rssi.
54      */
55     public Integer getDevice() {
56         return device;
57     }
58
59     /**
60      * Returns the peer rssi.
61      */
62     public Integer getPeer() {
63         return peer;
64     }
65
66     @Override
67     public String toString() {
68         return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("address", address)
69                 .append("device", device).append("peer", peer).toString();
70     }
71 }