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.ihc.internal.profiles;
15 import java.util.Collection;
16 import java.util.Locale;
18 import java.util.stream.Collectors;
19 import java.util.stream.Stream;
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 for IHC / ELKO profiles.
35 * @author Pauli Anttila - initial contribution.
39 @Component(service = { ProfileFactory.class, ProfileTypeProvider.class })
40 public class IhcProfileFactory implements ProfileFactory, ProfileTypeProvider {
42 private static final Set<ProfileType> SUPPORTED_PROFILE_TYPES = Stream.of(IhcProfiles.PUSHBUTTON_COMMAND_TYPE)
43 .collect(Collectors.toSet());
45 private static final Set<ProfileTypeUID> SUPPORTED_PROFILE_TYPE_UIDS = Stream.of(IhcProfiles.PUSHBUTTON_COMMAND)
46 .collect(Collectors.toSet());
50 public Profile createProfile(ProfileTypeUID profileTypeUID, ProfileCallback callback, ProfileContext context) {
51 if (IhcProfiles.PUSHBUTTON_COMMAND.equals(profileTypeUID)) {
52 return new PushButtonToCommandProfile(callback, context);
59 public Collection<ProfileType> getProfileTypes(@Nullable Locale locale) {
60 return SUPPORTED_PROFILE_TYPES;
64 public Collection<ProfileTypeUID> getSupportedProfileTypeUIDs() {
65 return SUPPORTED_PROFILE_TYPE_UIDS;