2 * Copyright (c) 2010-2022 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.fineoffsetweatherstation.internal.domain;
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;
24 * The protocol defining the way the data is parsed
26 * @author Andreas Berger - Initial contribution
29 public enum Protocol {
30 DEFAULT(FineOffsetGatewayQueryService::new),
31 ELV(ELVGatewayQueryService::new);
33 private final GatewayQueryServiceFactory queryServiceFactory;
35 Protocol(GatewayQueryServiceFactory queryServiceFactory) {
36 this.queryServiceFactory = queryServiceFactory;
39 public GatewayQueryService getGatewayQueryService(FineOffsetGatewayConfiguration config,
40 @Nullable ThingStatusListener thingStatusListener, ConversionContext conversionContext) {
41 return queryServiceFactory.newInstance(config, thingStatusListener, conversionContext);
44 private interface GatewayQueryServiceFactory {
45 GatewayQueryService newInstance(FineOffsetGatewayConfiguration config,
46 @Nullable ThingStatusListener thingStatusListener, ConversionContext conversionContext);