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.modbus.internal.profiles;
15 import static org.openhab.binding.modbus.internal.profiles.ModbusProfiles.*;
17 import java.util.Collection;
18 import java.util.Locale;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.openhab.core.thing.profiles.Profile;
24 import org.openhab.core.thing.profiles.ProfileCallback;
25 import org.openhab.core.thing.profiles.ProfileContext;
26 import org.openhab.core.thing.profiles.ProfileFactory;
27 import org.openhab.core.thing.profiles.ProfileType;
28 import org.openhab.core.thing.profiles.ProfileTypeProvider;
29 import org.openhab.core.thing.profiles.ProfileTypeUID;
30 import org.osgi.service.component.annotations.Component;
33 * A factory and advisor for modbus profiles.
36 * @author Sami Salonen - Initial contribution
39 @Component(service = { ProfileFactory.class, ProfileTypeProvider.class })
40 public class ModbusProfileFactory implements ProfileFactory, ProfileTypeProvider {
42 private static final Set<ProfileType> SUPPORTED_PROFILE_TYPES = Set.of(GAIN_OFFSET_TYPE);
44 private static final Set<ProfileTypeUID> SUPPORTED_PROFILE_TYPE_UIDS = Set.of(GAIN_OFFSET);
47 public @Nullable Profile createProfile(ProfileTypeUID profileTypeUID, ProfileCallback callback,
48 ProfileContext context) {
49 if (GAIN_OFFSET.equals(profileTypeUID)) {
50 return new ModbusGainOffsetProfile<>(callback, context);
57 public Collection<ProfileType> getProfileTypes(@Nullable Locale locale) {
58 return SUPPORTED_PROFILE_TYPES;
62 public Collection<ProfileTypeUID> getSupportedProfileTypeUIDs() {
63 return SUPPORTED_PROFILE_TYPE_UIDS;