/** * Maps channel DTO into channel object. * * @param channelDTO the channel DTO * @return the channel object */ public static Channel map(ChannelDTO channelDTO) { ChannelUID channelUID = new ChannelUID(channelDTO.uid); ChannelTypeUID channelTypeUID = new ChannelTypeUID(channelDTO.channelTypeUID); return ChannelBuilder.create(channelUID, channelDTO.itemType) .withConfiguration(new Configuration(channelDTO.configuration)).withLabel(channelDTO.label) .withDescription(channelDTO.description).withProperties(channelDTO.properties).withType(channelTypeUID) .withDefaultTags(channelDTO.defaultTags).withKind(ChannelKind.parse(channelDTO.kind)).build(); } }
/** * Creates a channel builder from the given channel. * * @param channel the channel to be changed * @return channel builder */ public static ChannelBuilder create(Channel channel) { ChannelBuilder channelBuilder = create(channel.getUID(), channel.getAcceptedItemType()) .withConfiguration(channel.getConfiguration()).withDefaultTags(channel.getDefaultTags()) .withKind(channel.getKind()).withProperties(channel.getProperties()) .withType(channel.getChannelTypeUID()); String label = channel.getLabel(); if (label != null) { channelBuilder.withLabel(label); } String description = channel.getDescription(); if (description != null) { channelBuilder.withDescription(description); } return channelBuilder; }
.withDefaultTags(channelType.getTags()) //