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.io.hueemulation.internal.automation;
15 import java.util.Arrays;
16 import java.util.Collection;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.core.automation.Module;
21 import org.openhab.core.automation.Trigger;
22 import org.openhab.core.automation.handler.BaseModuleHandlerFactory;
23 import org.openhab.core.automation.handler.ModuleHandler;
24 import org.openhab.core.automation.handler.ModuleHandlerFactory;
25 import org.openhab.core.scheduler.Scheduler;
26 import org.osgi.service.component.annotations.Component;
27 import org.osgi.service.component.annotations.Deactivate;
28 import org.osgi.service.component.annotations.Reference;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
33 * This factory is responsible for timer related module types.
35 * @author David Graeff - Initial contribution
38 @Component(service = ModuleHandlerFactory.class)
39 public class TimerModuleExHandlerFactory extends BaseModuleHandlerFactory {
41 private final Logger logger = LoggerFactory.getLogger(TimerModuleExHandlerFactory.class);
43 private static final Collection<String> TYPES = Arrays
44 .asList(new String[] { AbsoluteDateTimeTriggerHandler.MODULE_TYPE_ID, TimerTriggerHandler.MODULE_TYPE_ID });
47 private @NonNullByDefault({}) Scheduler scheduler;
51 public void deactivate() {
56 public Collection<String> getTypes() {
61 protected @Nullable ModuleHandler internalCreate(Module module, String ruleUID) {
62 logger.trace("create {} -> {}", module.getId(), module.getTypeUID());
63 String moduleTypeUID = module.getTypeUID();
64 if (AbsoluteDateTimeTriggerHandler.MODULE_TYPE_ID.equals(moduleTypeUID) && module instanceof Trigger) {
65 return new AbsoluteDateTimeTriggerHandler((Trigger) module, scheduler);
66 } else if (TimerTriggerHandler.MODULE_TYPE_ID.equals(moduleTypeUID) && module instanceof Trigger) {
67 return new TimerTriggerHandler((Trigger) module, scheduler);
69 logger.error("The module handler type '{}' is not supported.", moduleTypeUID);