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.harmonyhub.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.storage.StorageService;
17 import org.openhab.core.thing.ThingUID;
18 import org.openhab.core.thing.binding.AbstractStorageBasedTypeProvider;
19 import org.openhab.core.thing.type.ChannelType;
20 import org.openhab.core.thing.type.ChannelTypeProvider;
21 import org.osgi.service.component.annotations.Activate;
22 import org.osgi.service.component.annotations.Component;
23 import org.osgi.service.component.annotations.Reference;
26 * The {@link HarmonyHubDynamicTypeProvider} is an instance of a {@link AbstractStorageBasedTypeProvider} for the
30 * @author Jan N. Klug - Initial contribution
32 @Component(service = { HarmonyHubDynamicTypeProvider.class, ChannelTypeProvider.class })
34 public class HarmonyHubDynamicTypeProvider extends AbstractStorageBasedTypeProvider {
37 public HarmonyHubDynamicTypeProvider(@Reference StorageService storageService) {
38 super(storageService);
41 public void removeChannelTypesForThing(ThingUID uid) {
42 String thingUid = uid.getAsString() + ":";
43 getChannelTypes(null).stream().map(ChannelType::getUID).filter(c -> c.getAsString().startsWith(thingUid))
44 .forEach(this::removeChannelType);