mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 21:31:53 +01:00
Changed comparison from equals() to reference (#1817)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
parent
8102cffb7f
commit
7cb746ece1
@ -90,7 +90,7 @@ public class ChannelCommandDescriptionProvider implements CommandDescriptionProv
|
||||
CommandDescription dynamicCommandDescription = dynamicCommandDescriptionProvider
|
||||
.getCommandDescription(channel, originalCommandDescription, locale);
|
||||
if (dynamicCommandDescription != null) {
|
||||
if (dynamicCommandDescription.equals(originalCommandDescription)) {
|
||||
if (dynamicCommandDescription == originalCommandDescription) {
|
||||
logger.error(
|
||||
"Dynamic command description matches original command description. DynamicCommandDescriptionProvider implementations must never return the original command description. {} has to be fixed.",
|
||||
dynamicCommandDescription.getClass());
|
||||
|
@ -100,12 +100,12 @@ public class ChannelStateDescriptionProvider implements StateDescriptionFragment
|
||||
ChannelType channelType = thingTypeRegistry.getChannelType(channel, locale);
|
||||
if (channelType != null) {
|
||||
stateDescription = channelType.getState();
|
||||
if ((channelType.getItemType() != null)
|
||||
&& ((stateDescription == null) || (stateDescription.getPattern() == null))) {
|
||||
String itemType = channelType.getItemType();
|
||||
if (itemType != null && (stateDescription == null || stateDescription.getPattern() == null)) {
|
||||
String pattern = null;
|
||||
if (CoreItemFactory.STRING.equalsIgnoreCase(channelType.getItemType())) {
|
||||
if (CoreItemFactory.STRING.equalsIgnoreCase(itemType)) {
|
||||
pattern = "%s";
|
||||
} else if (channelType.getItemType().startsWith(CoreItemFactory.NUMBER)) {
|
||||
} else if (itemType.startsWith(CoreItemFactory.NUMBER)) {
|
||||
pattern = "%.0f";
|
||||
}
|
||||
if (pattern != null) {
|
||||
@ -131,14 +131,15 @@ public class ChannelStateDescriptionProvider implements StateDescriptionFragment
|
||||
private @Nullable StateDescription getDynamicStateDescription(Channel channel,
|
||||
@Nullable StateDescription originalStateDescription, @Nullable Locale locale) {
|
||||
for (DynamicStateDescriptionProvider provider : dynamicStateDescriptionProviders) {
|
||||
StateDescription stateDescription = provider.getStateDescription(channel, originalStateDescription, locale);
|
||||
if (stateDescription != null) {
|
||||
if (stateDescription.equals(originalStateDescription)) {
|
||||
StateDescription dynamicStateDescription = provider.getStateDescription(channel, originalStateDescription,
|
||||
locale);
|
||||
if (dynamicStateDescription != null) {
|
||||
if (dynamicStateDescription == originalStateDescription) {
|
||||
logger.error(
|
||||
"Dynamic state description matches original state description. DynamicStateDescriptionProvider implementations must never return the original state description. {} has to be fixed.",
|
||||
provider.getClass());
|
||||
} else {
|
||||
return stateDescription;
|
||||
return dynamicStateDescription;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user