2 * Copyright (c) 2010-2023 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, null),
31 ELV(ELVGatewayQueryService::new, Measurand.ParserCustomizationType.ELV);
33 private final GatewayQueryServiceFactory queryServiceFactory;
34 private final Measurand.@Nullable ParserCustomizationType parserCustomizationType;
36 Protocol(GatewayQueryServiceFactory queryServiceFactory,
37 Measurand.@Nullable ParserCustomizationType parserCustomizationType) {
38 this.queryServiceFactory = queryServiceFactory;
39 this.parserCustomizationType = parserCustomizationType;
42 public Measurand.@Nullable ParserCustomizationType getParserCustomizationType() {
43 return parserCustomizationType;
46 public GatewayQueryService getGatewayQueryService(FineOffsetGatewayConfiguration config,
47 @Nullable ThingStatusListener thingStatusListener, ConversionContext conversionContext) {
48 return queryServiceFactory.newInstance(config, thingStatusListener, conversionContext);
51 private interface GatewayQueryServiceFactory {
52 GatewayQueryService newInstance(FineOffsetGatewayConfiguration config,
53 @Nullable ThingStatusListener thingStatusListener, ConversionContext conversionContext);