Changed comparison from equals() to reference (#1817)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2020-11-14 13:46:03 +01:00 committed by GitHub
parent 8102cffb7f
commit 7cb746ece1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 9 deletions

View File

@ -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());

View File

@ -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;
}
}
}