@Override public Bridge build() { return (Bridge) super.build(); }
protected void updateThingWithChannels(List<Channel> channels) { if (!channels.isEmpty()) { logger.debug("Updating thing with channels: {} / {}", url, channels.size()); synchronized (updateLock) { ThingBuilder thingBuilder = editThing(); channels.forEach(channel -> { String uid = channel.getUID().getIdWithoutGroup(); if (getChannel(uid) == null) { logger.debug("Channel to be added: {} {}", url, uid); thingBuilder.withChannel(channel); } }); logger.debug("Updating thing with new channels: {} / {}", url, channels.size()); updateThing(thingBuilder.build()); } } }
/** * Creates a thing based on a given thing type. It also creates the * default-configuration given in the configDescriptions if the * configDescriptionRegistry is not null * * @param thingType (must not be null) * @param thingUID (must not be null) * @param configuration (must not be null) * @param bridgeUID (can be null) * @param configDescriptionRegistry (can be null) * @return thing the thing */ public static Thing createThing(ThingType thingType, ThingUID thingUID, Configuration configuration, @Nullable ThingUID bridgeUID, @Nullable ConfigDescriptionRegistry configDescriptionRegistry) { ThingFactoryHelper.applyDefaultConfiguration(configuration, thingType, configDescriptionRegistry); List<Channel> channels = ThingFactoryHelper.createChannels(thingType, thingUID, configDescriptionRegistry); return createThingBuilder(thingType, thingUID).withConfiguration(configuration).withChannels(channels) .withProperties(thingType.getProperties()).withBridge(bridgeUID).build(); }
/** * Maps thing DTO into thing * * @param thingDTO the thingDTO * @param isBridge flag if the thing DTO identifies a bridge * @return the corresponding thing */ public static Thing map(ThingDTO thingDTO, boolean isBridge) { ThingUID thingUID = new ThingUID(thingDTO.UID); ThingTypeUID thingTypeUID = thingDTO.thingTypeUID == null ? new ThingTypeUID("") : new ThingTypeUID(thingDTO.thingTypeUID); final Thing thing; if (isBridge) { thing = BridgeBuilder.create(thingTypeUID, thingUID).build(); } else { thing = ThingBuilder.create(thingTypeUID, thingUID).build(); } return ThingHelper.merge(thing, thingDTO); }
ThingBuilder thingBuilder = editThing(); thingBuilder.withChannels(nodeChannels).withConfiguration(getConfig()); updateThing(thingBuilder.build());
Thing thing = thingBuilder.build(); if ((thingFromHandler != null)) { this.merge(thingFromHandler, thing);
Thing mergedThing = builder.build();