@Override public Bridge build() { return (Bridge) super.build(); }
@Override public BridgeBuilder withChannels(Channel... channels) { return (BridgeBuilder) super.withChannels(channels); }
@Override public BridgeBuilder withConfiguration(Configuration thingConfiguration) { return (BridgeBuilder) super.withConfiguration(thingConfiguration); }
builder = BridgeBuilder.create(thing.getThingTypeUID(), thing.getUID()); } else { builder = ThingBuilder.create(thing.getThingTypeUID(), thing.getUID()); builder.withLabel(updatedContents.label); } else { builder.withLabel(thing.getLabel()); builder.withLocation(updatedContents.location); } else { builder.withLocation(thing.getLocation()); builder.withBridge(new ThingUID(updatedContents.bridgeUID)); } else { builder.withBridge(thing.getBridgeUID()); builder.withConfiguration(new Configuration(updatedContents.configuration)); } else { builder.withConfiguration(thing.getConfiguration()); builder.withProperties(updatedContents.properties); } else { builder.withProperties(thing.getProperties()); builder.withChannel(ChannelDTOMapper.map(channelDTO)); builder.withChannels(thing.getChannels()); builder.withLocation(updatedContents.location);
_xifexpression_2 = BridgeBuilder.create(thingTypeUID, thingUID); } else { _xifexpression_2 = ThingBuilder.create(thingTypeUID, thingUID); thingBuilder.withConfiguration(configuration); thingBuilder.withBridge(bridgeUID); thingBuilder.withLabel(label); thingBuilder.withLocation(location); EList<ModelChannel> _channels = modelThing.getChannels(); List<ChannelDefinition> _elvis = null; thingBuilder.withChannels(channels); Thing thing = thingBuilder.build(); if ((thingFromHandler != null)) { this.merge(thingFromHandler, thing);
/** * Creates a thing builder, which allows to modify the thing. The method * {@link BaseThingHandler#updateThing(Thing)} must be called to persist the changes. * * @return {@link ThingBuilder} which builds an exact copy of the thing (not null) */ protected ThingBuilder editThing() { return ThingBuilder.create(this.thing.getThingTypeUID(), this.thing.getUID()) .withBridge(this.thing.getBridgeUID()).withChannels(this.thing.getChannels()) .withConfiguration(this.thing.getConfiguration()).withLabel(this.thing.getLabel()) .withLocation(this.thing.getLocation()).withProperties(this.thing.getProperties()); }
/** * 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(); }
oldChannelUidList, newChannelUidList); ThingBuilder thingBuilder = editThing(); thingBuilder.withChannels(nodeChannels).withConfiguration(getConfig()); updateThing(thingBuilder.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()); } } }
/** * 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); }
@Override public BridgeBuilder withChannel(Channel channel) { return (BridgeBuilder) super.withChannel(channel); }
@Override public BridgeBuilder withLabel(@Nullable String label) { return (BridgeBuilder) super.withLabel(label); }
@Override public BridgeBuilder withLocation(@Nullable String location) { return (BridgeBuilder) super.withLocation(location); }
@Override public BridgeBuilder withBridge(@Nullable ThingUID bridgeUID) { return (BridgeBuilder) super.withBridge(bridgeUID); }
private static ThingBuilder createThingBuilder(ThingType thingType, ThingUID thingUID) { if (thingType instanceof BridgeType) { return BridgeBuilder.create(thingType.getUID(), thingUID); } return ThingBuilder.create(thingType.getUID(), thingUID); }
@Override public BridgeBuilder withChannels(List<Channel> channels) { return (BridgeBuilder) super.withChannels(channels); }
public ThingBuilder withChannels(Channel... channels) { return withChannels(Arrays.asList(channels)); }