This repository has been archived by the owner on May 7, 2020. It is now read-only.
/
__bindingIdCamelCase__HandlerFactory.java
64 lines (55 loc) · 2.25 KB
/
__bindingIdCamelCase__HandlerFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#set( $dt = $package.getClass().forName("java.util.Date").newInstance() )
#set( $year = $dt.getYear() + 1900 )
#if( $vendorName == "Eclipse.org/SmartHome" )
#set( $copyright = "Contributors to the Eclipse Foundation" )
#else
#set( $copyright = "by the respective copyright holders." )
#end
/**
* Copyright (c) ${startYear},${year} ${copyright}
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package ${package}.internal;
import static ${package}.${bindingIdCamelCase}BindingConstants.*;
import java.util.Collections;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import ${package}.handler.${bindingIdCamelCase}Handler;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingTypeUID;
import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory;
import org.eclipse.smarthome.core.thing.binding.ThingHandler;
import org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory;
import org.osgi.service.component.annotations.Component;
/**
* The {@link ${bindingIdCamelCase}HandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author ${author} - Initial contribution
*/
@Component(service = ThingHandlerFactory.class, immediate = true, configurationPid = "binding.${bindingId}")
@NonNullByDefault
public class ${bindingIdCamelCase}HandlerFactory extends BaseThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_SAMPLE);
@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
}
@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (THING_TYPE_SAMPLE.equals(thingTypeUID)) {
return new ${bindingIdCamelCase}Handler(thing);
}
return null;
}
}