]> git.basschouten.com Git - openhab-addons.git/blob
01940133d966cbada8381f0d1951829260158703
[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.ihc.internal.profiles;
14
15 import java.util.Collection;
16 import java.util.Locale;
17 import java.util.Set;
18 import java.util.stream.Collectors;
19 import java.util.stream.Stream;
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 for IHC / ELKO profiles.
34  *
35  * @author Pauli Anttila - initial contribution.
36  *
37  */
38 @NonNullByDefault
39 @Component(service = { ProfileFactory.class, ProfileTypeProvider.class })
40 public class IhcProfileFactory implements ProfileFactory, ProfileTypeProvider {
41
42     private static final Set<ProfileType> SUPPORTED_PROFILE_TYPES = Stream.of(IhcProfiles.PUSHBUTTON_COMMAND_TYPE)
43             .collect(Collectors.toSet());
44
45     private static final Set<ProfileTypeUID> SUPPORTED_PROFILE_TYPE_UIDS = Stream.of(IhcProfiles.PUSHBUTTON_COMMAND)
46             .collect(Collectors.toSet());
47
48     @Nullable
49     @Override
50     public Profile createProfile(ProfileTypeUID profileTypeUID, ProfileCallback callback, ProfileContext context) {
51         if (IhcProfiles.PUSHBUTTON_COMMAND.equals(profileTypeUID)) {
52             return new PushButtonToCommandProfile(callback, context);
53         } else {
54             return null;
55         }
56     }
57
58     @Override
59     public Collection<ProfileType> getProfileTypes(@Nullable Locale locale) {
60         return SUPPORTED_PROFILE_TYPES;
61     }
62
63     @Override
64     public Collection<ProfileTypeUID> getSupportedProfileTypeUIDs() {
65         return SUPPORTED_PROFILE_TYPE_UIDS;
66     }
67 }