]> git.basschouten.com Git - openhab-addons.git/blob
d59a8ab06573986d97d16fa76f8e628929190dad
[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.knx.internal.client;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 import tuwien.auto.calimero.datapoint.Datapoint;
19
20 /**
21  * Information about a data point which is queued to be read from the KNX bus.
22  *
23  * @author Karel Goderis - Initial contribution
24  */
25 @NonNullByDefault
26 public class ReadDatapoint {
27
28     private final Datapoint datapoint;
29     private int retries;
30     private final int limit;
31
32     public ReadDatapoint(Datapoint datapoint, int limit) {
33         this.datapoint = datapoint;
34         this.retries = 0;
35         this.limit = limit;
36     }
37
38     public Datapoint getDatapoint() {
39         return datapoint;
40     }
41
42     public int getRetries() {
43         return retries;
44     }
45
46     public void incrementRetries() {
47         this.retries++;
48     }
49
50     public int getLimit() {
51         return limit;
52     }
53
54     @Override
55     public int hashCode() {
56         final int prime = 31;
57         int result = 1;
58         result = prime * result + ((datapoint.getMainAddress() == null) ? 0 : datapoint.getMainAddress().hashCode());
59         return result;
60     }
61
62     @Override
63     public boolean equals(@Nullable Object obj) {
64         if (this == obj) {
65             return true;
66         }
67         if (obj == null) {
68             return false;
69         }
70         if (getClass() != obj.getClass()) {
71             return false;
72         }
73         @Nullable
74         ReadDatapoint other = (ReadDatapoint) obj;
75         return datapoint.getMainAddress().equals(other.datapoint.getMainAddress());
76     }
77 }