]> git.basschouten.com Git - openhab-addons.git/blob
807933a5b6e2839e804f4a2bb42a5faa765bbd92
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.freeathomesystem.internal.type;
14
15 import java.util.Collection;
16 import java.util.HashMap;
17 import java.util.Locale;
18 import java.util.Map;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.openhab.core.thing.ThingTypeUID;
23 import org.openhab.core.thing.binding.ThingTypeProvider;
24 import org.openhab.core.thing.type.ThingType;
25 import org.osgi.service.component.annotations.Component;
26
27 /**
28  *
29  * @author Andras Uhrin - Initial contribution
30  *
31  */
32
33 @Component(service = { FreeAtHomeThingTypeProvider.class, ThingTypeProvider.class })
34 @NonNullByDefault
35 public class FreeAtHomeThingTypeProviderImpl implements FreeAtHomeThingTypeProvider {
36     private final Map<ThingTypeUID, ThingType> thingTypesByUID = new HashMap<>();
37
38     @Override
39     public Collection<ThingType> getThingTypes(@Nullable Locale locale) {
40         Map<ThingTypeUID, ThingType> copy = new HashMap<>(thingTypesByUID);
41         return copy.values();
42     }
43
44     @Override
45     public @Nullable ThingType getThingType(ThingTypeUID thingTypeUID, @Nullable Locale locale) {
46         return thingTypesByUID.get(thingTypeUID);
47     }
48
49     @Override
50     public void addThingType(@Nullable ThingType thingType) {
51         if (thingType != null) {
52             thingTypesByUID.put(thingType.getUID(), thingType);
53         }
54     }
55 }