]> git.basschouten.com Git - openhab-addons.git/blob
0ca9da2b63a3b01e02e5a804f2c2debbd4aa9659
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.fineoffsetweatherstation.internal.domain;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.fineoffsetweatherstation.internal.FineOffsetGatewayConfiguration;
18 import org.openhab.binding.fineoffsetweatherstation.internal.handler.ThingStatusListener;
19 import org.openhab.binding.fineoffsetweatherstation.internal.service.ELVGatewayQueryService;
20 import org.openhab.binding.fineoffsetweatherstation.internal.service.FineOffsetGatewayQueryService;
21 import org.openhab.binding.fineoffsetweatherstation.internal.service.GatewayQueryService;
22
23 /**
24  * The protocol defining the way the data is parsed
25  *
26  * @author Andreas Berger - Initial contribution
27  */
28 @NonNullByDefault
29 public enum Protocol {
30     DEFAULT(FineOffsetGatewayQueryService::new),
31     ELV(ELVGatewayQueryService::new);
32
33     private final GatewayQueryServiceFactory queryServiceFactory;
34
35     Protocol(GatewayQueryServiceFactory queryServiceFactory) {
36         this.queryServiceFactory = queryServiceFactory;
37     }
38
39     public GatewayQueryService getGatewayQueryService(FineOffsetGatewayConfiguration config,
40             @Nullable ThingStatusListener thingStatusListener, ConversionContext conversionContext) {
41         return queryServiceFactory.newInstance(config, thingStatusListener, conversionContext);
42     }
43
44     private interface GatewayQueryServiceFactory {
45         GatewayQueryService newInstance(FineOffsetGatewayConfiguration config,
46                 @Nullable ThingStatusListener thingStatusListener, ConversionContext conversionContext);
47     }
48 }