Skip to content

Commit 8b2414c

Browse files
committed
[smsmodem] Apply code review (removing unnecessary method)
Signed-off-by: Gwendal Roulleau <[email protected]>
1 parent 6216419 commit 8b2414c

File tree

3 files changed

+5
-31
lines changed

3 files changed

+5
-31
lines changed

bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSConversationDiscoveryService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ protected void startScan() {
5656

5757
public void buildDiscovery(String sender) {
5858
String senderSanitized = sender.replaceAll("[^a-zA-Z0-9+]", "_");
59-
ThingUID thingUID = SMSModemHandlerFactory
60-
.getSMSConversationUID(SMSModemBindingConstants.SMSCONVERSATION_THING_TYPE, senderSanitized, bridgeUid);
59+
60+
ThingUID thingUID = new ThingUID(SMSModemBindingConstants.SMSCONVERSATION_THING_TYPE, senderSanitized,
61+
bridgeUid.getId());
62+
6163
DiscoveryResult result = DiscoveryResultBuilder.create(thingUID)
6264
.withProperty(SMSModemBindingConstants.SMSCONVERSATION_PARAMETER_RECIPIENT, senderSanitized)
6365
.withLabel("Conversation with " + sender).withBridge(bridgeUid)

bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSModemHandlerFactory.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
import org.eclipse.jdt.annotation.Nullable;
2020
import org.openhab.binding.smsmodem.internal.handler.SMSConversationHandler;
2121
import org.openhab.binding.smsmodem.internal.handler.SMSModemBridgeHandler;
22-
import org.openhab.core.config.core.Configuration;
2322
import org.openhab.core.io.transport.serial.SerialPortManager;
2423
import org.openhab.core.thing.Bridge;
2524
import org.openhab.core.thing.Thing;
2625
import org.openhab.core.thing.ThingTypeUID;
27-
import org.openhab.core.thing.ThingUID;
2826
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
2927
import org.openhab.core.thing.binding.ThingHandler;
3028
import org.openhab.core.thing.binding.ThingHandlerFactory;
@@ -75,31 +73,4 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
7573

7674
return null;
7775
}
78-
79-
@Override
80-
public @Nullable Thing createThing(ThingTypeUID thingTypeUID, Configuration configuration,
81-
@Nullable ThingUID thingUID, @Nullable ThingUID bridgeUID) {
82-
if (SMSModemBridgeHandler.SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) {
83-
return super.createThing(thingTypeUID, configuration, thingUID, null);
84-
}
85-
if (SMSConversationHandler.SUPPORTED_THING_TYPES_UIDS.equals(thingTypeUID)) {
86-
if (bridgeUID != null) {
87-
ThingUID safethingUID = thingUID == null
88-
? getSMSConversationUID(thingTypeUID,
89-
(String) configuration
90-
.get(SMSModemBindingConstants.SMSCONVERSATION_PARAMETER_RECIPIENT),
91-
bridgeUID)
92-
: thingUID;
93-
return super.createThing(thingTypeUID, configuration, safethingUID, bridgeUID);
94-
} else {
95-
throw new IllegalArgumentException("Cannot create a SMSConversation without a SMSModem bridge");
96-
}
97-
98-
}
99-
throw new IllegalArgumentException("The thing type " + thingTypeUID + " is not supported by the binding.");
100-
}
101-
102-
public static ThingUID getSMSConversationUID(ThingTypeUID thingTypeUID, String recipient, ThingUID bridgeUID) {
103-
return new ThingUID(thingTypeUID, recipient, bridgeUID.getId());
104-
}
10576
}

bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/handler/SMSModemBridgeHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ protected void updateConfiguration(Configuration configuration) {
132132

133133
@Override
134134
public void initialize() {
135+
updateStatus(ThingStatus.UNKNOWN);
135136
shouldRun = true;
136137
ScheduledFuture<?> checkScheduledFinal = checkScheduled;
137138
if (checkScheduledFinal == null || (checkScheduledFinal.isDone()) && this.shouldRun) {

0 commit comments

Comments
 (0)