[thing] Add toString overrides to ThingImpl & BridgeImpl (#4382)

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
This commit is contained in:
Florian Hotze 2024-09-19 18:53:26 +02:00 committed by GitHub
parent 5f14cd1c5f
commit 437a885d82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 0 deletions

View File

@ -89,4 +89,9 @@ public class BridgeImpl extends ThingImpl implements Bridge {
}
return bridgeHandler;
}
@Override
public String toString() {
return super.toString().replace("Bridge=False", "Bridge=True");
}
}

View File

@ -237,6 +237,31 @@ public class ThingImpl implements Thing {
return ThingStatusDetail.DISABLED != getStatusInfo().getStatusDetail();
}
@Override
public String toString() {
// Configuration is deliberately excluded because it might include sensitive data like passwords.
StringBuilder sb = new StringBuilder(getUID().toString());
sb.append(" (ThingTypeUID=");
sb.append(getThingTypeUID());
sb.append(", Bridge=False");
if (getBridgeUID() != null) {
sb.append(", BridgeUID=");
sb.append(getBridgeUID());
}
sb.append(", Label=");
sb.append(getLabel());
if (getLocation() != null) {
sb.append(", Location=");
sb.append(getLocation());
}
sb.append(", Status=");
sb.append(getStatus());
sb.append(", StatusInfo=");
sb.append(getStatusInfo());
sb.append(")");
return sb.toString();
}
@Override
public int hashCode() {
final int prime = 31;