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.jsonpath.internal.profiles;
15 import java.util.Arrays;
16 import java.util.Collection;
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.osgi.service.component.annotations.Component;
31 import org.osgi.service.component.annotations.Reference;
34 * Profilefactory that creates the transformation profile for the jsonpath transformation service
36 * @author Stefan Triller - initial contribution
40 @Component(service = { ProfileFactory.class, ProfileTypeProvider.class })
41 public class JSonPathTransformationProfileFactory implements ProfileFactory, ProfileTypeProvider {
44 private TransformationService service;
47 public Collection<ProfileType> getProfileTypes(@Nullable Locale locale) {
48 return Arrays.asList(ProfileTypeBuilder.newState(JSonPathTransformationProfile.PROFILE_TYPE_UID,
49 JSonPathTransformationProfile.PROFILE_TYPE_UID.getId()).build());
53 public @Nullable Profile createProfile(ProfileTypeUID profileTypeUID, ProfileCallback callback,
54 ProfileContext profileContext) {
55 return new JSonPathTransformationProfile(callback, profileContext, service);
59 public Collection<ProfileTypeUID> getSupportedProfileTypeUIDs() {
60 return Arrays.asList(JSonPathTransformationProfile.PROFILE_TYPE_UID);
63 @Reference(target = "(openhab.transform=JSONPATH)")
64 public void addTransformationService(TransformationService service) {
65 this.service = service;
68 public void removeTransformationService(TransformationService service) {