Source:
<code>public Response create(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language") String language, @ApiParam(value = "thing data", required = true) ThingDTO thingBean) { final Locale locale = LocaleUtil.getLocale(language); ThingTypeUID thingTypeUID = new ThingTypeUID(thingBean.thingTypeUID); ThingUID thingUIDObject = new ThingUID(thingBean.UID); ThingUID bridgeUID = null; if (thingBean.bridgeUID != null) { bridgeUID = new ThingUID(thingBean.bridgeUID); } Configuration configuration = convertConfiguration(thingBean.configuration); Status status; Thing thing = thingRegistry.get(thingUIDObject); if (thing == null) { List<Channel> channels = new ArrayList<Channel>(); <START> for (ChannelDTO channelBean : thingBean.channels) { <END> String channelId = channelBean.id; if (channelId == null) { channelId = channelBean.itemType + "_" + System.nanoTime(); } ChannelUID channelUIDObject = new ChannelUID(thingTypeUID, thingUIDObject, channelId); configuration = convertConfiguration(channelBean.configuration); Channel channel = managedThingProvider.createChannel(channelUIDObject, channelBean.itemType, configuration); channels.add(channel); } thing = managedThingProvider.createThing(thingTypeUID, thingUIDObject, bridgeUID, thingBean.label, configuration, channels); status = Status.CREATED; } else { status = Status.CONFLICT; } return getThingResponse(status, thing, locale, "Thing " + thingUIDObject.toString() + " already exists!"); }</code><technical_language>Is is guaranteed thingBean.channels is null</technical_language>

Target:
public Response create(@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @ApiParam(value = "language") String language, @ApiParam(value = "thing data", required = true) ThingDTO thingBean) { final Locale locale = LocaleUtil.getLocale(language); ThingTypeUID thingTypeUID = new ThingTypeUID(thingBean.thingTypeUID); ThingUID thingUIDObject = new ThingUID(thingBean.UID); ThingUID bridgeUID = null; if (thingBean.bridgeUID != null) { bridgeUID = new ThingUID(thingBean.bridgeUID); } Configuration configuration = convertConfiguration(thingBean.configuration); Status status; String statusMessage = null; Thing thing = thingRegistry.get(thingUIDObject); if (thing == null) { List<Channel> channels = null; if (thingBean.channels != null) { channels = new ArrayList<Channel>(); for (ChannelDTO channelBean : thingBean.channels) { String channelId = channelBean.id; if (channelId == null) { } ChannelUID channelUIDObject = new ChannelUID(thingTypeUID, thingUIDObject, channelId); configuration = convertConfiguration(channelBean.configuration); Channel channel = managedThingProvider.createChannel(channelUIDObject, channelBean.itemType, configuration); channels.add(channel); } } else { logger.trace("Thing does not contain any Channel configuration."); } thing = managedThingProvider.createThing(thingTypeUID, thingUIDObject, bridgeUID, thingBean.label, configuration, channels); if (thing != null) { status = Status.CREATED; } else { status = Status.BAD_REQUEST; statusMessage = "Cannot create thing. No binding found that supports creating a thing of type " + thingTypeUID; } } else { status = Status.CONFLICT; statusMessage = "Thing " + thingUIDObject.toString() + " already exists!"; } return getThingResponse(status, thing, locale, statusMessage); }