use of org.eclipse.smarthome.core.thing.binding.ThingActionsScope in project smarthome by eclipse.
the class AnnotatedThingActionModuleTypeProvider method addAnnotatedThingActions.
@Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE)
public void addAnnotatedThingActions(ThingActions annotatedThingActions) {
if (annotatedThingActions.getClass().isAnnotationPresent(ThingActionsScope.class)) {
ThingActionsScope scope = annotatedThingActions.getClass().getAnnotation(ThingActionsScope.class);
Collection<ModuleInformation> moduleInformations = helper.parseAnnotations(scope.name(), annotatedThingActions);
String thingUID = annotatedThingActions.getThingHandler().getThing().getUID().getAsString();
for (ModuleInformation mi : moduleInformations) {
mi.setThingUID(thingUID);
ModuleType oldType = null;
if (this.moduleInformation.containsKey(mi.getUID())) {
oldType = helper.buildModuleType(mi.getUID(), this.moduleInformation);
Set<ModuleInformation> availableModuleConfigs = this.moduleInformation.get(mi.getUID());
availableModuleConfigs.add(mi);
} else {
Set<ModuleInformation> configs = ConcurrentHashMap.newKeySet();
configs.add(mi);
this.moduleInformation.put(mi.getUID(), configs);
}
ModuleType mt = helper.buildModuleType(mi.getUID(), this.moduleInformation);
if (mt != null) {
for (ProviderChangeListener<ModuleType> l : changeListeners) {
if (oldType != null) {
l.updated(this, oldType, mt);
} else {
l.added(this, mt);
}
}
}
}
}
}
Aggregations