use of org.eclipse.smarthome.core.thing.type.TriggerChannelTypeBuilder in project smarthome by eclipse.
the class ChannelTypeI18nLocalizationService method createLocalizedChannelType.
public ChannelType createLocalizedChannelType(Bundle bundle, ChannelType channelType, @Nullable Locale locale) {
ChannelTypeUID channelTypeUID = channelType.getUID();
String defaultLabel = channelType.getLabel();
String label = thingTypeI18nUtil.getChannelLabel(bundle, channelTypeUID, defaultLabel, locale);
String description = thingTypeI18nUtil.getChannelDescription(bundle, channelTypeUID, channelType.getDescription(), locale);
switch(channelType.getKind()) {
case STATE:
StateDescription state = createLocalizedStateDescription(bundle, channelType.getState(), channelTypeUID, locale);
CommandDescription command = createLocalizedCommandDescription(bundle, channelType.getCommandDescription(), channelTypeUID, locale);
StateChannelTypeBuilder stateBuilder = ChannelTypeBuilder.state(channelTypeUID, label == null ? defaultLabel : label, channelType.getItemType()).isAdvanced(channelType.isAdvanced()).withCategory(channelType.getCategory()).withConfigDescriptionURI(channelType.getConfigDescriptionURI()).withTags(channelType.getTags()).withStateDescription(state).withAutoUpdatePolicy(channelType.getAutoUpdatePolicy()).withCommandDescription(command);
if (description != null) {
stateBuilder.withDescription(description);
}
return stateBuilder.build();
case TRIGGER:
TriggerChannelTypeBuilder triggerBuilder = ChannelTypeBuilder.trigger(channelTypeUID, label == null ? defaultLabel : label).isAdvanced(channelType.isAdvanced()).withCategory(channelType.getCategory()).withConfigDescriptionURI(channelType.getConfigDescriptionURI()).withTags(channelType.getTags()).withEventDescription(channelType.getEvent());
if (description != null) {
triggerBuilder.withDescription(description);
}
return triggerBuilder.build();
default:
return new ChannelType(channelTypeUID, channelType.isAdvanced(), channelType.getItemType(), channelType.getKind(), label == null ? defaultLabel : label, description, channelType.getCategory(), channelType.getTags(), channelType.getState(), channelType.getEvent(), channelType.getConfigDescriptionURI(), channelType.getAutoUpdatePolicy());
}
}
Aggregations