private ChannelGroupType createLocalizedChannelGroupType(Bundle bundle, ChannelGroupType channelGroupType, Locale locale) { LocalizedChannelTypeKey localizedChannelTypeKey = getLocalizedChannelTypeKey(channelGroupType.getUID(), locale); ChannelGroupType cachedEntry = localizedChannelGroupTypeCache.get(localizedChannelTypeKey); if (cachedEntry != null) { return cachedEntry; } if (this.thingTypeI18nUtil != null) { ChannelGroupTypeUID channelGroupTypeUID = channelGroupType.getUID(); String label = this.thingTypeI18nUtil.getChannelGroupLabel(bundle, channelGroupTypeUID, channelGroupType.getLabel(), locale); String description = this.thingTypeI18nUtil.getChannelGroupDescription(bundle, channelGroupTypeUID, channelGroupType.getDescription(), locale); ChannelGroupType localizedChannelType = new ChannelGroupType(channelGroupTypeUID, channelGroupType.isAdvanced(), label, description, channelGroupType.getChannelDefinitions()); localizedChannelGroupTypeCache.put(localizedChannelTypeKey, localizedChannelType); return localizedChannelType; } return channelGroupType; }
public ChannelGroupType createLocalizedChannelGroupType(Bundle bundle, ChannelGroupType channelGroupType, @Nullable Locale locale) { ChannelGroupTypeUID channelGroupTypeUID = channelGroupType.getUID(); String defaultLabel = channelGroupType.getLabel(); String label = thingTypeI18nUtil.getChannelGroupLabel(bundle, channelGroupTypeUID, defaultLabel, locale); String description = thingTypeI18nUtil.getChannelGroupDescription(bundle, channelGroupTypeUID, channelGroupType.getDescription(), locale); List<ChannelDefinition> localizedChannelDefinitions = channelI18nUtil.createLocalizedChannelDefinitions(bundle, channelGroupType.getChannelDefinitions(), channelDefinition -> thingTypeI18nUtil.getChannelLabel(bundle, channelGroupTypeUID, channelDefinition, channelDefinition.getLabel(), locale), channelDefinition -> thingTypeI18nUtil.getChannelDescription(bundle, channelGroupTypeUID, channelDefinition, channelDefinition.getDescription(), locale), locale); ChannelGroupTypeBuilder builder = ChannelGroupTypeBuilder .instance(channelGroupTypeUID, label == null ? defaultLabel : label) .isAdvanced(channelGroupType.isAdvanced()).withCategory(channelGroupType.getCategory()) .withChannelDefinitions(localizedChannelDefinitions); if (description != null) { builder.withDescription(description); } return builder.build(); }