From ed2d1962f5c0f15868e1fba83bcc74885111905e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20L=27hopital?= Date: Sat, 7 Dec 2024 23:13:45 +0100 Subject: [PATCH] A session of compile warning hunt (#4472) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gaël L'hopital --- .../org/openhab/core/cache/ExpiringCache.java | 2 + .../openhab/core/cache/lru/LRUMediaCache.java | 12 +++--- ...sedSequentialScheduledExecutorService.java | 3 +- .../core/common/ThreadFactoryBuilder.java | 10 ++--- .../common/registry/AbstractRegistry.java | 10 ++--- .../openhab/core/events/AbstractEvent.java | 18 +++------ .../events/system/SystemEventFactory.java | 3 +- .../org/openhab/core/i18n/LocalizedKey.java | 2 +- .../auth/AuthenticationManagerImpl.java | 4 +- .../internal/auth/ManagedUserProvider.java | 4 +- .../common/AbstractInvocationHandler.java | 4 +- .../internal/events/OSGiEventManager.java | 5 +-- .../core/internal/i18n/I18nProviderImpl.java | 7 ++-- .../i18n/LanguageResourceBundleManager.java | 4 +- .../items/ItemBuilderFactoryImpl.java | 5 +-- .../core/internal/items/ItemRegistryImpl.java | 36 +++++++---------- ...adataStateDescriptionFragmentProvider.java | 40 +++++++++---------- .../internal/scheduler/SchedulerImpl.java | 1 - .../types/StateDescriptionFragmentImpl.java | 5 +-- .../org/openhab/core/items/GenericItem.java | 10 ++--- .../org/openhab/core/items/GroupItem.java | 6 +-- .../java/org/openhab/core/items/Item.java | 27 ++++++------- .../org/openhab/core/items/ItemProvider.java | 3 +- .../core/items/ManagedMetadataProvider.java | 3 +- .../openhab/core/items/dto/ItemDTOMapper.java | 7 ---- .../events/AbstractItemRegistryEvent.java | 4 +- .../core/library/items/NumberItem.java | 5 +-- .../core/library/types/NextPreviousType.java | 3 +- .../core/library/types/StringListType.java | 3 +- .../org/openhab/core/net/CidrAddress.java | 3 +- .../java/org/openhab/core/net/NetUtil.java | 9 ++--- .../openhab/core/scheduler/CronAdjuster.java | 4 +- .../org/openhab/core/scheduler/Scheduler.java | 3 +- .../org/openhab/core/service/ReadyMarker.java | 16 ++------ .../java/org/openhab/core/types/Type.java | 4 +- .../java/org/openhab/core/util/ColorUtil.java | 9 ++--- .../core/internal/i18n/I18nExceptionTest.java | 4 +- .../org/openhab/core/util/UIDUtilsTest.java | 3 +- 38 files changed, 117 insertions(+), 184 deletions(-) diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/ExpiringCache.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/ExpiringCache.java index f8e08209a..aa4175fed 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/ExpiringCache.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/ExpiringCache.java @@ -67,6 +67,7 @@ public class ExpiringCache { * Returns the value - possibly from the cache, if it is still valid. */ public synchronized @Nullable V getValue() { + @Nullable V cachedValue = value.get(); if (cachedValue == null || isExpired()) { return refreshValue(); @@ -98,6 +99,7 @@ public class ExpiringCache { * @return the new value */ public synchronized @Nullable V refreshValue() { + @Nullable V freshValue = action.get(); value = new SoftReference<>(freshValue); expiresAt = calcExpiresAt(); diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/lru/LRUMediaCache.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/lru/LRUMediaCache.java index 94ff36157..d82ff32f5 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/lru/LRUMediaCache.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/cache/lru/LRUMediaCache.java @@ -132,13 +132,11 @@ public class LRUMediaCache { // 2 clean orphan (part of a pair (file + metadata) without a corresponding partner) // 2-a delete a file without its metadata for (Path path : filesInCacheFolder) { - if (path != null) { - String fileName = path.getFileName().toString(); - // check corresponding metadata in storage - V metadata = storage.get(fileName); - if (metadata == null) { - Files.delete(path); - } + String fileName = path.getFileName().toString(); + // check corresponding metadata in storage + V metadata = storage.get(fileName); + if (metadata == null) { + Files.delete(path); } } // 2-b delete metadata without corresponding file diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/common/PoolBasedSequentialScheduledExecutorService.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/common/PoolBasedSequentialScheduledExecutorService.java index afcb5f507..af2599149 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/common/PoolBasedSequentialScheduledExecutorService.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/common/PoolBasedSequentialScheduledExecutorService.java @@ -22,7 +22,6 @@ import java.util.concurrent.Callable; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; -import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.RunnableFuture; @@ -43,7 +42,7 @@ import org.slf4j.LoggerFactory; /** * A ScheduledExecutorService that will sequentially perform the tasks like a - * {@link Executors#newSingleThreadScheduledExecutor} backed by a thread pool. + * {@link java.util.concurrent.Executors#newSingleThreadScheduledExecutor} backed by a thread pool. * This is a drop in replacement to a ScheduledExecutorService with one thread to avoid a lot of threads created, idling * most of the time and wasting memory on low-end devices. * diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/common/ThreadFactoryBuilder.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/common/ThreadFactoryBuilder.java index 1d6045c17..c467bb540 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/common/ThreadFactoryBuilder.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/common/ThreadFactoryBuilder.java @@ -15,8 +15,6 @@ package org.openhab.core.common; import static java.util.concurrent.Executors.defaultThreadFactory; import java.lang.Thread.UncaughtExceptionHandler; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicInteger; @@ -25,10 +23,12 @@ import org.eclipse.jdt.annotation.Nullable; /** * A builder for {@link ThreadFactory} instances. This builder is intended to be used for creating thread factories to - * be used, e.g., when creating {@link Executor}s via the {@link Executors} utility methods. + * be used, e.g., when creating {@link java.util.concurrent.Executor}s via the {@link java.util.concurrent.Executors} + * utility methods. *

* The built {@link ThreadFactory} uses a wrapped {@link ThreadFactory} to create threads (defaulting to - * {@link Executors#defaultThreadFactory()}, and then overwrites thread properties as indicated in the build process. + * {@link java.util.concurrent.Executors#defaultThreadFactory()}, and then overwrites thread properties as indicated in + * the build process. * * @author Henning Sudbrock - Initial contribution */ @@ -60,7 +60,7 @@ public class ThreadFactoryBuilder { /** * Sets the wrapped thread factory used to create threads. *

- * If set to null, {@link Executors#defaultThreadFactory()} is used. + * If set to null, {@link java.util.concurrent.Executors#defaultThreadFactory()} is used. *

* Defaults to null. * diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractRegistry.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractRegistry.java index dd4f86330..487629de6 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractRegistry.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/common/registry/AbstractRegistry.java @@ -442,9 +442,9 @@ public abstract class AbstractRegistry<@NonNull E extends Identifiable, @NonN } elementsAdded.forEach(this::notifyListenersAboutAddedElement); - if (provider instanceof ManagedProvider && providerClazz != null && readyService != null) { - readyService.markReady( - new ReadyMarker("managed", providerClazz.getSimpleName().replace("Provider", "").toLowerCase())); + if (provider instanceof ManagedProvider && providerClazz instanceof Class clazz + && readyService instanceof ReadyService rs) { + rs.markReady(new ReadyMarker("managed", clazz.getSimpleName().replace("Provider", "").toLowerCase())); } logger.debug("Provider \"{}\" has been added.", provider.getClass().getName()); } @@ -688,9 +688,9 @@ public abstract class AbstractRegistry<@NonNull E extends Identifiable, @NonN * @param event the event */ protected void postEvent(Event event) { - if (eventPublisher != null) { + if (eventPublisher instanceof EventPublisher ep) { try { - eventPublisher.post(event); + ep.post(event); } catch (RuntimeException ex) { logger.error("Cannot post event of type \"{}\".", event.getType(), ex); } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/events/AbstractEvent.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/events/AbstractEvent.java index 3e307f30d..71fc1dfca 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/events/AbstractEvent.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/events/AbstractEvent.java @@ -61,9 +61,9 @@ public abstract class AbstractEvent implements Event { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((payload == null) ? 0 : payload.hashCode()); - result = prime * result + ((source == null) ? 0 : source.hashCode()); - result = prime * result + ((topic == null) ? 0 : topic.hashCode()); + result = prime * result + payload.hashCode(); + result = prime * result + (source instanceof String local ? local.hashCode() : 0); + result = prime * result + topic.hashCode(); return result; } @@ -79,11 +79,7 @@ public abstract class AbstractEvent implements Event { return false; } AbstractEvent other = (AbstractEvent) obj; - if (payload == null) { - if (other.payload != null) { - return false; - } - } else if (!payload.equals(other.payload)) { + if (!payload.equals(other.payload)) { return false; } if (source == null) { @@ -93,11 +89,7 @@ public abstract class AbstractEvent implements Event { } else if (!source.equals(other.source)) { return false; } - if (topic == null) { - if (other.topic != null) { - return false; - } - } else if (!topic.equals(other.topic)) { + if (!topic.equals(other.topic)) { return false; } return true; diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/events/system/SystemEventFactory.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/events/system/SystemEventFactory.java index 35c702bd0..dbf707964 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/events/system/SystemEventFactory.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/events/system/SystemEventFactory.java @@ -19,7 +19,6 @@ import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.events.AbstractEventFactory; import org.openhab.core.events.Event; import org.openhab.core.events.EventFactory; -import org.openhab.core.types.Type; import org.osgi.service.component.annotations.Component; /** @@ -38,7 +37,7 @@ public class SystemEventFactory extends AbstractEventFactory { } /** - * Creates a trigger event from a {@link Type}. + * Creates a trigger event from a {@link org.openhab.core.types.Type}. * * @param startlevel Startlevel of system * @return Created start level event. diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/i18n/LocalizedKey.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/i18n/LocalizedKey.java index 885c532a3..380eed198 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/i18n/LocalizedKey.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/i18n/LocalizedKey.java @@ -46,7 +46,7 @@ public class LocalizedKey { final int prime = 31; int result = 1; result = prime * result + key.hashCode(); - result = prime * result + ((locale != null) ? locale.hashCode() : 0); + result = prime * result + (locale instanceof String string ? string.hashCode() : 0); return result; } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/auth/AuthenticationManagerImpl.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/auth/AuthenticationManagerImpl.java index ecac3a0c8..fb1629fe0 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/auth/AuthenticationManagerImpl.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/auth/AuthenticationManagerImpl.java @@ -48,9 +48,7 @@ public class AuthenticationManagerImpl implements AuthenticationManager { unmatched = false; try { Authentication authentication = provider.authenticate(credentials); - if (authentication != null) { - return authentication; - } + return authentication; } catch (AuthenticationException e) { logger.info("Failed to authenticate credentials {} with provider {}", credentials.getClass(), provider, e); diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/auth/ManagedUserProvider.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/auth/ManagedUserProvider.java index 64d01a582..eca94b930 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/auth/ManagedUserProvider.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/auth/ManagedUserProvider.java @@ -13,17 +13,15 @@ package org.openhab.core.internal.auth; import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.core.auth.ManagedUser; import org.openhab.core.auth.User; import org.openhab.core.common.registry.DefaultAbstractManagedProvider; -import org.openhab.core.common.registry.ManagedProvider; import org.openhab.core.storage.StorageService; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; /** - * A {@link ManagedProvider} for {@link ManagedUser} entities + * A {@link org.openhab.core.common.registry.ManagedProvider} for {@link org.openhab.core.auth.ManagedUser} entities * * @author Yannick Schaus - initial contribution */ diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/AbstractInvocationHandler.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/AbstractInvocationHandler.java index 8055f66f8..ac09ac459 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/AbstractInvocationHandler.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/common/AbstractInvocationHandler.java @@ -117,8 +117,8 @@ abstract class AbstractInvocationHandler { } else { logger.debug(MSG_TIMEOUT_Q, timeout, toString(invocation.getInvocationStack())); } - if (timeoutHandler != null) { - timeoutHandler.run(); + if (timeoutHandler instanceof Runnable handler) { + handler.run(); } } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/events/OSGiEventManager.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/events/OSGiEventManager.java index b5e0bfb79..5e008b295 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/events/OSGiEventManager.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/events/OSGiEventManager.java @@ -17,7 +17,6 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArraySet; -import org.openhab.core.events.Event; import org.openhab.core.events.EventFactory; import org.openhab.core.events.EventSubscriber; import org.osgi.service.component.ComponentContext; @@ -33,8 +32,8 @@ import org.osgi.service.event.EventHandler; * The {@link OSGiEventManager} provides an OSGi based default implementation of the openHAB event bus. * * The OSGiEventHandler tracks {@link EventSubscriber}s and {@link EventFactory}s, receives OSGi events (by - * implementing the OSGi {@link EventHandler} interface) and dispatches the received OSGi events as OH {@link Event}s - * to the {@link EventSubscriber}s if the provided filter applies. + * implementing the OSGi {@link EventHandler} interface) and dispatches the received OSGi events + * as OH {@link org.openhab.core.events.Event}s to the {@link EventSubscriber}s if the provided filter applies. * * @author Stefan Bußweiler - Initial contribution * @author Markus Rathgeb - Return on received events as fast as possible (handle event in another thread) diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/I18nProviderImpl.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/I18nProviderImpl.java index ee1983fdf..ce61377b7 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/I18nProviderImpl.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/I18nProviderImpl.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; import java.util.Objects; -import java.util.ResourceBundle; import java.util.Set; import javax.measure.Quantity; @@ -100,7 +99,8 @@ import org.slf4j.LoggerFactory; * and {@link LocationProvider} service interfaces. * *

- * This implementation uses the i18n mechanism of Java ({@link ResourceBundle}) to translate a given key into text. The + * This implementation uses the i18n mechanism of Java ({@link java.util.ResourceBundle}) to translate a + * given key into text. The * resources must be placed under the specific directory {@link LanguageResourceBundleManager#RESOURCE_DIRECTORY} within * the certain modules. Each module is tracked in the platform by using the {@link ResourceBundleTracker} and managed by * using one certain {@link LanguageResourceBundleManager} which is responsible for the translation. @@ -134,7 +134,6 @@ public class I18nProviderImpl public static final String REGION = "region"; public static final String VARIANT = "variant"; private @Nullable Locale locale; - private @Nullable String currencyCode; // TranslationProvider private final ResourceBundleTracker resourceBundleTracker; @@ -301,7 +300,7 @@ public class I18nProviderImpl if (oldTimeZone != null && this.timeZone == null) { logger.info("Time zone is not set, falling back to the default time zone."); - } else if (this.timeZone != null && !this.timeZone.equals(oldTimeZone)) { + } else if (this.timeZone instanceof ZoneId zId && !zId.equals(oldTimeZone)) { logger.info("Time zone set to '{}'.", this.timeZone); } } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/LanguageResourceBundleManager.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/LanguageResourceBundleManager.java index eb37d02fa..fa8995213 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/LanguageResourceBundleManager.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/i18n/LanguageResourceBundleManager.java @@ -183,9 +183,7 @@ public class LanguageResourceBundleManager { ResourceBundle resourceBundle = ResourceBundle.getBundle(resourceName, locale, this.resourceClassLoader, Control.getNoFallbackControl(Control.FORMAT_PROPERTIES)); - if (resourceBundle != null) { - return resourceBundle.getString(key); - } + return resourceBundle.getString(key); } catch (Exception ex) { // nothing to do } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/ItemBuilderFactoryImpl.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/ItemBuilderFactoryImpl.java index 8d89cb91e..f09a3bf10 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/ItemBuilderFactoryImpl.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/ItemBuilderFactoryImpl.java @@ -20,7 +20,6 @@ import org.openhab.core.items.Item; import org.openhab.core.items.ItemBuilder; import org.openhab.core.items.ItemBuilderFactory; import org.openhab.core.items.ItemFactory; -import org.openhab.core.library.CoreItemFactory; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; @@ -28,8 +27,8 @@ import org.osgi.service.component.annotations.ReferenceCardinality; import org.osgi.service.component.annotations.ReferencePolicy; /** - * Provides an {@link ItemBuilder} with all available {@link ItemFactory}s set. The {@link CoreItemFactory} will always - * be present. + * Provides an {@link ItemBuilder} with all available {@link ItemFactory}s set. + * The {@link org.openhab.core.library.CoreItemFactory} will always be present. * * @author Henning Treu - Initial contribution */ diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/ItemRegistryImpl.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/ItemRegistryImpl.java index b5f991450..c954277bb 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/ItemRegistryImpl.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/ItemRegistryImpl.java @@ -156,28 +156,24 @@ public class ItemRegistryImpl extends AbstractRegistry groupItemNames) { for (String groupName : groupItemNames) { - if (groupName != null) { - try { - if (getItem(groupName) instanceof GroupItem groupItem) { - groupItem.addMember(item); - } - } catch (ItemNotFoundException e) { - // the group might not yet be registered, let's ignore this + try { + if (getItem(groupName) instanceof GroupItem groupItem) { + groupItem.addMember(item); } + } catch (ItemNotFoundException e) { + // the group might not yet be registered, let's ignore this } } } private void replaceInGroupItems(Item oldItem, Item newItem, List groupItemNames) { for (String groupName : groupItemNames) { - if (groupName != null) { - try { - if (getItem(groupName) instanceof GroupItem groupItem) { - groupItem.replaceMember(oldItem, newItem); - } - } catch (ItemNotFoundException e) { - // the group might not yet be registered, let's ignore this + try { + if (getItem(groupName) instanceof GroupItem groupItem) { + groupItem.replaceMember(oldItem, newItem); } + } catch (ItemNotFoundException e) { + // the group might not yet be registered, let's ignore this } } } @@ -229,14 +225,12 @@ public class ItemRegistryImpl extends AbstractRegistry groupItemNames) { for (String groupName : groupItemNames) { - if (groupName != null) { - try { - if (getItem(groupName) instanceof GroupItem groupItem) { - groupItem.removeMember(item); - } - } catch (ItemNotFoundException e) { - // the group might not yet be registered, let's ignore this + try { + if (getItem(groupName) instanceof GroupItem groupItem) { + groupItem.removeMember(item); } + } catch (ItemNotFoundException e) { + // the group might not yet be registered, let's ignore this } } } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/MetadataStateDescriptionFragmentProvider.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/MetadataStateDescriptionFragmentProvider.java index 6bbf754e6..c598e385d 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/MetadataStateDescriptionFragmentProvider.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/items/MetadataStateDescriptionFragmentProvider.java @@ -125,34 +125,30 @@ public class MetadataStateDescriptionFragmentProvider implements StateDescriptio private BigDecimal getBigDecimal(Object value) { BigDecimal ret = null; - if (value != null) { - if (value instanceof BigDecimal decimal) { - ret = decimal; - } else if (value instanceof String string) { - ret = new BigDecimal(string); - } else if (value instanceof BigInteger integer) { - ret = new BigDecimal(integer); - } else if (value instanceof Number number) { - ret = new BigDecimal(number.doubleValue()); - } else { - throw new ClassCastException("Not possible to coerce [" + value + "] from class " + value.getClass() - + " into a BigDecimal."); - } + if (value instanceof BigDecimal decimal) { + ret = decimal; + } else if (value instanceof String string) { + ret = new BigDecimal(string); + } else if (value instanceof BigInteger integer) { + ret = new BigDecimal(integer); + } else if (value instanceof Number number) { + ret = new BigDecimal(number.doubleValue()); + } else { + throw new ClassCastException( + "Not possible to coerce [" + value + "] from class " + value.getClass() + " into a BigDecimal."); } return ret; } private Boolean getBoolean(Object value) { Boolean ret = null; - if (value != null) { - if (value instanceof Boolean boolean1) { - ret = boolean1; - } else if (value instanceof String string) { - ret = Boolean.parseBoolean(string); - } else { - throw new ClassCastException( - "Not possible to coerce [" + value + "] from class " + value.getClass() + " into a Boolean."); - } + if (value instanceof Boolean boolean1) { + ret = boolean1; + } else if (value instanceof String string) { + ret = Boolean.parseBoolean(string); + } else { + throw new ClassCastException( + "Not possible to coerce [" + value + "] from class " + value.getClass() + " into a Boolean."); } return ret; } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/scheduler/SchedulerImpl.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/scheduler/SchedulerImpl.java index 3d227e711..4a371b61d 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/scheduler/SchedulerImpl.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/scheduler/SchedulerImpl.java @@ -200,7 +200,6 @@ public class SchedulerImpl implements Scheduler { */ private static class ScheduledCompletableFutureRecurring extends ScheduledCompletableFutureOnce { private @Nullable volatile ScheduledCompletableFuture scheduledPromise; - private @Nullable String identifier; public ScheduledCompletableFutureRecurring(@Nullable String identifier, ZonedDateTime scheduledTime) { super(identifier, scheduledTime); diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/types/StateDescriptionFragmentImpl.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/types/StateDescriptionFragmentImpl.java index e719f799e..a3dae1750 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/types/StateDescriptionFragmentImpl.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/internal/types/StateDescriptionFragmentImpl.java @@ -21,7 +21,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.types.StateDescription; import org.openhab.core.types.StateDescriptionFragment; -import org.openhab.core.types.StateDescriptionFragmentBuilder; import org.openhab.core.types.StateOption; /** @@ -62,7 +61,7 @@ public class StateDescriptionFragmentImpl implements StateDescriptionFragment { * @param pattern pattern to render the state * @param readOnly if the state can be changed by the system * @param options predefined list of options - * @deprecated use {@link StateDescriptionFragmentBuilder} instead. + * @deprecated use {@link org.openhab.core.types.StateDescriptionFragmentBuilder} instead. */ @Deprecated public StateDescriptionFragmentImpl(@Nullable BigDecimal minimum, @Nullable BigDecimal maximum, @@ -81,7 +80,7 @@ public class StateDescriptionFragmentImpl implements StateDescriptionFragment { * Note: State options will only be set if not empty. * * @param legacy the {@link StateDescription} to initialize from. - * @deprecated use {@link StateDescriptionFragmentBuilder} instead. + * @deprecated use {@link org.openhab.core.types.StateDescriptionFragmentBuilder} instead. */ @Deprecated public StateDescriptionFragmentImpl(StateDescription legacy) { diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/GenericItem.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/GenericItem.java index 8d36cf9de..23c148964 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/GenericItem.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/GenericItem.java @@ -294,7 +294,7 @@ public abstract class GenericItem implements ActiveItem { Set clonedListeners = new CopyOnWriteArraySet<>(listeners); ExecutorService pool = ThreadPoolManager.getPool(ITEM_THREADPOOLNAME); try { - final boolean stateChanged = newState != null && !newState.equals(oldState); + final boolean stateChanged = !newState.equals(oldState); clonedListeners.forEach(listener -> pool.execute(() -> { try { listener.stateUpdated(GenericItem.this, newState); @@ -372,7 +372,7 @@ public abstract class GenericItem implements ActiveItem { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + name.hashCode(); return result; } @@ -388,11 +388,7 @@ public abstract class GenericItem implements ActiveItem { return false; } GenericItem other = (GenericItem) obj; - if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { + if (!name.equals(other.name)) { return false; } return true; diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/GroupItem.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/GroupItem.java index d6f6d0d1c..412b956b0 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/GroupItem.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/GroupItem.java @@ -223,7 +223,6 @@ public class GroupItem extends GenericItem implements StateChangeListener, Metad * @return the accepted data types of this group item */ @Override - @SuppressWarnings("unchecked") public List> getAcceptedDataTypes() { if (baseItem != null) { return baseItem.getAcceptedDataTypes(); @@ -249,7 +248,6 @@ public class GroupItem extends GenericItem implements StateChangeListener, Metad * @return the accepted command types of this group item */ @Override - @SuppressWarnings("unchecked") public List> getAcceptedCommandTypes() { if (baseItem != null) { return baseItem.getAcceptedCommandTypes(); @@ -315,9 +313,9 @@ public class GroupItem extends GenericItem implements StateChangeListener, Metad sb.append("Type="); sb.append(getClass().getSimpleName()); sb.append(", "); - if (getBaseItem() != null) { + if (getBaseItem() instanceof Item item) { sb.append("BaseType="); - sb.append(baseItem.getClass().getSimpleName()); + sb.append(item.getClass().getSimpleName()); sb.append(", "); } sb.append("Members="); diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/Item.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/Item.java index 57edff58e..243a5906c 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/Item.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/Item.java @@ -19,15 +19,10 @@ import java.util.Set; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.common.registry.Identifiable; -import org.openhab.core.library.types.OnOffType; -import org.openhab.core.library.types.PercentType; import org.openhab.core.types.Command; import org.openhab.core.types.CommandDescription; -import org.openhab.core.types.CommandOption; import org.openhab.core.types.State; import org.openhab.core.types.StateDescription; -import org.openhab.core.types.StateOption; -import org.openhab.core.types.UnDefType; /** *

@@ -75,14 +70,16 @@ public interface Item extends Identifiable { * This method provides a list of all data types that can be used to update the item state * *

- * Imagine e.g. a dimmer device: It's status could be 0%, 10%, 50%, 100%, but also OFF or ON and maybe UNDEFINED. So - * the accepted data types would be in this case {@link PercentType}, {@link OnOffType} and {@link UnDefType} + * Imagine e.g. a dimmer device: It's status could be 0%, 10%, 50%, 100%, but also OFF or ON and maybe + * UNDEFINED. So the accepted data types would be in this case {@link org.openhab.core.library.types.PercentType}, + * {@linkorg.openhab.core.library.types.OnOffType} and {@link org.openhab.core.types.UnDefType} * *

* The order of data types denotes the order of preference. So in case a state needs to be converted * in order to be accepted, it will be attempted to convert it to a type from top to bottom. Therefore * the type with the least information loss should be on top of the list - in the example above the - * {@link PercentType} carries more information than the {@link OnOffType}, hence it is listed first. + * {@link org.openhab.core.library.types.PercentType} carries more information than the + * {@linkorg.openhab.core.library.types.OnOffType}, hence it is listed first. * * @return a list of data types that can be used to update the item state */ @@ -93,8 +90,9 @@ public interface Item extends Identifiable { * This method provides a list of all command types that can be used for this item * *

- * Imagine e.g. a dimmer device: You could ask it to dim to 0%, 10%, 50%, 100%, but also to turn OFF or ON. So the - * accepted command types would be in this case {@link PercentType}, {@link OnOffType} + * Imagine e.g. a dimmer device: You could ask it to dim to 0%, 10%, 50%, 100%, but also to turn OFF or ON. + * So the accepted command types would be in this case {@link org.openhab.core.library.types.PercentType}, + * {@linkorg.openhab.core.library.types.OnOffType} * * * @return a list of all command types that can be used for this item @@ -160,8 +158,8 @@ public interface Item extends Identifiable { /** * Returns the {@link CommandDescription} for this item. In case no dedicated {@link CommandDescription} is - * provided the {@link StateOption}s from the {@link StateDescription} will be served as valid - * {@link CommandOption}s. + * provided the {@link org.openhab.core.types.StateOption}s from the {@link StateDescription} will be served + * as valid {@link org.openhab.core.types.CommandOption}s. * * @return the {@link CommandDescription} for the default locale (can be null). */ @@ -171,8 +169,9 @@ public interface Item extends Identifiable { /** * Returns the {@link CommandDescription} for the given locale. In case no dedicated {@link CommandDescription} is - * provided the {@link StateOption}s from the {@link StateDescription} will be served as valid - * {@link CommandOption}s. + * provided the {@link org.openhab.core.types.StateOption}s from the {@link StateDescription} will be served as + * valid + * {@link org.openhab.core.types.CommandOption}s. * * @param locale locale (can be null) * @return command description (can be null) diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/ItemProvider.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/ItemProvider.java index 0c0acf305..731c3c948 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/ItemProvider.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/ItemProvider.java @@ -12,7 +12,6 @@ */ package org.openhab.core.items; -import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.common.registry.Provider; @@ -24,6 +23,6 @@ import org.openhab.core.common.registry.Provider; * @author Kai Kreuzer - Initial contribution */ @NonNullByDefault -public interface ItemProvider extends Provider<@NonNull Item> { +public interface ItemProvider extends Provider { } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/ManagedMetadataProvider.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/ManagedMetadataProvider.java index 2fa1de135..01d8452df 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/ManagedMetadataProvider.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/ManagedMetadataProvider.java @@ -14,12 +14,11 @@ package org.openhab.core.items; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.common.registry.ManagedProvider; -import org.openhab.core.storage.StorageService; /** * {@link ManagedMetadataProvider} is an OSGi service interface that allows to add or remove * metadata for items at runtime. Persistence of added metadata is handled by - * a {@link StorageService}. + * a {@link org.openhab.core.storage.StorageService}. * * @author Kai Kreuzer - Initial contribution */ diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/dto/ItemDTOMapper.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/dto/ItemDTOMapper.java index da0b0b697..75e87fa9d 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/dto/ItemDTOMapper.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/dto/ItemDTOMapper.java @@ -46,13 +46,6 @@ public class ItemDTOMapper { * @return the item object */ public static @Nullable Item map(ItemDTO itemDTO, ItemBuilderFactory itemBuilderFactory) { - if (itemDTO == null) { - throw new IllegalArgumentException("The argument 'itemDTO' must no be null."); - } - if (itemBuilderFactory == null) { - throw new IllegalArgumentException("The argument 'itemBuilderFactory' must no be null."); - } - if (!ItemUtil.isValidItemName(itemDTO.name)) { throw new IllegalArgumentException("The item name '" + itemDTO.name + "' is invalid."); } diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/events/AbstractItemRegistryEvent.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/events/AbstractItemRegistryEvent.java index 49296fb05..bd321a758 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/items/events/AbstractItemRegistryEvent.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/items/events/AbstractItemRegistryEvent.java @@ -15,11 +15,11 @@ package org.openhab.core.items.events; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.core.events.AbstractEvent; -import org.openhab.core.items.ItemRegistry; import org.openhab.core.items.dto.ItemDTO; /** - * Abstract implementation of an item registry event which will be posted by the {@link ItemRegistry} for added, removed + * Abstract implementation of an item registry event which will be posted by the + * {@link org.openhab.core.items.ItemRegistry} for added, removed * and updated items. * * @author Stefan Bußweiler - Initial contribution diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/items/NumberItem.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/items/NumberItem.java index c5e8449f1..68252e6ad 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/items/NumberItem.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/items/NumberItem.java @@ -16,7 +16,6 @@ import java.util.List; import java.util.Locale; import java.util.Objects; -import javax.measure.Dimension; import javax.measure.Quantity; import javax.measure.Unit; @@ -130,9 +129,9 @@ public class NumberItem extends GenericItem implements MetadataAwareItem { } /** - * Returns the {@link Dimension} associated with this {@link NumberItem}, may be null. + * Returns the {@link javax.measure.Dimension} associated with this {@link NumberItem}, may be null. * - * @return the {@link Dimension} associated with this {@link NumberItem}, may be null. + * @return the {@link javax.measure.Dimension} associated with this {@link NumberItem}, may be null. */ public @Nullable Class> getDimension() { return dimension; diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/NextPreviousType.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/NextPreviousType.java index aeb7be207..bcbf1b9d8 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/NextPreviousType.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/NextPreviousType.java @@ -13,12 +13,11 @@ package org.openhab.core.library.types; import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.core.library.items.PlayerItem; import org.openhab.core.types.Command; import org.openhab.core.types.PrimitiveType; /** - * This type is used by the {@link PlayerItem}. + * This type is used by the {@link org.openhab.core.library.items.PlayerItem}. * * @author Alex Tugarev - Initial contribution */ diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/StringListType.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/StringListType.java index 6dc0b9698..3d0ee0018 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/StringListType.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/types/StringListType.java @@ -13,7 +13,6 @@ package org.openhab.core.library.types; import java.util.Arrays; -import java.util.Formatter; import java.util.List; import java.util.stream.Collectors; @@ -72,7 +71,7 @@ public class StringListType implements Command, State { /** *

* Formats the value of this type according to a pattern (@see - * {@link Formatter}). One single value of this type can be referenced + * {@link java.util.Formatter}). One single value of this type can be referenced * by the pattern using an index. The item order is defined by the natural * (alphabetical) order of their keys. * diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/net/CidrAddress.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/net/CidrAddress.java index 0bb98a137..a5d9e30a2 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/net/CidrAddress.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/net/CidrAddress.java @@ -13,7 +13,6 @@ package org.openhab.core.net; import java.net.InetAddress; -import java.net.InterfaceAddress; import java.util.Objects; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -26,7 +25,7 @@ import org.eclipse.jdt.annotation.Nullable; * The toString() method will return a CIRDR representation, but the individual * address and prefix length can be accessed as well. * - * Java has a class that exactly provides this {@link InterfaceAddress}, but unfortunately + * Java has a class that exactly provides this {@link java.net.InterfaceAddress}, but unfortunately * no public constructor exists. * * @author David Graeff - Initial contribution diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/net/NetUtil.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/net/NetUtil.java index 378934ceb..73e2e2fd8 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/net/NetUtil.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/net/NetUtil.java @@ -582,9 +582,6 @@ public class NetUtil implements NetworkAddressService { } private boolean getConfigParameter(Map parameters, String parameter, boolean defaultValue) { - if (parameters == null) { - return defaultValue; - } Object value = parameters.get(parameter); if (value == null) { return defaultValue; @@ -602,7 +599,7 @@ public class NetUtil implements NetworkAddressService { /** * For all network interfaces (except loopback) all IPv4 addresses are returned. * This list can for example, be used to scan the network for available devices. - * + * * @return A full list of IP {@link InetAddress} (except network and broadcast) */ public static List getFullRangeOfAddressesToScan() { @@ -619,7 +616,7 @@ public class NetUtil implements NetworkAddressService { /** * For the given {@link CidrAddress} all IPv4 addresses are returned. * This list can, for example, be used to scan the network for available devices. - * + * * @param iFaceAddress The {@link CidrAddress} of the network interface * @param maxAllowedPrefixLength Control the maximum allowed prefix length of the network (e.g. 24 for class C). * iFaceAddress's with a larger prefix are ignored and return an empty result. @@ -659,7 +656,7 @@ public class NetUtil implements NetworkAddressService { /** * Calculate each IP address within a subnet - * + * * @param address IPv4 address in byte array form (i.e. 127.0.0.1 = 01111111 00000000 00000000 00000001) * @param maskLength Network mask length (i.e. the number after the forward-slash, '/', in CIDR notation) * @return A list of all possible IP addresses in byte array form diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/scheduler/CronAdjuster.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/scheduler/CronAdjuster.java index 9ef077893..56fdd7fad 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/scheduler/CronAdjuster.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/scheduler/CronAdjuster.java @@ -16,7 +16,6 @@ import java.time.DayOfWeek; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.Temporal; -import java.time.temporal.TemporalAdjuster; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -31,7 +30,8 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; /** - * This class creates a {@link TemporalAdjuster} that takes a temporal and adjust it to the next deadline based on a + * This class creates a {@link java.time.temporal.TemporalAdjuster} that takes a temporal and adjust it to the next + * deadline based on a * cron specification. * * @See http://www.cronmaker.com/ diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/scheduler/Scheduler.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/scheduler/Scheduler.java index 17405e93b..2e09a52fc 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/scheduler/Scheduler.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/scheduler/Scheduler.java @@ -17,7 +17,6 @@ import java.time.Instant; import java.time.temporal.TemporalAdjuster; import java.util.concurrent.Callable; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeoutException; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @@ -79,7 +78,7 @@ public interface Scheduler { } /** - * Return a {@link ScheduledCompletableFuture} that fails with a {@link TimeoutException} + * Return a {@link ScheduledCompletableFuture} that fails with a {@link java.util.concurrent.TimeoutException} * when the given {@link CompletableFuture} is not resolved before the given timeout. If the * given {@link CompletableFuture} fails or is resolved before the timeout then the returned * {@link ScheduledCompletableFuture} will be treated accordingly. The cancellation does not influence diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/service/ReadyMarker.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/service/ReadyMarker.java index 4028d1407..12da2b957 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/service/ReadyMarker.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/service/ReadyMarker.java @@ -55,8 +55,8 @@ public final class ReadyMarker { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((identifier == null) ? 0 : identifier.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + identifier.hashCode(); + result = prime * result + type.hashCode(); return result; } @@ -72,18 +72,10 @@ public final class ReadyMarker { return false; } ReadyMarker other = (ReadyMarker) obj; - if (identifier == null) { - if (other.identifier != null) { - return false; - } - } else if (!identifier.equals(other.identifier)) { + if (!identifier.equals(other.identifier)) { return false; } - if (type == null) { - if (other.type != null) { - return false; - } - } else if (!type.equals(other.type)) { + if (!type.equals(other.type)) { return false; } return true; diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/types/Type.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/types/Type.java index 5d0ab1aef..65eebdced 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/types/Type.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/types/Type.java @@ -12,8 +12,6 @@ */ package org.openhab.core.types; -import java.util.Formatter; - import org.eclipse.jdt.annotation.NonNullByDefault; /** @@ -31,7 +29,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault; public interface Type { /** - * Formats the value of this type according to a pattern (see {@link Formatter}). + * Formats the value of this type according to a pattern (see {@link java.util.Formatter}). * * @param pattern the pattern to use * @return the formatted string diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/util/ColorUtil.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/util/ColorUtil.java index 1539c27fe..1702b8ca1 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/util/ColorUtil.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/util/ColorUtil.java @@ -48,7 +48,6 @@ public class ColorUtil { private static final BigDecimal BIG_DECIMAL_60 = BigDecimal.valueOf(60); private static final BigDecimal BIG_DECIMAL_5 = BigDecimal.valueOf(5); private static final BigDecimal BIG_DECIMAL_3 = BigDecimal.valueOf(3); - private static final BigDecimal BIG_DECIMAL_2 = BigDecimal.valueOf(2); private static final BigDecimal BIG_DECIMAL_2_POINT_55 = new BigDecimal("2.55"); private static final double[] CORM_COEFFICIENTS = { -0.00616793, 0.0893944, -0.5179722, 1.5317403, -2.4243787, 1.925865, -0.471106 }; @@ -531,7 +530,7 @@ public class ColorUtil { * * Duv describes the distance of a color point from the black body curve. It's useful for calculating * if a color is near to "white", at any color temperature. - * + * * @param xy array of double with CIE 1931 x,y in the range 0.0000 to 1.0000 * @return the calculated Duv metric * @throws IllegalArgumentException when input array has wrong size or exceeds allowed value range. @@ -1599,7 +1598,7 @@ public class ColorUtil { /** * Search the 'KELVIN_TO_XY_LOOKUP_TABLE' for the XY entry closest to the given colour temperature. * Uses a recursive 'QuickSearch' algorithm. - * + * * @param kelvin the colour temperature in K to find * @param min the first index in the lookup table * @param max the last index in the lookup table @@ -1625,7 +1624,7 @@ public class ColorUtil { * Convert a colour temperature in Kelvin to a point in the CIE XY colour space. * Uses a lookup table as described here. - * + * * @param kelvin the colour temperature in K to be converted * @return an array with the found CIE colour XY values * @throws IndexOutOfBoundsException if the colour temperature is out of range 2000K .. 6500K @@ -1648,7 +1647,7 @@ public class ColorUtil { *

* Note that McCamy's approximation is accurate to better than 1% from 2000 K to 10000 K * but below 2000 K the approximation error increases rapidly and exponentially. - * + * * @param xy an array with the CIE colour XY values to be converted * @return the colour temperature in K * @throws IllegalArgumentException if the wrong number of arguments is provided diff --git a/bundles/org.openhab.core/src/test/java/org/openhab/core/internal/i18n/I18nExceptionTest.java b/bundles/org.openhab.core/src/test/java/org/openhab/core/internal/i18n/I18nExceptionTest.java index 74eb4374e..fae80b5f5 100644 --- a/bundles/org.openhab.core/src/test/java/org/openhab/core/internal/i18n/I18nExceptionTest.java +++ b/bundles/org.openhab.core/src/test/java/org/openhab/core/internal/i18n/I18nExceptionTest.java @@ -24,13 +24,13 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.openhab.core.i18n.AbstractI18nException; import org.openhab.core.i18n.CommunicationException; import org.openhab.core.i18n.TranslationProvider; import org.osgi.framework.Bundle; /** - * The {@link I18nExceptionTest} tests all the functionalities of the {@link AbstractI18nException} class. + * The {@link I18nExceptionTest} tests all the functionalities of the + * {@link org.openhab.core.i18n.AbstractI18nException} class. * * @author Laurent Garnier - Initial contribution */ diff --git a/bundles/org.openhab.core/src/test/java/org/openhab/core/util/UIDUtilsTest.java b/bundles/org.openhab.core/src/test/java/org/openhab/core/util/UIDUtilsTest.java index 6a2f3793e..ba256caa9 100644 --- a/bundles/org.openhab.core/src/test/java/org/openhab/core/util/UIDUtilsTest.java +++ b/bundles/org.openhab.core/src/test/java/org/openhab/core/util/UIDUtilsTest.java @@ -19,10 +19,9 @@ import java.util.function.Consumer; import org.eclipse.jdt.annotation.NonNullByDefault; import org.hamcrest.core.IsEqual; import org.junit.jupiter.api.Test; -import org.openhab.core.common.AbstractUID; /** - * Tests for {@link AbstractUID}. + * Tests for {@link org.openhab.core.common.AbstractUID}. * * @author Markus Rathgeb - Initial contribution */