public ChannelGroupType toChannelGroupType() throws ConversionException { ChannelGroupType channelGroupType = ChannelGroupTypeBuilder.instance(this.channelGroupTypeUID, this.label) .isAdvanced(this.advanced).withDescription(this.description).withCategory(this.category) .withChannelDefinitions(toChannelDefinitions(this.channelTypeReferences)).build(); return channelGroupType; }
/** * Create an instance of a ChannelGroupTypeBuilder for {@link ChannelGroupType}s * * @param channelGroupTypeUID UID of the {@link ChannelGroupType} * @param label Label for the {@link ChannelGroupType} * @return ChannelGroupTypeBuilder for {@link ChannelGroupType}s */ public static ChannelGroupTypeBuilder instance(ChannelGroupTypeUID channelGroupTypeUID, String label) { if (channelGroupTypeUID == null) { throw new IllegalArgumentException("ChannelGroupTypeUID must be set."); } if (StringUtils.isEmpty(label)) { throw new IllegalArgumentException("Label for a ChannelGroupType must not be empty."); } return new ChannelGroupTypeBuilder(channelGroupTypeUID, label); }
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(); }