]> git.basschouten.com Git - openhab-addons.git/blob
ea1f4563962ebf481e7de744be492b16d90a50aa
[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.boschshc.internal.services;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.boschshc.internal.devices.bridge.BridgeHandler;
18
19 /**
20  * Base class for Bosch Smart Home services containing what all services have in common.
21  * <p>
22  * The services of the devices and their official APIs can be found
23  * <a href="https://apidocs.bosch-smarthome.com/local/">here</a>.
24  * 
25  * @author Christian Oeing - Initial contribution
26  * @author David Pace - Service abstraction
27  */
28 @NonNullByDefault
29 public abstract class AbstractBoschSHCService {
30
31     /**
32      * Unique service name
33      */
34     private final String serviceName;
35
36     /**
37      * Bridge to use for communication from/to the device
38      */
39     private @Nullable BridgeHandler bridgeHandler;
40
41     /**
42      * Id of device the service belongs to
43      */
44     private @Nullable String deviceId;
45
46     protected AbstractBoschSHCService(String serviceName) {
47         this.serviceName = serviceName;
48     }
49
50     /**
51      * Initializes the service
52      * 
53      * @param bridgeHandler Bridge to use for communication from/to the device
54      * @param deviceId Id of device this service is for
55      */
56     public void initialize(BridgeHandler bridgeHandler, String deviceId) {
57         this.bridgeHandler = bridgeHandler;
58         this.deviceId = deviceId;
59     }
60
61     public String getServiceName() {
62         return serviceName;
63     }
64
65     protected @Nullable BridgeHandler getBridgeHandler() {
66         return bridgeHandler;
67     }
68
69     protected @Nullable String getDeviceId() {
70         return deviceId;
71     }
72 }