2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.freeboxos.internal.config;
15 import java.util.Optional;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.freeboxos.internal.api.rest.HomeManager.Category;
19 import org.openhab.binding.freeboxos.internal.api.rest.HomeManager.HomeNode;
20 import org.openhab.core.config.discovery.DiscoveryResultBuilder;
21 import org.openhab.core.thing.ThingUID;
24 * The {@link NodeConfigurationBuilder} is responsible for holding configuration informations associated to a Freebox
27 * @author ben12 - Initial contribution
30 public class NodeConfigurationBuilder {
31 private static final NodeConfigurationBuilder BUILDER_INSTANCE = new NodeConfigurationBuilder();
33 private NodeConfigurationBuilder() {
36 public static NodeConfigurationBuilder getInstance() {
37 return BUILDER_INSTANCE;
40 public Optional<DiscoveryResultBuilder> configure(ThingUID bridgeUID, HomeNode node) {
41 if (node.category() == Category.UNKNOWN) {
42 return Optional.empty();
44 ThingUID thingUID = new ThingUID(node.category().getThingTypeUID(), bridgeUID, Integer.toString(node.id()));
45 DiscoveryResultBuilder discoveryResultBuilder = DiscoveryResultBuilder.create(thingUID);
46 discoveryResultBuilder.withProperty(ClientConfiguration.ID, node.id()).withLabel(node.label())
47 .withRepresentationProperty(ClientConfiguration.ID).withBridge(bridgeUID);
48 return Optional.of(discoveryResultBuilder);