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.transform.map.internal.profiles;
15 import java.util.Collection;
16 import java.util.List;
17 import java.util.Locale;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.core.thing.profiles.Profile;
22 import org.openhab.core.thing.profiles.ProfileCallback;
23 import org.openhab.core.thing.profiles.ProfileContext;
24 import org.openhab.core.thing.profiles.ProfileFactory;
25 import org.openhab.core.thing.profiles.ProfileType;
26 import org.openhab.core.thing.profiles.ProfileTypeBuilder;
27 import org.openhab.core.thing.profiles.ProfileTypeProvider;
28 import org.openhab.core.thing.profiles.ProfileTypeUID;
29 import org.openhab.core.transform.TransformationService;
30 import org.openhab.transform.map.internal.MapTransformationService;
31 import org.osgi.service.component.annotations.Component;
32 import org.osgi.service.component.annotations.Reference;
35 * {@link ProfileFactory} that creates the transformation profile for the {@link MapTransformationService}.
37 * @author Stefan Triller - Initial contribution
40 @Component(service = { ProfileFactory.class, ProfileTypeProvider.class })
41 public class MapTransformationProfileFactory implements ProfileFactory, ProfileTypeProvider {
44 private TransformationService service;
47 public Collection<ProfileType> getProfileTypes(@Nullable Locale locale) {
48 return List.of(ProfileTypeBuilder
49 .newState(MapTransformationProfile.PROFILE_TYPE_UID, MapTransformationProfile.PROFILE_TYPE_UID.getId())
54 public @Nullable Profile createProfile(ProfileTypeUID profileTypeUID, ProfileCallback callback,
55 ProfileContext profileContext) {
56 return new MapTransformationProfile(callback, profileContext, service);
60 public Collection<ProfileTypeUID> getSupportedProfileTypeUIDs() {
61 return List.of(MapTransformationProfile.PROFILE_TYPE_UID);
64 @Reference(target = "(openhab.transform=MAP)")
65 public void addTransformationService(TransformationService service) {
66 this.service = service;
69 public void removeTransformationService(TransformationService service) {