]> git.basschouten.com Git - openhab-addons.git/blob
62a7202831a645996e2217a74280b8dc32b8b5e8
[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.modbus.internal.profiles;
14
15 import static org.openhab.binding.modbus.internal.profiles.ModbusProfiles.*;
16
17 import java.util.Collection;
18 import java.util.Locale;
19 import java.util.Set;
20
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;
31
32 /**
33  * A factory and advisor for modbus profiles.
34  *
35  *
36  * @author Sami Salonen - Initial contribution
37  */
38 @NonNullByDefault
39 @Component(service = { ProfileFactory.class, ProfileTypeProvider.class })
40 public class ModbusProfileFactory implements ProfileFactory, ProfileTypeProvider {
41
42     private static final Set<ProfileType> SUPPORTED_PROFILE_TYPES = Set.of(GAIN_OFFSET_TYPE);
43
44     private static final Set<ProfileTypeUID> SUPPORTED_PROFILE_TYPE_UIDS = Set.of(GAIN_OFFSET);
45
46     @Override
47     public @Nullable Profile createProfile(ProfileTypeUID profileTypeUID, ProfileCallback callback,
48             ProfileContext context) {
49         if (GAIN_OFFSET.equals(profileTypeUID)) {
50             return new ModbusGainOffsetProfile<>(callback, context);
51         } else {
52             return null;
53         }
54     }
55
56     @Override
57     public Collection<ProfileType> getProfileTypes(@Nullable Locale locale) {
58         return SUPPORTED_PROFILE_TYPES;
59     }
60
61     @Override
62     public Collection<ProfileTypeUID> getSupportedProfileTypeUIDs() {
63         return SUPPORTED_PROFILE_TYPE_UIDS;
64     }
65 }