From 12e8edc03931ded800af688b04d826d2fda0bd2c Mon Sep 17 00:00:00 2001 From: Wouter Born Date: Fri, 11 Oct 2019 11:29:47 +0200 Subject: [PATCH] Use diamond operator (#1114) Signed-off-by: Wouter Born --- .../internal/RuleSupportScriptExtension.java | 13 ++- .../SimpleActionHandlerDelegate.java | 4 +- .../internal/loader/ScriptFileWatcher.java | 6 +- .../RuleSupportRuleRegistryDelegate.java | 3 +- .../shared/ScriptedAutomationManager.java | 20 ++-- .../shared/ScriptedRuleProvider.java | 5 +- .../rulesupport/shared/simple/SimpleRule.java | 6 +- .../internal/ScriptEngineManagerImpl.java | 9 +- .../internal/ScriptExtensionManager.java | 8 +- .../defaultscope/ItemRegistryDelegate.java | 2 +- .../internal/handler/ScriptActionHandler.java | 2 +- .../provider/ScriptModuleTypeProvider.java | 2 +- .../rest/internal/ModuleTypeResource.java | 2 +- .../core/automation/dto/ActionDTOMapper.java | 5 +- .../automation/dto/ActionTypeDTOMapper.java | 4 +- .../automation/dto/ConditionDTOMapper.java | 5 +- .../dto/ConditionTypeDTOMapper.java | 4 +- .../core/automation/dto/TriggerDTOMapper.java | 5 +- .../automation/dto/TriggerTypeDTOMapper.java | 4 +- .../automation/internal/RuleEngineImpl.java | 30 +++-- .../core/automation/internal/RuleImpl.java | 6 +- .../automation/internal/RuleRegistryImpl.java | 12 +- .../commands/AbstractCommandProvider.java | 6 +- .../commands/AutomationCommandList.java | 12 +- .../CommandlineModuleTypeProvider.java | 10 +- .../commands/CommandlineTemplateProvider.java | 10 +- .../automation/internal/commands/Printer.java | 43 ++++--- .../automation/internal/commands/Utils.java | 6 +- .../AbstractCompositeModuleHandler.java | 2 +- .../composite/CompositeActionHandler.java | 4 +- .../CompositeModuleHandlerFactory.java | 2 +- .../composite/CompositeTriggerHandler.java | 2 +- .../handler/CompareConditionHandler.java | 2 +- .../handler/GenericEventTriggerHandler.java | 2 +- .../handler/ItemCommandTriggerHandler.java | 2 +- .../handler/ItemStateTriggerHandler.java | 4 +- .../parser/gson/ModuleTypeGSONParser.java | 8 +- .../AbstractResourceBundleProvider.java | 22 ++-- .../AutomationResourceBundlesEventQueue.java | 6 +- .../AutomationResourceBundlesTracker.java | 6 +- .../provider/HostFragmentMappingUtil.java | 6 +- .../ModuleTypeResourceBundleProvider.java | 4 +- .../TemplateResourceBundleProvider.java | 4 +- .../provider/file/AbstractFileProvider.java | 14 +-- .../provider/file/ModuleTypeFileProvider.java | 4 +- .../provider/file/TemplateFileProvider.java | 2 +- .../provider/file/WatchServiceUtil.java | 4 +- .../provider/i18n/ModuleI18nUtil.java | 2 +- .../provider/i18n/ModuleTypeI18nUtil.java | 4 +- .../template/RuleTemplateRegistry.java | 6 +- .../internal/type/ModuleTypeRegistryImpl.java | 18 +-- .../util/ConfigurationNormalizer.java | 4 +- .../automation/util/ReferenceResolver.java | 2 +- .../core/automation/util/RuleBuilder.java | 6 +- ...nnotationActionModuleTypeProviderTest.java | 4 +- .../org/openhab/core/items/GenericItem.java | 2 +- .../core/library/items/StringItem.java | 2 +- .../QueryablePersistenceServiceDelegate.java | 3 +- .../config/core/ConfigDescription.java | 4 +- .../core/ConfigDescriptionParameter.java | 32 ++--- .../ConfigDescriptionParameterBuilder.java | 4 +- .../core/ConfigDescriptionRegistry.java | 17 ++- .../core/dto/ConfigDescriptionDTOMapper.java | 8 +- .../config/core/internal/ConfigMapper.java | 2 +- .../net/NetworkConfigOptionProvider.java | 3 +- .../normalization/NormalizerFactory.java | 2 +- .../core/ConfigDescriptionRegistryTest.java | 4 +- .../internal/DiscoveryResultImpl.java | 2 +- .../DiscoveryServiceRegistryImpl.java | 2 +- .../discovery/internal/PersistentInbox.java | 2 +- .../dispatch/internal/ConfigDispatcher.java | 4 +- .../config/xml/AbstractXmlBasedProvider.java | 2 +- .../xml/ConfigDescriptionConverter.java | 7 +- .../xml/osgi/XmlDocumentBundleTracker.java | 6 +- .../internal/ConsoleSupportEclipse.java | 4 +- .../rfc147/internal/ConsoleSupportRfc147.java | 2 +- .../io/console/ConsoleInterpreter.java | 2 +- .../io/http/servlet/BaseSmartHomeServlet.java | 2 +- .../core/config/ConfigurationService.java | 2 +- .../persistence/PersistenceResource.java | 2 +- .../core/persistence/ItemHistoryListDTO.java | 2 +- .../rest/core/thing/EnrichedChannelDTO.java | 3 +- .../io/rest/mdns/internal/MDNSAnnouncer.java | 2 +- .../sitemap/SitemapSubscriptionService.java | 2 +- .../sitemap/internal/PageChangeListener.java | 9 +- .../io/rest/sitemap/internal/PageDTO.java | 2 +- .../sitemap/internal/SitemapResource.java | 8 +- .../io/rest/sitemap/internal/WidgetDTO.java | 4 +- .../io/rest/sse/internal/util/SseUtil.java | 2 +- .../io/rest/voice/internal/HLIMapper.java | 2 +- .../rest/internal/resources/RootResource.java | 2 +- .../internal/resources/beans/RootBean.java | 2 +- .../transport/mqtt/MqttBrokerConnection.java | 14 +-- .../mqtt/internal/MqttServiceImpl.java | 2 +- .../serial/internal/SerialPortUtil.java | 2 +- .../upnp/internal/UpnpIOServiceImpl.java | 8 +- .../core/internal/ModelRepositoryImpl.java | 8 +- .../core/internal/folder/FolderObserver.java | 4 +- .../item/internal/GenericItemProvider.java | 8 +- .../internal/engine/RuleTriggerManager.java | 24 ++-- .../model/script/engine/ScriptException.java | 14 +-- .../ScriptImplicitlyImportedTypes.java | 3 +- ...nericThingProviderMultipleBundlesTest.java | 4 +- .../core/persistence/dto/ItemHistoryDTO.java | 2 +- .../json/internal/JsonStorageService.java | 3 +- .../handler/MagicChattyThingHandler.java | 4 +- .../test/storage/VolatileStorage.java | 2 +- .../test/storage/VolatileStorageService.java | 4 +- .../xml/internal/XmlThingTypeProvider.java | 2 +- .../eclipse/smarthome/core/thing/Channel.java | 11 +- .../binding/BaseThingHandlerFactory.java | 5 +- .../thing/binding/builder/ChannelBuilder.java | 2 +- .../profiles/SystemOffsetProfile.java | 3 +- .../core/thing/type/ChannelGroupType.java | 4 +- .../core/thing/type/ChannelType.java | 4 +- .../core/thing/util/ThingHelper.java | 9 +- .../profiles/SystemOffsetProfileTest.java | 12 +- .../AbstractFileTransformationService.java | 2 +- .../ui/internal/chart/ChartServlet.java | 4 +- .../DefaultChartProvider.java | 8 +- .../ui/internal/items/ItemUIRegistryImpl.java | 10 +- .../internal/proxy/ProxyServletService.java | 2 +- .../items/ItemUIRegistryImplTest.java | 8 +- .../core/voice/internal/DialogProcessor.java | 2 +- .../core/voice/internal/VoiceManagerImpl.java | 2 +- .../text/AbstractRuleBasedInterpreter.java | 89 +++++++------- .../smarthome/core/voice/text/Expression.java | 7 +- .../voice/text/ExpressionAlternatives.java | 4 +- .../voice/text/ExpressionCardinality.java | 8 +- .../core/voice/text/ExpressionIdentifier.java | 5 +- .../core/voice/text/ExpressionLet.java | 4 +- .../core/voice/text/ExpressionMatch.java | 4 +- .../core/voice/text/ExpressionSequence.java | 6 +- .../smarthome/core/voice/text/TokenList.java | 2 +- .../common/QueueingThreadPoolExecutor.java | 4 +- .../osgi/ResourceBundleClassLoader.java | 4 +- .../common/registry/AbstractProvider.java | 5 +- .../common/registry/AbstractRegistry.java | 4 +- .../common/SafeCallerBuilderImpl.java | 4 +- .../internal/events/OSGiEventPublisher.java | 2 +- .../i18n/LanguageResourceBundleManager.java | 2 +- .../internal/i18n/ResourceBundleTracker.java | 4 +- .../core/internal/items/ItemRegistryImpl.java | 10 +- .../core/internal/scheduler/CronAdjuster.java | 9 +- .../internal/scheduler/SchedulerImpl.java | 6 +- .../smarthome/core/items/GenericItem.java | 10 +- .../smarthome/core/items/GroupItem.java | 6 +- .../core/items/ManagedItemProvider.java | 2 +- .../core/items/dto/ItemDTOMapper.java | 2 +- .../core/items/events/ItemEventFactory.java | 2 +- .../core/library/items/CallItem.java | 4 +- .../core/library/items/ColorItem.java | 4 +- .../core/library/items/ContactItem.java | 4 +- .../core/library/items/DateTimeItem.java | 4 +- .../core/library/items/DimmerItem.java | 4 +- .../core/library/items/ImageItem.java | 4 +- .../core/library/items/LocationItem.java | 4 +- .../core/library/items/NumberItem.java | 4 +- .../core/library/items/PlayerItem.java | 4 +- .../core/library/items/RollershutterItem.java | 4 +- .../core/library/items/StringItem.java | 6 +- .../core/library/items/SwitchItem.java | 4 +- .../eclipse/smarthome/core/net/NetUtil.java | 2 +- .../core/types/EventDescription.java | 4 +- .../osgi/ResourceBundleClassLoaderTest.java | 4 +- .../internal/i18n/I18nProviderImplTest.java | 2 +- .../core/library/items/StateUtil.java | 7 +- .../types/ArithmeticGroupFunctionTest.java | 2 +- .../types/DateTimeGroupFunctionTest.java | 2 +- .../core/library/types/DateTimeTypeTest.java | 2 +- ...antityTypeArithmeticGroupFunctionTest.java | 110 +++++++++--------- .../core/library/types/QuantityTypeTest.java | 8 +- .../core/library/unit/SmartHomeUnitsTest.java | 2 +- .../test/internal/cipher/CipherTest.java | 2 +- .../automation/internal/RuleEngineTest.java | 24 ++-- .../internal/TestModuleTypeProvider.java | 12 +- .../core/ConfigOptionRegistryOSGiTest.java | 2 +- .../discovery/internal/InboxOSGiTest.java | 18 +-- .../persistence/PersistenceResourceTest.java | 5 +- .../tests/TestPersistenceService.java | 3 +- .../script/lib/NumberExtensionsTest.java | 19 ++- .../hue/DumbThingTypeProvider.java | 2 +- .../hue/TestHueThingTypeProvider.java | 2 +- .../core/cache/ExpiringCacheAsyncTest.java | 11 +- .../internal/items/ItemUpdaterOSGiTest.java | 2 +- .../core/items/GroupItemOSGiTest.java | 26 ++--- .../binding/ChangeThingTypeOSGiTest.java | 3 +- .../thing/internal/ThingRegistryOSGiTest.java | 2 +- .../firmware/FirmwareUpdateServiceTest.java | 2 +- .../core/voice/internal/AudioSourceStub.java | 10 +- .../core/voice/internal/KSServiceStub.java | 16 +-- .../core/voice/internal/TTSServiceStub.java | 18 +-- .../javavoicemanager/VoiceManagerTest.java | 6 +- .../InterpretCommandTest.java | 2 +- .../SayCommandTest.java | 2 +- 195 files changed, 665 insertions(+), 672 deletions(-) diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/RuleSupportScriptExtension.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/RuleSupportScriptExtension.java index 04423acc2..63646df30 100644 --- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/RuleSupportScriptExtension.java +++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/RuleSupportScriptExtension.java @@ -18,6 +18,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.eclipse.smarthome.config.core.ConfigDescriptionParameter; @@ -61,10 +62,10 @@ public class RuleSupportScriptExtension implements ScriptExtensionProvider { private static final String RULE_REGISTRY = "ruleRegistry"; private static final String AUTOMATION_MANAGER = "automationManager"; - private static HashMap> presets = new HashMap<>(); - private static HashMap staticTypes = new HashMap<>(); - private static HashSet types = new HashSet(); - private final ConcurrentHashMap> objectCache = new ConcurrentHashMap<>(); + private static Map> presets = new HashMap<>(); + private static Map staticTypes = new HashMap<>(); + private static Set types = new HashSet<>(); + private final Map> objectCache = new ConcurrentHashMap<>(); private RuleRegistry ruleRegistry; private ScriptedRuleProvider ruleProvider; @@ -180,7 +181,7 @@ public class RuleSupportScriptExtension implements ScriptExtensionProvider { return obj; } - HashMap objects = objectCache.get(scriptIdentifier); + Map objects = objectCache.get(scriptIdentifier); if (objects == null) { objects = new HashMap<>(); @@ -230,7 +231,7 @@ public class RuleSupportScriptExtension implements ScriptExtensionProvider { @Override public void unload(String scriptIdentifier) { - HashMap objects = objectCache.remove(scriptIdentifier); + Map objects = objectCache.remove(scriptIdentifier); if (objects != null) { Object hr = objects.get(AUTOMATION_MANAGER); diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleActionHandlerDelegate.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleActionHandlerDelegate.java index 015c01730..18ba81cf1 100644 --- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleActionHandlerDelegate.java +++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/delegates/SimpleActionHandlerDelegate.java @@ -42,7 +42,7 @@ public class SimpleActionHandlerDelegate extends BaseActionModuleHandler { @Override public Map execute(Map inputs) { - Set keys = new HashSet(inputs.keySet()); + Set keys = new HashSet<>(inputs.keySet()); Map extendedInputs = new HashMap<>(inputs); for (String key : keys) { @@ -57,7 +57,7 @@ public class SimpleActionHandlerDelegate extends BaseActionModuleHandler { } Object result = actionHandler.execute(module, extendedInputs); - HashMap resultMap = new HashMap(); + Map resultMap = new HashMap<>(); resultMap.put("result", result); return resultMap; } diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/ScriptFileWatcher.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/ScriptFileWatcher.java index c2cff7a91..7651acab8 100644 --- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/ScriptFileWatcher.java +++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/internal/loader/ScriptFileWatcher.java @@ -58,7 +58,7 @@ public class ScriptFileWatcher extends AbstractWatchService { private final long earliestStart = System.currentTimeMillis() + INITIAL_DELAY * 1000; private ScriptEngineManager manager; - ScheduledExecutorService scheduler; + private ScheduledExecutorService scheduler; private final Map> urlsByScriptExtension = new ConcurrentHashMap<>(); private final Set loaded = new HashSet<>(); @@ -204,7 +204,7 @@ public class ScriptFileWatcher extends AbstractWatchService { synchronized (urlsByScriptExtension) { Set set = urlsByScriptExtension.get(scriptType); if (set == null) { - set = new HashSet(); + set = new HashSet<>(); urlsByScriptExtension.put(scriptType, set); } set.add(url); @@ -267,7 +267,7 @@ public class ScriptFileWatcher extends AbstractWatchService { }); synchronized (urlsByScriptExtension) { - HashSet newlySupported = new HashSet<>(); + Set newlySupported = new HashSet<>(); for (String key : urlsByScriptExtension.keySet()) { if (manager.isSupported(key)) { newlySupported.add(key); diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/RuleSupportRuleRegistryDelegate.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/RuleSupportRuleRegistryDelegate.java index 3f3e994b4..45ef1f2ec 100644 --- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/RuleSupportRuleRegistryDelegate.java +++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/RuleSupportRuleRegistryDelegate.java @@ -14,6 +14,7 @@ package org.openhab.core.automation.module.script.rulesupport.shared; import java.util.Collection; import java.util.HashSet; +import java.util.Set; import java.util.stream.Stream; import org.eclipse.smarthome.core.common.registry.RegistryChangeListener; @@ -30,7 +31,7 @@ import org.openhab.core.automation.RuleRegistry; public class RuleSupportRuleRegistryDelegate implements RuleRegistry { private final RuleRegistry ruleRegistry; - private final HashSet rules = new HashSet<>(); + private final Set rules = new HashSet<>(); private final ScriptedRuleProvider ruleProvider; diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedAutomationManager.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedAutomationManager.java index 62e9f8181..fa8819e66 100644 --- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedAutomationManager.java +++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedAutomationManager.java @@ -14,6 +14,8 @@ package org.openhab.core.automation.module.script.rulesupport.shared; import java.util.ArrayList; import java.util.HashSet; +import java.util.List; +import java.util.Set; import org.eclipse.smarthome.config.core.Configuration; import org.openhab.core.automation.Action; @@ -48,9 +50,9 @@ public class ScriptedAutomationManager { private final RuleSupportRuleRegistryDelegate ruleRegistryDelegate; - private final HashSet modules = new HashSet<>(); - private final HashSet moduleHandlers = new HashSet<>(); - private final HashSet privateHandlers = new HashSet<>(); + private final Set modules = new HashSet<>(); + private final Set moduleHandlers = new HashSet<>(); + private final Set privateHandlers = new HashSet<>(); private final ScriptedCustomModuleHandlerFactory scriptedCustomModuleHandlerFactory; private final ScriptedCustomModuleTypeProvider scriptedCustomModuleTypeProvider; @@ -88,17 +90,17 @@ public class ScriptedAutomationManager { public void removeAll() { logger.info("removeAll added handlers"); - HashSet types = new HashSet<>(modules); + Set types = new HashSet<>(modules); for (String moduleType : types) { removeModuleType(moduleType); } - HashSet moduleHandlers = new HashSet<>(this.moduleHandlers); + Set moduleHandlers = new HashSet<>(this.moduleHandlers); for (String uid : moduleHandlers) { removeHandler(uid); } - HashSet privateHandlers = new HashSet<>(this.privateHandlers); + Set privateHandlers = new HashSet<>(this.privateHandlers); for (String privId : privateHandlers) { removePrivateHandler(privId); } @@ -123,7 +125,7 @@ public class ScriptedAutomationManager { int moduleIndex = 1; try { - ArrayList conditions = new ArrayList<>(); + List conditions = new ArrayList<>(); for (Condition cond : element.getConditions()) { Condition toAdd = cond; if (cond.getId().isEmpty()) { @@ -141,7 +143,7 @@ public class ScriptedAutomationManager { } try { - ArrayList triggers = new ArrayList<>(); + List triggers = new ArrayList<>(); for (Trigger trigger : element.getTriggers()) { Trigger toAdd = trigger; if (trigger.getId().isEmpty()) { @@ -157,7 +159,7 @@ public class ScriptedAutomationManager { // triggers are optional } - ArrayList actions = new ArrayList<>(); + List actions = new ArrayList<>(); actions.addAll(element.getActions()); if (element instanceof SimpleRuleActionHandler) { diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedRuleProvider.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedRuleProvider.java index aaacaa0f6..5df78a559 100644 --- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedRuleProvider.java +++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/ScriptedRuleProvider.java @@ -15,6 +15,7 @@ package org.openhab.core.automation.module.script.rulesupport.shared; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.Map; import org.eclipse.smarthome.core.common.registry.ProviderChangeListener; import org.openhab.core.automation.Rule; @@ -29,9 +30,9 @@ import org.osgi.service.component.annotations.Component; */ @Component(immediate = true, service = { ScriptedRuleProvider.class, RuleProvider.class }) public class ScriptedRuleProvider implements RuleProvider { - private final Collection> listeners = new ArrayList>(); + private final Collection> listeners = new ArrayList<>(); - HashMap rules = new HashMap<>(); + private final Map rules = new HashMap<>(); @Override public void addProviderChangeListener(ProviderChangeListener listener) { diff --git a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRule.java b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRule.java index bde680819..a1b34cb5d 100644 --- a/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRule.java +++ b/bundles/org.openhab.core.automation.module.script.rulesupport/src/main/java/org/openhab/core/automation/module/script/rulesupport/shared/simple/SimpleRule.java @@ -208,13 +208,11 @@ public abstract class SimpleRule implements Rule, SimpleRuleActionHandler { @Override public List getModules() { - final List result; - List modules = new ArrayList(); + List modules = new ArrayList<>(); modules.addAll(triggers); modules.addAll(conditions); modules.addAll(actions); - result = Collections.unmodifiableList(modules); - return result; + return Collections.unmodifiableList(modules); } @SuppressWarnings("unchecked") diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineManagerImpl.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineManagerImpl.java index fdc729706..17a820efc 100644 --- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineManagerImpl.java +++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptEngineManagerImpl.java @@ -15,6 +15,7 @@ package org.openhab.core.automation.module.script.internal; import java.io.InputStreamReader; import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.script.Invocable; import javax.script.ScriptEngine; @@ -43,9 +44,9 @@ import org.slf4j.LoggerFactory; public class ScriptEngineManagerImpl implements ScriptEngineManager { private final Logger logger = LoggerFactory.getLogger(this.getClass()); - private HashMap loadedScriptEngineInstances = new HashMap<>(); - private HashMap customSupport = new HashMap<>(); - private HashMap genericSupport = new HashMap<>(); + private Map loadedScriptEngineInstances = new HashMap<>(); + private Map customSupport = new HashMap<>(); + private Map genericSupport = new HashMap<>(); private @NonNullByDefault({}) ScriptExtensionManager scriptExtensionManager; @Reference @@ -113,7 +114,7 @@ public class ScriptEngineManagerImpl implements ScriptEngineManager { try { ScriptEngine engine = engineFactory.createScriptEngine(scriptType); if (engine != null) { - HashMap scriptExManager = new HashMap<>(); + Map scriptExManager = new HashMap<>(); result = new ScriptEngineContainer(engine, engineFactory, engineIdentifier); ScriptExtensionManagerWrapper wrapper = new ScriptExtensionManagerWrapper(scriptExtensionManager, result); diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptExtensionManager.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptExtensionManager.java index a378cecd7..9d59388ba 100644 --- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptExtensionManager.java +++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/ScriptExtensionManager.java @@ -34,7 +34,7 @@ import org.osgi.service.component.annotations.ReferencePolicy; */ @Component(service = ScriptExtensionManager.class) public class ScriptExtensionManager { - private Set scriptExtensionProviders = new CopyOnWriteArraySet(); + private Set scriptExtensionProviders = new CopyOnWriteArraySet<>(); @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) public void addScriptExtensionProvider(ScriptExtensionProvider provider) { @@ -54,7 +54,7 @@ public class ScriptExtensionManager { } public List getTypes() { - ArrayList types = new ArrayList<>(); + List types = new ArrayList<>(); for (ScriptExtensionProvider provider : scriptExtensionProviders) { types.addAll(provider.getTypes()); @@ -64,7 +64,7 @@ public class ScriptExtensionManager { } public List getPresets() { - ArrayList presets = new ArrayList<>(); + List presets = new ArrayList<>(); for (ScriptExtensionProvider provider : scriptExtensionProviders) { presets.addAll(provider.getPresets()); @@ -84,7 +84,7 @@ public class ScriptExtensionManager { } public List getDefaultPresets() { - ArrayList defaultPresets = new ArrayList<>(); + List defaultPresets = new ArrayList<>(); for (ScriptExtensionProvider provider : scriptExtensionProviders) { defaultPresets.addAll(provider.getDefaultPresets()); diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ItemRegistryDelegate.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ItemRegistryDelegate.java index ca8b63ba4..6d87a2654 100644 --- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ItemRegistryDelegate.java +++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/defaultscope/ItemRegistryDelegate.java @@ -113,7 +113,7 @@ public class ItemRegistryDelegate implements Map { @Override public Set> entrySet() { - Set> entries = new HashSet>(); + Set> entries = new HashSet<>(); for (Item item : itemRegistry.getAll()) { entries.add(new AbstractMap.SimpleEntry<>(item.getName(), item.getState())); } diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/ScriptActionHandler.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/ScriptActionHandler.java index acbb62784..542396520 100644 --- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/ScriptActionHandler.java +++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/handler/ScriptActionHandler.java @@ -54,7 +54,7 @@ public class ScriptActionHandler extends AbstractScriptModuleHandler imp @Override public @Nullable Map execute(final Map context) { - HashMap resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); getScriptEngine().ifPresent(scriptEngine -> { setExecutionContext(scriptEngine, context); diff --git a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/provider/ScriptModuleTypeProvider.java b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/provider/ScriptModuleTypeProvider.java index d8553c6c1..d4431e317 100755 --- a/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/provider/ScriptModuleTypeProvider.java +++ b/bundles/org.openhab.core.automation.module.script/src/main/java/org/openhab/core/automation/module/script/internal/provider/ScriptModuleTypeProvider.java @@ -71,7 +71,7 @@ public class ScriptModuleTypeProvider implements ModuleTypeProvider { if (parameterOptions.isEmpty()) { return null; } else { - List outputs = new ArrayList(); + List outputs = new ArrayList<>(); Output result = new Output("result", "java.lang.Object", "result", "the script result", null, null, null); outputs.add(result); diff --git a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ModuleTypeResource.java b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ModuleTypeResource.java index fb85555d4..ff0f81b64 100644 --- a/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ModuleTypeResource.java +++ b/bundles/org.openhab.core.automation.rest/src/main/java/org/openhab/core/automation/rest/internal/ModuleTypeResource.java @@ -99,7 +99,7 @@ public class ModuleTypeResource implements RESTResource { @QueryParam("type") @ApiParam(value = "filtering by action, condition or trigger", required = false) String type) { final Locale locale = localeService.getLocale(language); final String[] tags = tagList != null ? tagList.split(",") : null; - final List modules = new ArrayList(); + final List modules = new ArrayList<>(); if (type == null || type.equals("trigger")) { modules.addAll(TriggerTypeDTOMapper.map(moduleTypeRegistry.getTriggers(locale, tags))); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionDTOMapper.java index 1764e7b81..5664158b7 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionDTOMapper.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionDTOMapper.java @@ -18,7 +18,6 @@ import java.util.List; import org.eclipse.smarthome.config.core.Configuration; import org.openhab.core.automation.Action; -import org.openhab.core.automation.dto.ActionDTO; import org.openhab.core.automation.util.ModuleBuilder; /** @@ -46,7 +45,7 @@ public class ActionDTOMapper extends ModuleDTOMapper { if (actions == null) { return null; } - final List dtos = new ArrayList(actions.size()); + final List dtos = new ArrayList<>(actions.size()); for (final Action action : actions) { dtos.add(map(action)); } @@ -57,7 +56,7 @@ public class ActionDTOMapper extends ModuleDTOMapper { if (dtos == null) { return null; } - final List actions = new ArrayList(dtos.size()); + final List actions = new ArrayList<>(dtos.size()); for (final ActionDTO dto : dtos) { actions.add(mapDto(dto)); } diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionTypeDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionTypeDTOMapper.java index e6912fbe1..438b7592d 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionTypeDTOMapper.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ActionTypeDTOMapper.java @@ -17,8 +17,6 @@ import java.util.Collection; import java.util.List; import org.eclipse.smarthome.config.core.dto.ConfigDescriptionDTOMapper; -import org.openhab.core.automation.dto.ActionTypeDTO; -import org.openhab.core.automation.dto.CompositeActionTypeDTO; import org.openhab.core.automation.type.ActionType; import org.openhab.core.automation.type.CompositeActionType; @@ -57,7 +55,7 @@ public class ActionTypeDTOMapper extends ModuleTypeDTOMapper { if (types == null) { return null; } - final List dtos = new ArrayList(types.size()); + final List dtos = new ArrayList<>(types.size()); for (final ActionType type : types) { if (type instanceof CompositeActionType) { dtos.add(map((CompositeActionType) type)); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionDTOMapper.java index b0ce6ed12..1efa638b9 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionDTOMapper.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionDTOMapper.java @@ -17,7 +17,6 @@ import java.util.List; import org.eclipse.smarthome.config.core.Configuration; import org.openhab.core.automation.Condition; -import org.openhab.core.automation.dto.ConditionDTO; import org.openhab.core.automation.util.ModuleBuilder; /** @@ -45,7 +44,7 @@ public class ConditionDTOMapper extends ModuleDTOMapper { if (conditions == null) { return null; } - final List dtos = new ArrayList(conditions.size()); + final List dtos = new ArrayList<>(conditions.size()); for (final Condition action : conditions) { dtos.add(map(action)); } @@ -56,7 +55,7 @@ public class ConditionDTOMapper extends ModuleDTOMapper { if (dtos == null) { return null; } - final List conditions = new ArrayList(dtos.size()); + final List conditions = new ArrayList<>(dtos.size()); for (final ConditionDTO dto : dtos) { conditions.add(mapDto(dto)); } diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionTypeDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionTypeDTOMapper.java index 28b9ddad6..f755dc2c7 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionTypeDTOMapper.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/ConditionTypeDTOMapper.java @@ -17,8 +17,6 @@ import java.util.Collection; import java.util.List; import org.eclipse.smarthome.config.core.dto.ConfigDescriptionDTOMapper; -import org.openhab.core.automation.dto.CompositeConditionTypeDTO; -import org.openhab.core.automation.dto.ConditionTypeDTO; import org.openhab.core.automation.type.CompositeConditionType; import org.openhab.core.automation.type.ConditionType; @@ -58,7 +56,7 @@ public class ConditionTypeDTOMapper extends ModuleTypeDTOMapper { if (types == null) { return null; } - final List dtos = new ArrayList(types.size()); + final List dtos = new ArrayList<>(types.size()); for (final ConditionType type : types) { if (type instanceof CompositeConditionType) { dtos.add(map((CompositeConditionType) type)); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerDTOMapper.java index 7fbc80208..12eb5dcf9 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerDTOMapper.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerDTOMapper.java @@ -18,7 +18,6 @@ import java.util.List; import org.eclipse.smarthome.config.core.Configuration; import org.openhab.core.automation.Trigger; -import org.openhab.core.automation.dto.TriggerDTO; import org.openhab.core.automation.util.ModuleBuilder; /** @@ -45,7 +44,7 @@ public class TriggerDTOMapper extends ModuleDTOMapper { if (triggers == null) { return null; } - final List dtos = new ArrayList(triggers.size()); + final List dtos = new ArrayList<>(triggers.size()); for (final Trigger trigger : triggers) { dtos.add(map(trigger)); } @@ -56,7 +55,7 @@ public class TriggerDTOMapper extends ModuleDTOMapper { if (dtos == null) { return null; } - final List triggers = new ArrayList(dtos.size()); + final List triggers = new ArrayList<>(dtos.size()); for (final TriggerDTO dto : dtos) { triggers.add(mapDto(dto)); } diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerTypeDTOMapper.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerTypeDTOMapper.java index 9c1b9e27a..9d5652243 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerTypeDTOMapper.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/dto/TriggerTypeDTOMapper.java @@ -17,8 +17,6 @@ import java.util.Collection; import java.util.List; import org.eclipse.smarthome.config.core.dto.ConfigDescriptionDTOMapper; -import org.openhab.core.automation.dto.CompositeTriggerTypeDTO; -import org.openhab.core.automation.dto.TriggerTypeDTO; import org.openhab.core.automation.type.CompositeTriggerType; import org.openhab.core.automation.type.TriggerType; @@ -57,7 +55,7 @@ public class TriggerTypeDTOMapper extends ModuleTypeDTOMapper { if (types == null) { return null; } - final List dtos = new ArrayList(types.size()); + final List dtos = new ArrayList<>(types.size()); for (final TriggerType type : types) { if (type instanceof CompositeTriggerType) { dtos.add(map((CompositeTriggerType) type)); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java index f33fc35e8..95c833d78 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleEngineImpl.java @@ -131,13 +131,13 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener thCallbacks = new HashMap(); + private final @NonNullByDefault({}) Map thCallbacks = new HashMap<>(); /** * {@link Map} holding all {@link ModuleType} UIDs that are available in some rule's module definition. The relation * is {@link ModuleType}'s UID to {@link Set} of {@link Rule} UIDs. */ - private final @NonNullByDefault({}) Map> mapModuleTypeToRules = new HashMap>(); + private final @NonNullByDefault({}) Map> mapModuleTypeToRules = new HashMap<>(); /** * {@link Map} holding all available {@link ModuleHandlerFactory}s linked with {@link ModuleType}s that they @@ -251,8 +251,8 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener>(); - this.moduleHandlerFactories = new HashMap(20); + this.contextMap = new HashMap<>(); + this.moduleHandlerFactories = new HashMap<>(20); this.disabledRulesStorage = storageService. getStorage(DISABLED_RULE_STORAGE, this.getClass().getClassLoader()); @@ -334,7 +334,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener rulesPerModule = mapModuleTypeToRules.get(moduleTypeName); if (rulesPerModule != null) { - rules = new HashSet(); + rules = new HashSet<>(); rules.addAll(rulesPerModule); } } @@ -363,7 +363,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener rulesPerModule = mapModuleTypeToRules.get(moduleTypeName); if (rulesPerModule != null) { - rules = new HashSet(); + rules = new HashSet<>(); rules.addAll(rulesPerModule); } } @@ -400,7 +400,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener rulesPerModule = mapModuleTypeToRules.get(moduleTypeName); if (rulesPerModule != null) { - rules = new HashSet(); + rules = new HashSet<>(); rules.addAll(rulesPerModule); } } @@ -408,8 +408,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener(20); + notInitializedRules = notInitializedRules != null ? notInitializedRules : new HashSet<>(20); notInitializedRules.add(rUID); } } @@ -743,7 +742,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener rules = mapModuleTypeToRules.get(moduleTypeId); if (rules == null) { - rules = new HashSet(11); + rules = new HashSet<>(11); } rules.add(rUID); mapModuleTypeToRules.put(moduleTypeId, rules); @@ -933,11 +932,10 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener>(20); + mapMissingHandlers = mapMissingHandlers != null ? mapMissingHandlers : new HashMap<>(20); List list = mapMissingHandlers.get(rUID); if (list == null) { - list = new ArrayList(5); + list = new ArrayList<>(5); } list.add(moduleTypeName); mapMissingHandlers.put(rUID, list); @@ -1101,7 +1099,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener context = contextMap.get(ruleUID); if (context == null) { - context = new HashMap(); + context = new HashMap<>(); contextMap.put(ruleUID, context); } if (connections != null) { @@ -1264,7 +1262,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener, OutputRef> triggerOutputTags = new HashMap, OutputRef>(11); + Map, OutputRef> triggerOutputTags = new HashMap<>(11); for (WrappedTrigger mt : rule.getTriggers()) { final Trigger t = mt.unwrap(); TriggerType tt = (TriggerType) mtRegistry.get(t.getTypeUID()); @@ -1272,7 +1270,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener, OutputRef> actionOutputTags = new HashMap, OutputRef>(11); + Map, OutputRef> actionOutputTags = new HashMap<>(11); for (WrappedAction ma : rule.getActions()) { final Action a = ma.unwrap(); ActionType at = (ActionType) mtRegistry.get(a.getTypeUID()); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleImpl.java index 294e5e698..c0cff4888 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleImpl.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleImpl.java @@ -258,13 +258,11 @@ public class RuleImpl implements Rule { @Override public List getModules() { - final List result; - List modules = new ArrayList(); + List modules = new ArrayList<>(); modules.addAll(triggers); modules.addAll(conditions); modules.addAll(actions); - result = Collections.unmodifiableList(modules); - return result; + return Collections.unmodifiableList(modules); } @Override diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleRegistryImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleRegistryImpl.java index 061b1c80f..123297176 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleRegistryImpl.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/RuleRegistryImpl.java @@ -113,7 +113,7 @@ public class RuleRegistryImpl extends AbstractRegistry> mapTemplateToRules = new HashMap>(); + private final Map> mapTemplateToRules = new HashMap<>(); /** * Constructor that is responsible to invoke the super constructor with appropriate providerClazz @@ -292,7 +292,7 @@ public class RuleRegistryImpl extends AbstractRegistry getByTag(String tag) { - Collection result = new LinkedList(); + Collection result = new LinkedList<>(); if (tag == null) { forEach(result::add); } else { @@ -307,8 +307,8 @@ public class RuleRegistryImpl extends AbstractRegistry getByTags(String... tags) { - Set tagSet = tags != null ? new HashSet(Arrays.asList(tags)) : null; - Collection result = new LinkedList(); + Set tagSet = tags != null ? new HashSet<>(Arrays.asList(tags)) : null; + Collection result = new LinkedList<>(); if (tagSet == null || tagSet.isEmpty()) { forEach(result::add); } else { @@ -364,7 +364,7 @@ public class RuleRegistryImpl extends AbstractRegistry ruleUIDs = mapTemplateToRules.get(templateUID); if (ruleUIDs == null) { - ruleUIDs = new HashSet(); + ruleUIDs = new HashSet<>(); mapTemplateToRules.put(templateUID, ruleUIDs); } if (resolved) { @@ -615,7 +615,7 @@ public class RuleRegistryImpl extends AbstractRegistry rules = new HashSet(); + Set rules = new HashSet<>(); synchronized (this) { Set rulesForResolving = mapTemplateToRules.get(templateUID); if (rulesForResolving != null) { diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AbstractCommandProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AbstractCommandProvider.java index 4da820672..6073b449d 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AbstractCommandProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AbstractCommandProvider.java @@ -59,7 +59,7 @@ public abstract class AbstractCommandProvider implements ServiceTrackerCustom *

* The Map has for keys - {@link URL} resource provider and for values - Lists with UIDs of the objects. */ - Map> providerPortfolio = new HashMap>(); + Map> providerPortfolio = new HashMap<>(); /** * This field is a {@link ServiceTracker} for {@link Parser} services. @@ -70,7 +70,7 @@ public abstract class AbstractCommandProvider implements ServiceTrackerCustom * This Map provides structure for fast access to the {@link Parser}s. This provides opportunity for high * performance at runtime of the system. */ - protected Map> parsers = new HashMap>(); + protected Map> parsers = new HashMap<>(); /** * This Map provides structure for fast access to the provided automation objects. This provides opportunity for @@ -79,7 +79,7 @@ public abstract class AbstractCommandProvider implements ServiceTrackerCustom *

* The Map has for keys UIDs of the objects and for values {@link Localizer}s of the objects. */ - protected Map providedObjectsHolder = new HashMap(); + protected Map providedObjectsHolder = new HashMap<>(); protected List> listeners; diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandList.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandList.java index 92af36808..5523c71f4 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandList.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/AutomationCommandList.java @@ -145,7 +145,7 @@ public class AutomationCommandList extends AutomationCommand { */ private String listRules() { Collection collection = autoCommands.getRules(); - Map rules = new Hashtable(); + Map rules = new Hashtable<>(); Map listRules = null; if (collection != null && !collection.isEmpty()) { addCollection(collection, rules); @@ -187,7 +187,7 @@ public class AutomationCommandList extends AutomationCommand { */ private String listTemplates() { Collection collection = autoCommands.getTemplates(locale); - Map templates = new Hashtable(); + Map templates = new Hashtable<>(); Map listTemplates = null; if (collection != null && !collection.isEmpty()) { addCollection(collection, templates); @@ -229,7 +229,7 @@ public class AutomationCommandList extends AutomationCommand { * command {@link AutomationCommands#LIST_MODULE_TYPES}. */ private String listModuleTypes() { - Map moduleTypes = new Hashtable(); + Map moduleTypes = new Hashtable<>(); Collection collection = autoCommands.getTriggers(locale); addCollection(collection, moduleTypes); collection = autoCommands.getConditions(locale); @@ -276,7 +276,7 @@ public class AutomationCommandList extends AutomationCommand { * @return a collection of {@link Rule}s that match the filter. */ private Collection getRuleByFilter(Map list) { - Collection rules = new ArrayList(); + Collection rules = new ArrayList<>(); if (!list.isEmpty()) { Rule r = null; String uid = list.get(id); @@ -312,7 +312,7 @@ public class AutomationCommandList extends AutomationCommand { * @return a collection of {@link Template}s that match the filter. */ private Collection getTemplateByFilter(Map list) { - Collection templates = new ArrayList(); + Collection templates = new ArrayList<>(); RuleTemplate t = null; String uid = list.get(id); if (uid != null) { @@ -346,7 +346,7 @@ public class AutomationCommandList extends AutomationCommand { * @return a collection of {@link ModuleType}s that match the filter. */ private Collection getModuleTypeByFilter(Map list) { - Collection moduleTypes = new ArrayList(); + Collection moduleTypes = new ArrayList<>(); if (!list.isEmpty()) { ModuleType mt = null; String uid = list.get(id); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineModuleTypeProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineModuleTypeProvider.java index b553ee5ad..8c7b2ed54 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineModuleTypeProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineModuleTypeProvider.java @@ -74,7 +74,7 @@ public class CommandlineModuleTypeProvider extends AbstractCommandProvider>(); + listeners = new LinkedList<>(); mtpReg = bc.registerService(ModuleTypeProvider.class.getName(), this, null); this.moduleTypeRegistry = moduleTypeRegistry; } @@ -188,13 +188,13 @@ public class CommandlineModuleTypeProvider extends AbstractCommandProvider providedObjects = parser.parse(inputStreamReader); if (providedObjects != null && !providedObjects.isEmpty()) { String uid = null; - List portfolio = new ArrayList(); + List portfolio = new ArrayList<>(); synchronized (providerPortfolio) { providerPortfolio.put(url, portfolio); } - List importDataExceptions = new ArrayList(); + List importDataExceptions = new ArrayList<>(); for (ModuleType providedObject : providedObjects) { - List exceptions = new ArrayList(); + List exceptions = new ArrayList<>(); uid = providedObject.getUID(); checkExistence(uid, exceptions); if (exceptions.isEmpty()) { @@ -235,7 +235,7 @@ public class CommandlineModuleTypeProvider extends AbstractCommandProvider getAll() { - return new LinkedList(providedObjectsHolder.values()); + return new LinkedList<>(providedObjectsHolder.values()); } @Override diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineTemplateProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineTemplateProvider.java index ea8b327fc..d2e870b9c 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineTemplateProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/CommandlineTemplateProvider.java @@ -70,7 +70,7 @@ public class CommandlineTemplateProvider extends AbstractCommandProvider templateRegistry) { super(context); - listeners = new LinkedList>(); + listeners = new LinkedList<>(); tpReg = bc.registerService(RuleTemplateProvider.class.getName(), this, null); this.templateRegistry = templateRegistry; } @@ -178,13 +178,13 @@ public class CommandlineTemplateProvider extends AbstractCommandProvider providedObjects = parser.parse(inputStreamReader); if (providedObjects != null && !providedObjects.isEmpty()) { - List portfolio = new ArrayList(); + List portfolio = new ArrayList<>(); synchronized (providerPortfolio) { providerPortfolio.put(url, portfolio); } - List importDataExceptions = new ArrayList(); + List importDataExceptions = new ArrayList<>(); for (RuleTemplate ruleT : providedObjects) { - List exceptions = new ArrayList(); + List exceptions = new ArrayList<>(); String uid = ruleT.getUID(); checkExistence(uid, exceptions); if (exceptions.isEmpty()) { @@ -225,7 +225,7 @@ public class CommandlineTemplateProvider extends AbstractCommandProvider getAll() { - return new LinkedList(providedObjectsHolder.values()); + return new LinkedList<>(providedObjectsHolder.values()); } @Override diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Printer.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Printer.java index 3c8f5697d..2dca4e7b2 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Printer.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Printer.java @@ -96,14 +96,14 @@ public class Printer { */ static String printRules(AutomationCommandsPluggable autoCommands, Map ruleUIDs) { int[] columnWidths = new int[] { COLUMN_ID, COLUMN_RULE_UID, COLUMN_RULE_NAME, COLUMN_RULE_STATUS }; - List columnValues = new ArrayList(); + List columnValues = new ArrayList<>(); columnValues.add(ID); columnValues.add(UID); columnValues.add(NAME); columnValues.add(STATUS); String titleRow = Utils.getRow(columnWidths, columnValues); - List rulesRows = new ArrayList(); + List rulesRows = new ArrayList<>(); for (int i = 1; i <= ruleUIDs.size(); i++) { String id = new Integer(i).toString(); String uid = ruleUIDs.get(id); @@ -125,12 +125,12 @@ public class Printer { */ static String printTemplates(Map templateUIDs) { int[] columnWidths = new int[] { COLUMN_ID, COLUMN_UID }; - List columnTitles = new ArrayList(); + List columnTitles = new ArrayList<>(); columnTitles.add(ID); columnTitles.add(UID); String titleRow = Utils.getRow(columnWidths, columnTitles); - List templates = new ArrayList(); + List templates = new ArrayList<>(); collectListRecords(templateUIDs, templates, columnWidths); return Utils.getTableContent(TABLE_WIDTH, columnWidths, templates, titleRow); } @@ -143,12 +143,12 @@ public class Printer { */ static String printModuleTypes(Map moduleTypeUIDs) { int[] columnWidths = new int[] { COLUMN_ID, COLUMN_UID }; - List columnTitles = new ArrayList(); + List columnTitles = new ArrayList<>(); columnTitles.add(ID); columnTitles.add(UID); String titleRow = Utils.getRow(columnWidths, columnTitles); - List moduleTypes = new ArrayList(); + List moduleTypes = new ArrayList<>(); collectListRecords(moduleTypeUIDs, moduleTypes, columnWidths); return Utils.getTableContent(TABLE_WIDTH, columnWidths, moduleTypes, titleRow); } @@ -161,11 +161,11 @@ public class Printer { */ static String printRule(Rule rule, RuleStatus status) { int[] columnWidths = new int[] { TABLE_WIDTH }; - List ruleProperty = new ArrayList(); + List ruleProperty = new ArrayList<>(); ruleProperty.add(rule.getUID() + " [ " + status + " ]"); String titleRow = Utils.getRow(columnWidths, ruleProperty); - List ruleContent = new ArrayList(); + List ruleContent = new ArrayList<>(); columnWidths = new int[] { COLUMN_PROPERTY, COLUMN_PROPERTY_VALUE }; ruleProperty.set(0, UID); ruleProperty.add(rule.getUID()); @@ -203,11 +203,11 @@ public class Printer { */ static String printTemplate(Template template) { int[] columnWidths = new int[] { TABLE_WIDTH }; - List templateProperty = new ArrayList(); + List templateProperty = new ArrayList<>(); templateProperty.add(template.getUID()); String titleRow = Utils.getRow(columnWidths, templateProperty); - List templateContent = new ArrayList(); + List templateContent = new ArrayList<>(); columnWidths = new int[] { COLUMN_PROPERTY, COLUMN_PROPERTY_VALUE }; templateProperty.set(0, UID); templateProperty.add(template.getUID()); @@ -247,11 +247,11 @@ public class Printer { */ static String printModuleType(ModuleType moduleType) { int[] columnWidths = new int[] { TABLE_WIDTH }; - List moduleTypeProperty = new ArrayList(); + List moduleTypeProperty = new ArrayList<>(); moduleTypeProperty.add(moduleType.getUID()); String titleRow = Utils.getRow(columnWidths, moduleTypeProperty); - List moduleTypeContent = new ArrayList(); + List moduleTypeContent = new ArrayList<>(); columnWidths = new int[] { COLUMN_PROPERTY, COLUMN_PROPERTY_VALUE }; moduleTypeProperty.set(0, UID); moduleTypeProperty.add(moduleType.getUID()); @@ -309,7 +309,7 @@ public class Printer { * @return a string representing the response of the command {@link AutomationCommands#ENABLE_RULE}. */ static String printRuleStatus(String ruleUID, RuleStatus status) { - List title = new ArrayList(); + List title = new ArrayList<>(); title.add(ruleUID + " [ " + status + " ]"); String titleRow = Utils.getRow(new int[] { TABLE_WIDTH }, title); List res = Utils.getTableTitle(titleRow, TABLE_WIDTH); @@ -332,10 +332,10 @@ public class Printer { */ @SuppressWarnings("unchecked") private static List collectRecords(int[] columnWidths, String prop, Collection list) { - List res = new ArrayList(); + List res = new ArrayList<>(); boolean isFirst = true; boolean isList = false; - List values = new ArrayList(); + List values = new ArrayList<>(); values.add(prop); values.add(""); if (list != null && !list.isEmpty()) { @@ -395,9 +395,9 @@ public class Printer { */ private static List getModuleRecords(Module module) { int[] columnWidths = new int[] { COLUMN_PROPERTY_VALUE }; - List columnValues = new ArrayList(); + List columnValues = new ArrayList<>(); columnValues.add(module.getId()); - List moduleContent = new ArrayList(); + List moduleContent = new ArrayList<>(); moduleContent.addAll(Utils.getTableTitle(Utils.getRow(columnWidths, columnValues), COLUMN_PROPERTY_VALUE)); columnWidths = new int[] { COLUMN_CONFIG_PARAMETER, COLUMN_CONFIG_PARAMETER_VALUE }; @@ -430,8 +430,7 @@ public class Printer { inputs = ((Action) module).getInputs(); } if (inputs != null && !inputs.isEmpty()) { - moduleContent.addAll( - collectRecords(columnWidths, INPUTS, new ArrayList>(inputs.entrySet()))); + moduleContent.addAll(collectRecords(columnWidths, INPUTS, new ArrayList<>(inputs.entrySet()))); } return moduleContent; } @@ -464,13 +463,13 @@ public class Printer { */ private static List getConfigurationDescriptionRecords( List configDescriptions) { - List configParamContent = new ArrayList(); + List configParamContent = new ArrayList<>(); if (configDescriptions != null && !configDescriptions.isEmpty()) { for (ConfigDescriptionParameter parameter : configDescriptions) { int[] columnWidths = new int[] { COLUMN_CONFIG_PARAMETER, COLUMN_CONFIG_PARAMETER_PROP, COLUMN_CONFIG_PARAMETER_PROP_VALUE }; configParamContent.add(Utils.getColumn(COLUMN_PROPERTY_VALUE, parameter.getName() + " : ")); - List configParamProperty = new ArrayList(); + List configParamProperty = new ArrayList<>(); configParamProperty.add(""); configParamProperty.add(TYPE); configParamProperty.add(parameter.getType().toString()); @@ -566,7 +565,7 @@ public class Printer { for (int i = 1; i <= list.size(); i++) { String id = new Integer(i).toString(); String uid = list.get(id); - List columnValues = new ArrayList(); + List columnValues = new ArrayList<>(); columnValues.add(id); columnValues.add(uid); rows.add(Utils.getRow(columnWidths, columnValues)); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Utils.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Utils.java index d11d68373..636bcb617 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Utils.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/commands/Utils.java @@ -40,7 +40,7 @@ public class Utils { * @return an indexed UIDs of the automation objects. */ static Map putInHastable(String[] strings) { - Hashtable sorted = new Hashtable(); + Hashtable sorted = new Hashtable<>(); for (int i = 0; i < strings.length; i++) { sorted.put(new Integer(i + 1).toString(), strings[i]); } @@ -57,7 +57,7 @@ public class Utils { * @return filtered list with UIDs of the objects. */ static Map filterList(Map listObjects, Map listUIDs) { - Hashtable filtered = new Hashtable(); + Hashtable filtered = new Hashtable<>(); for (final Entry entry : listUIDs.entrySet()) { final String id = entry.getKey(); final String uid = entry.getValue(); @@ -133,7 +133,7 @@ public class Utils { * @return a string representing the title of the table. */ static List getTableTitle(String titleRow, int width) { - List res = new ArrayList(); + List res = new ArrayList<>(); res.add(printChars(TABLE_DELIMITER, width)); res.add(titleRow); res.add(printChars(TABLE_DELIMITER, width)); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/AbstractCompositeModuleHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/AbstractCompositeModuleHandler.java index 806396b67..a031eea14 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/AbstractCompositeModuleHandler.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/AbstractCompositeModuleHandler.java @@ -77,7 +77,7 @@ public abstract class AbstractCompositeModuleHandler getCompositeContext(Map context) { - Map result = new HashMap(context); + Map result = new HashMap<>(context); result.putAll(module.getConfiguration().getProperties()); return result; } diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeActionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeActionHandler.java index 80456468e..bc8681fdf 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeActionHandler.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeActionHandler.java @@ -62,7 +62,7 @@ public class CompositeActionHandler extends AbstractCompositeModuleHandler execute(Map context) { - final Map result = new HashMap(); + final Map result = new HashMap<>(); final List children = getChildren(); final Map compositeContext = getCompositeContext(context); for (Action child : children) { @@ -98,7 +98,7 @@ public class CompositeActionHandler extends AbstractCompositeModuleHandler getCompositeOutputMap(List outputs) { - Map result = new HashMap(11); + Map result = new HashMap<>(11); if (outputs != null) { for (Output output : outputs) { String refs = output.getReference(); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeModuleHandlerFactory.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeModuleHandlerFactory.java index 80c340e36..847638399 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeModuleHandlerFactory.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeModuleHandlerFactory.java @@ -172,7 +172,7 @@ public class CompositeModuleHandlerFactory extends BaseModuleHandlerFactory impl @SuppressWarnings("unchecked") private LinkedHashMap getChildHandlers(String compositeModuleId, Configuration compositeConfig, List childModules, String childModulePrefix) { - LinkedHashMap mapModuleToHandler = new LinkedHashMap(); + LinkedHashMap mapModuleToHandler = new LinkedHashMap<>(); for (T child : childModules) { String ruleId = getRuleId(childModulePrefix); ruleEngine.updateMapModuleTypeToRule(ruleId, child.getTypeUID()); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeTriggerHandler.java index ca9489a51..d94020d14 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeTriggerHandler.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/composite/CompositeTriggerHandler.java @@ -70,7 +70,7 @@ public class CompositeTriggerHandler public void triggered(Trigger trigger, Map context) { if (callback != null) { List outputs = moduleType.getOutputs(); - Map result = new HashMap(11); + Map result = new HashMap<>(11); for (Output output : outputs) { String refs = output.getReference(); if (refs != null) { diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/CompareConditionHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/CompareConditionHandler.java index bc44b1d12..c6e2c3fdf 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/CompareConditionHandler.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/CompareConditionHandler.java @@ -160,7 +160,7 @@ public class CompareConditionHandler extends BaseConditionModuleHandler { return rightOperandString2; } if (toCompare instanceof State) { - List> stateTypeList = new ArrayList>(); + List> stateTypeList = new ArrayList<>(); stateTypeList.add(((State) toCompare).getClass()); return TypeParser.parseState(stateTypeList, rightOperandString2); } else if (toCompare instanceof Integer) { diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericEventTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericEventTriggerHandler.java index 20bfaa6eb..4e1c89699 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericEventTriggerHandler.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/GenericEventTriggerHandler.java @@ -73,7 +73,7 @@ public class GenericEventTriggerHandler extends BaseTriggerModuleHandler impleme this.types = Collections.emptySet(); } this.bundleContext = bundleContext; - Dictionary properties = new Hashtable(); + Dictionary properties = new Hashtable<>(); properties.put("event.topics", topic); eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this, properties); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemCommandTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemCommandTriggerHandler.java index 45a2001a9..3338011c0 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemCommandTriggerHandler.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemCommandTriggerHandler.java @@ -64,7 +64,7 @@ public class ItemCommandTriggerHandler extends BaseTriggerModuleHandler implemen this.command = (String) module.getConfiguration().get(CFG_COMMAND); this.types = Collections.singleton(ItemCommandEvent.TYPE); this.bundleContext = bundleContext; - Dictionary properties = new Hashtable(); + Dictionary properties = new Hashtable<>(); this.topic = "smarthome/items/" + itemName + "/command"; properties.put("event.topics", topic); eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this, diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateTriggerHandler.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateTriggerHandler.java index b4a5ecc21..80dcf5717 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateTriggerHandler.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/module/handler/ItemStateTriggerHandler.java @@ -70,13 +70,13 @@ public class ItemStateTriggerHandler extends BaseTriggerModuleHandler implements if (UPDATE_MODULE_TYPE_ID.equals(module.getTypeUID())) { this.types = Collections.singleton(ItemStateEvent.TYPE); } else { - HashSet set = new HashSet<>(); + Set set = new HashSet<>(); set.add(ItemStateChangedEvent.TYPE); set.add(GroupItemStateChangedEvent.TYPE); this.types = Collections.unmodifiableSet(set); } this.bundleContext = bundleContext; - Dictionary properties = new Hashtable(); + Dictionary properties = new Hashtable<>(); properties.put("event.topics", "smarthome/items/" + itemName + "/*"); eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this, properties); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ModuleTypeGSONParser.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ModuleTypeGSONParser.java index c9b99e40c..36faba684 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ModuleTypeGSONParser.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/parser/gson/ModuleTypeGSONParser.java @@ -83,11 +83,11 @@ public class ModuleTypeGSONParser extends AbstractGSONParser { } private Map> createMapByType(Set dataObjects) { - Map> map = new HashMap>(); + Map> map = new HashMap<>(); - List triggers = new ArrayList(); - List conditions = new ArrayList(); - List actions = new ArrayList(); + List triggers = new ArrayList<>(); + List conditions = new ArrayList<>(); + List actions = new ArrayList<>(); for (ModuleType moduleType : dataObjects) { if (moduleType instanceof TriggerType) { triggers.add((TriggerType) moduleType); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java index 3b991bd88..82b542bf0 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AbstractResourceBundleProvider.java @@ -71,11 +71,11 @@ public abstract class AbstractResourceBundleProvider { public AbstractResourceBundleProvider() { logger = LoggerFactory.getLogger(this.getClass()); - providedObjectsHolder = new ConcurrentHashMap(); - providerPortfolio = new ConcurrentHashMap>(); - queue = new AutomationResourceBundlesEventQueue(this); - parsers = new ConcurrentHashMap>(); - waitingProviders = new ConcurrentHashMap>(); + providedObjectsHolder = new ConcurrentHashMap<>(); + providerPortfolio = new ConcurrentHashMap<>(); + queue = new AutomationResourceBundlesEventQueue<>(this); + parsers = new ConcurrentHashMap<>(); + waitingProviders = new ConcurrentHashMap<>(); } /** @@ -259,7 +259,7 @@ public abstract class AbstractResourceBundleProvider { } Vendor vendor = new Vendor(bundle.getSymbolicName(), bundle.getVersion().toString()); List previousPortfolio = getPreviousPortfolio(vendor); - List newPortfolio = new LinkedList(); + List newPortfolio = new LinkedList<>(); if (urlEnum != null) { while (urlEnum.hasMoreElements()) { URL url = urlEnum.nextElement(); @@ -290,7 +290,7 @@ public abstract class AbstractResourceBundleProvider { if (listeners != null) { List> snapshot = null; synchronized (listeners) { - snapshot = new LinkedList>(listeners); + snapshot = new LinkedList<>(listeners); } for (ProviderChangeListener listener : snapshot) { listener.removed((Provider) this, removedObject); @@ -359,7 +359,7 @@ public abstract class AbstractResourceBundleProvider { if (listeners != null) { List> snapshot = null; synchronized (listeners) { - snapshot = new LinkedList>(listeners); + snapshot = new LinkedList<>(listeners); } for (ProviderChangeListener listener : snapshot) { listener.removed((Provider) this, removedObject); @@ -397,7 +397,7 @@ public abstract class AbstractResourceBundleProvider { protected List getLocalizedConfigurationDescription(TranslationProvider i18nProvider, List config, Bundle bundle, String uid, String prefix, Locale locale) { - List configDescriptions = new ArrayList(); + List configDescriptions = new ArrayList<>(); if (config != null) { ConfigDescriptionI18nUtil util = new ConfigDescriptionI18nUtil(i18nProvider); for (ConfigDescriptionParameter parameter : config) { @@ -494,7 +494,7 @@ public abstract class AbstractResourceBundleProvider { Set parsedObjects) { List> snapshot = null; synchronized (listeners) { - snapshot = new LinkedList>(listeners); + snapshot = new LinkedList<>(listeners); } for (E parsedObject : parsedObjects) { String uid = getUID(parsedObject); @@ -521,7 +521,7 @@ public abstract class AbstractResourceBundleProvider { List urlList = waitingProviders.get(bundle); if (parser == null) { if (urlList == null) { - urlList = new ArrayList(); + urlList = new ArrayList<>(); } urlList.add(url); waitingProviders.put(bundle, urlList); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesEventQueue.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesEventQueue.java index c7f12dd93..e729cfecf 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesEventQueue.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesEventQueue.java @@ -44,7 +44,7 @@ public class AutomationResourceBundlesEventQueue implements Runnable { * This field serves for saving the BundleEvents for the bundles providing automation resources until their * processing completes. */ - private List queue = new ArrayList(); + private List queue = new ArrayList<>(); /** * This field is for synchronization purposes @@ -173,7 +173,7 @@ public class AutomationResourceBundlesEventQueue implements Runnable { return; } if (shared) { - queue = new LinkedList(); + queue = new LinkedList<>(); shared = false; } if (queue.add(event)) { @@ -231,7 +231,7 @@ public class AutomationResourceBundlesEventQueue implements Runnable { return; } if (shared) { - this.queue = new LinkedList(); + this.queue = new LinkedList<>(); shared = false; } if (this.queue.addAll(queue)) { diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesTracker.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesTracker.java index dab7781bc..8f9fd88d3 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesTracker.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/AutomationResourceBundlesTracker.java @@ -52,7 +52,7 @@ public class AutomationResourceBundlesTracker implements BundleTrackerCustomizer * {@link AbstractResourceBundleProvider}s of {@link ModuleType}s, {@link Template}s and {@link Rule}s. */ @SuppressWarnings("rawtypes") - private final List providerEventsQueue = new ArrayList(); + private final List providerEventsQueue = new ArrayList<>(); /** * This field holds a reference to an importer of {@link Rule}s. @@ -68,7 +68,7 @@ public class AutomationResourceBundlesTracker implements BundleTrackerCustomizer * This field serves for saving the BundleEvents for the bundles providing automation resources until their * processing completes. The events have been for adding, modifying or removing a bundle. */ - private final List queue = new LinkedList(); + private final List queue = new LinkedList<>(); public AutomationResourceBundlesTracker() { rImporter = createImporter(); @@ -80,7 +80,7 @@ public class AutomationResourceBundlesTracker implements BundleTrackerCustomizer @Activate protected void activate(BundleContext bc) { - bTracker = new BundleTracker(bc, ~Bundle.UNINSTALLED, this); + bTracker = new BundleTracker<>(bc, ~Bundle.UNINSTALLED, this); bTracker.open(); } diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/HostFragmentMappingUtil.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/HostFragmentMappingUtil.java index c7de63ac8..ade546d97 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/HostFragmentMappingUtil.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/HostFragmentMappingUtil.java @@ -29,7 +29,7 @@ import org.osgi.service.packageadmin.PackageAdmin; @SuppressWarnings("deprecation") public class HostFragmentMappingUtil { - private static Map> hostFragmentMapping = new HashMap>(); + private static Map> hostFragmentMapping = new HashMap<>(); static PackageAdmin pkgAdmin; @@ -49,7 +49,7 @@ public class HostFragmentMappingUtil { * @return a list with the hosts of the fragment parameter. */ static List returnHostBundles(Bundle fragment) { - List hosts = new ArrayList(); + List hosts = new ArrayList<>(); Bundle[] bundles = pkgAdmin.getHosts(fragment); if (bundles != null) { hosts = Arrays.asList(bundles); @@ -64,7 +64,7 @@ public class HostFragmentMappingUtil { } static List fillHostFragmentMapping(Bundle host) { - List fragments = new ArrayList(); + List fragments = new ArrayList<>(); Bundle[] bundles = pkgAdmin.getFragments(host); if (bundles != null) { fragments = Arrays.asList(bundles); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/ModuleTypeResourceBundleProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/ModuleTypeResourceBundleProvider.java index 981e7b4f5..926efc887 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/ModuleTypeResourceBundleProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/ModuleTypeResourceBundleProvider.java @@ -64,7 +64,7 @@ public class ModuleTypeResourceBundleProvider extends AbstractResourceBundleProv * @param context is the {@code BundleContext}, used for creating a tracker for {@link Parser} services. */ public ModuleTypeResourceBundleProvider() { - listeners = new LinkedList>(); + listeners = new LinkedList<>(); path = ROOT_DIRECTORY + "/moduletypes/"; } @@ -135,7 +135,7 @@ public class ModuleTypeResourceBundleProvider extends AbstractResourceBundleProv */ @Override public Collection getModuleTypes(Locale locale) { - List moduleTypesList = new ArrayList(); + List moduleTypesList = new ArrayList<>(); for (ModuleType mt : providedObjectsHolder.values()) { moduleTypesList.add(getPerLocale(mt, locale)); } diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/TemplateResourceBundleProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/TemplateResourceBundleProvider.java index 318b23f60..1c6eed693 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/TemplateResourceBundleProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/TemplateResourceBundleProvider.java @@ -71,7 +71,7 @@ public class TemplateResourceBundleProvider extends AbstractResourceBundleProvid * @param context is the {@code BundleContext}, used for creating a tracker for {@link Parser} services. */ public TemplateResourceBundleProvider() { - listeners = new LinkedList>(); + listeners = new LinkedList<>(); path = ROOT_DIRECTORY + "/templates/"; } @@ -141,7 +141,7 @@ public class TemplateResourceBundleProvider extends AbstractResourceBundleProvid */ @Override public Collection getTemplates(Locale locale) { - ArrayList templatesList = new ArrayList(); + List templatesList = new ArrayList<>(); for (RuleTemplate t : providedObjectsHolder.values()) { templatesList.add(getPerLocale(t, locale)); } diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AbstractFileProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AbstractFileProvider.java index de7269f3f..a8b2ad9e1 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AbstractFileProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/AbstractFileProvider.java @@ -62,25 +62,25 @@ public abstract class AbstractFileProvider implements Provider { *

* The Map has for keys URLs of the files containing automation objects and for values - parsed objects. */ - protected Map providedObjectsHolder = new ConcurrentHashMap(); + protected Map providedObjectsHolder = new ConcurrentHashMap<>(); /** * This Map provides structure for fast access to the {@link Parser}s. This provides opportunity for high * performance at runtime of the system. */ - private final Map> parsers = new ConcurrentHashMap>(); + private final Map> parsers = new ConcurrentHashMap<>(); /** * This map is used for mapping the imported automation objects to the file that contains them. This provides * opportunity when an event for deletion of the file is received, how to recognize which objects are removed. */ - private final Map> providerPortfolio = new ConcurrentHashMap>(); + private final Map> providerPortfolio = new ConcurrentHashMap<>(); /** * This Map holds URL resources that waiting for a parser to be loaded. */ - private final Map> urls = new ConcurrentHashMap>(); - private final List> listeners = new ArrayList>(); + private final Map> urls = new ConcurrentHashMap<>(); + private final List> listeners = new ArrayList<>(); public AbstractFileProvider(String root) { this.rootSubdirectory = root; @@ -250,7 +250,7 @@ public abstract class AbstractFileProvider implements Provider { synchronized (urls) { List value = urls.get(parserType); if (value == null) { - value = new ArrayList(); + value = new ArrayList<>(); urls.put(parserType, value); } value.add(url); @@ -261,7 +261,7 @@ public abstract class AbstractFileProvider implements Provider { protected void updateProvidedObjectsHolder(URL url, Set providedObjects) { if (providedObjects != null && !providedObjects.isEmpty()) { - List uids = new ArrayList(); + List uids = new ArrayList<>(); for (E providedObject : providedObjects) { String uid = getUID(providedObject); uids.add(uid); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/ModuleTypeFileProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/ModuleTypeFileProvider.java index 6a240631e..910c70384 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/ModuleTypeFileProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/ModuleTypeFileProvider.java @@ -53,8 +53,8 @@ public abstract class ModuleTypeFileProvider extends AbstractFileProvider Collection getModuleTypes(Locale locale) { Collection values = providedObjectsHolder.values(); if (values.isEmpty()) { - return Collections.emptyList(); + return Collections. emptyList(); } - return (Collection) new LinkedList(values); + return (Collection) new LinkedList<>(values); } } diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/TemplateFileProvider.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/TemplateFileProvider.java index 7bfc18745..5add1f132 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/TemplateFileProvider.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/TemplateFileProvider.java @@ -54,7 +54,7 @@ public abstract class TemplateFileProvider extends AbstractFileProvider emptyList(); } - return new LinkedList(values); + return new LinkedList<>(values); } } diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/WatchServiceUtil.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/WatchServiceUtil.java index 3a1666e04..5b3081816 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/WatchServiceUtil.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/file/WatchServiceUtil.java @@ -24,14 +24,14 @@ import java.util.Map; @SuppressWarnings("rawtypes") public class WatchServiceUtil { - private static final Map> WATCH_SERVICES = new HashMap>(); + private static final Map> WATCH_SERVICES = new HashMap<>(); public static void initializeWatchService(String watchingDir, AbstractFileProvider provider) { AutomationWatchService aws = null; synchronized (WATCH_SERVICES) { Map watchers = WATCH_SERVICES.get(provider); if (watchers == null) { - watchers = new HashMap(); + watchers = new HashMap<>(); WATCH_SERVICES.put(provider, watchers); } if (watchers.get(watchingDir) == null) { diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleI18nUtil.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleI18nUtil.java index 86fd7ca92..b978be88c 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleI18nUtil.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleI18nUtil.java @@ -35,7 +35,7 @@ public class ModuleI18nUtil { public static List getLocalizedModules(TranslationProvider i18nProvider, List modules, Bundle bundle, String uid, String prefix, Locale locale) { - List lmodules = new ArrayList(); + List lmodules = new ArrayList<>(); for (T module : modules) { String label = getModuleLabel(i18nProvider, bundle, uid, module.getId(), module.getLabel(), prefix, locale); String description = getModuleDescription(i18nProvider, bundle, uid, prefix, module.getId(), diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleTypeI18nUtil.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleTypeI18nUtil.java index e2754d0aa..2741c3845 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleTypeI18nUtil.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/provider/i18n/ModuleTypeI18nUtil.java @@ -48,7 +48,7 @@ public class ModuleTypeI18nUtil { public static List getLocalizedInputs(TranslationProvider i18nProvider, List inputs, Bundle bundle, String uid, Locale locale) { - List linputs = new ArrayList(); + List linputs = new ArrayList<>(); if (inputs != null) { for (Input input : inputs) { String inputName = input.getName(); @@ -65,7 +65,7 @@ public class ModuleTypeI18nUtil { public static List getLocalizedOutputs(TranslationProvider i18nProvider, List outputs, Bundle bundle, String uid, Locale locale) { - List loutputs = new ArrayList(); + List loutputs = new ArrayList<>(); if (outputs != null) { for (Output output : outputs) { String outputName = output.getName(); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/template/RuleTemplateRegistry.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/template/RuleTemplateRegistry.java index 22e9c3c04..7155aaf67 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/template/RuleTemplateRegistry.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/template/RuleTemplateRegistry.java @@ -21,7 +21,6 @@ import java.util.Locale; import java.util.Map.Entry; import java.util.Set; -import org.eclipse.smarthome.config.core.ConfigDescriptionParameter; import org.eclipse.smarthome.core.common.registry.AbstractRegistry; import org.eclipse.smarthome.core.common.registry.Provider; import org.openhab.core.automation.template.RuleTemplate; @@ -70,10 +69,9 @@ public class RuleTemplateRegistry extends AbstractRegistry(template.getTags()), new ArrayList<>(template.getTriggers()), + new HashSet<>(template.getTags()), new ArrayList<>(template.getTriggers()), new ArrayList<>(template.getConditions()), new ArrayList<>(template.getActions()), - new LinkedList(template.getConfigurationDescriptions()), - template.getVisibility()); + new LinkedList<>(template.getConfigurationDescriptions()), template.getVisibility()); } @Override diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/type/ModuleTypeRegistryImpl.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/type/ModuleTypeRegistryImpl.java index 215f5948f..dde264428 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/type/ModuleTypeRegistryImpl.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/internal/type/ModuleTypeRegistryImpl.java @@ -80,7 +80,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry Collection getByTag(String moduleTypeTag, Locale locale) { - Collection result = new ArrayList(20); + Collection result = new ArrayList<>(20); forEach((provider, mType) -> { ModuleType mt = locale == null ? mType : ((ModuleTypeProvider) provider).getModuleType(mType.getUID(), locale); @@ -102,8 +102,8 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry Collection getByTags(Locale locale, String... tags) { - Set tagSet = tags != null ? new HashSet(Arrays.asList(tags)) : null; - Collection result = new ArrayList(20); + Set tagSet = tags != null ? new HashSet<>(Arrays.asList(tags)) : null; + Collection result = new ArrayList<>(20); forEach((provider, mType) -> { ModuleType mt = locale == null ? mType : ((ModuleTypeProvider) provider).getModuleType(mType.getUID(), locale); @@ -119,7 +119,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry getTriggers(Locale locale, String... tags) { Collection moduleTypes = getByTags(locale, tags); - Collection triggerTypes = new ArrayList(); + Collection triggerTypes = new ArrayList<>(); for (ModuleType mt : moduleTypes) { if (mt instanceof TriggerType) { triggerTypes.add((TriggerType) mt); @@ -131,7 +131,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry getTriggers(String... tags) { Collection moduleTypes = getByTags(tags); - Collection triggerTypes = new ArrayList(); + Collection triggerTypes = new ArrayList<>(); for (ModuleType mt : moduleTypes) { if (mt instanceof TriggerType) { triggerTypes.add((TriggerType) mt); @@ -143,7 +143,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry getConditions(String... tags) { Collection moduleTypes = getByTags(tags); - Collection conditionTypes = new ArrayList(); + Collection conditionTypes = new ArrayList<>(); for (ModuleType mt : moduleTypes) { if (mt instanceof ConditionType) { conditionTypes.add((ConditionType) mt); @@ -155,7 +155,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry getConditions(Locale locale, String... tags) { Collection moduleTypes = getByTags(locale, tags); - Collection conditionTypes = new ArrayList(); + Collection conditionTypes = new ArrayList<>(); for (ModuleType mt : moduleTypes) { if (mt instanceof ConditionType) { conditionTypes.add((ConditionType) mt); @@ -167,7 +167,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry getActions(String... tags) { Collection moduleTypes = getByTags(tags); - Collection actionTypes = new ArrayList(); + Collection actionTypes = new ArrayList<>(); for (ModuleType mt : moduleTypes) { if (mt instanceof ActionType) { actionTypes.add((ActionType) mt); @@ -179,7 +179,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry getActions(Locale locale, String... tags) { Collection moduleTypes = getByTags(locale, tags); - Collection actionTypes = new ArrayList(); + Collection actionTypes = new ArrayList<>(); for (ModuleType mt : moduleTypes) { if (mt instanceof ActionType) { actionTypes.add((ActionType) mt); diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ConfigurationNormalizer.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ConfigurationNormalizer.java index 17722db47..65d4b6ca8 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ConfigurationNormalizer.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ConfigurationNormalizer.java @@ -22,6 +22,8 @@ import org.eclipse.smarthome.config.core.ConfigUtil; import org.eclipse.smarthome.config.core.Configuration; import org.openhab.core.automation.Module; import org.openhab.core.automation.RuleRegistry; +import org.openhab.core.automation.internal.ModuleImpl; +import org.openhab.core.automation.internal.RuleImpl; import org.openhab.core.automation.type.ModuleType; import org.openhab.core.automation.type.ModuleTypeRegistry; @@ -60,7 +62,7 @@ public class ConfigurationNormalizer { */ public static Map getConfigDescriptionMap( List configDesc) { - Map mapConfigDescs = new HashMap(); + Map mapConfigDescs = new HashMap<>(); for (ConfigDescriptionParameter configDescriptionParameter : configDesc) { mapConfigDescs.put(configDescriptionParameter.getName(), configDescriptionParameter); } diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ReferenceResolver.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ReferenceResolver.java index 5295e2ed4..57f15da5d 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ReferenceResolver.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/ReferenceResolver.java @@ -84,7 +84,7 @@ public class ReferenceResolver { Object result = resolveProperty(config, context, logger, configKey, (String) o); config.put(configKey, result); } else if (o instanceof List) { - ArrayList resultList = new ArrayList<>(); + List resultList = new ArrayList<>(); List list = (List) o; for (Object obj : list) { if (obj instanceof String) { diff --git a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/RuleBuilder.java b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/RuleBuilder.java index 8b7d08d40..b5417938e 100644 --- a/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/RuleBuilder.java +++ b/bundles/org.openhab.core.automation/src/main/java/org/openhab/core/automation/util/RuleBuilder.java @@ -112,7 +112,7 @@ public class RuleBuilder { public RuleBuilder withTriggers(@Nullable List triggers) { if (triggers != null) { - ArrayList triggerList = new ArrayList<>(triggers.size()); + List triggerList = new ArrayList<>(triggers.size()); triggers.forEach(t -> triggerList.add(TriggerBuilder.create(t).build())); this.triggers = triggerList; } @@ -125,7 +125,7 @@ public class RuleBuilder { public RuleBuilder withConditions(@Nullable List conditions) { if (conditions != null) { - ArrayList conditionList = new ArrayList<>(conditions.size()); + List conditionList = new ArrayList<>(conditions.size()); conditions.forEach(c -> conditionList.add(ConditionBuilder.create(c).build())); this.conditions = conditionList; } @@ -138,7 +138,7 @@ public class RuleBuilder { public RuleBuilder withActions(@Nullable List actions) { if (actions != null) { - ArrayList actionList = new ArrayList<>(actions.size()); + List actionList = new ArrayList<>(actions.size()); actions.forEach(a -> actionList.add(ActionBuilder.create(a).build())); this.actions = actionList; } diff --git a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/provider/AnnotationActionModuleTypeProviderTest.java b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/provider/AnnotationActionModuleTypeProviderTest.java index a6471ad58..e8d3b2d0b 100644 --- a/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/provider/AnnotationActionModuleTypeProviderTest.java +++ b/bundles/org.openhab.core.automation/src/test/java/org/openhab/core/automation/internal/module/provider/AnnotationActionModuleTypeProviderTest.java @@ -87,7 +87,7 @@ public class AnnotationActionModuleTypeProviderTest extends JavaTest { AnnotatedActionModuleTypeProvider prov = new AnnotatedActionModuleTypeProvider(); prov.setModuleTypeI18nService(moduleTypeI18nService); - HashMap properties1 = new HashMap(); + Map properties1 = new HashMap<>(); properties1.put(ConfigConstants.SERVICE_CONTEXT, "conf1"); prov.addActionProvider(actionProviderConf1, properties1); @@ -95,7 +95,7 @@ public class AnnotationActionModuleTypeProviderTest extends JavaTest { assertEquals(1, types.size()); assertTrue(types.contains(TEST_ACTION_TYPE_ID)); - HashMap properties2 = new HashMap(); + Map properties2 = new HashMap<>(); properties2.put(ConfigConstants.SERVICE_CONTEXT, "conf2"); prov.addActionProvider(actionProviderConf2, properties2); diff --git a/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/items/GenericItem.java b/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/items/GenericItem.java index da7190e4c..33e8c112c 100644 --- a/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/items/GenericItem.java +++ b/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/items/GenericItem.java @@ -36,7 +36,7 @@ public abstract class GenericItem implements Item { protected EventPublisher eventPublisher; protected Set listeners = new CopyOnWriteArraySet<>( - Collections.newSetFromMap(new WeakHashMap())); + Collections.newSetFromMap(new WeakHashMap<>())); protected List groupNames = new ArrayList<>(); diff --git a/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/library/items/StringItem.java b/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/library/items/StringItem.java index f91acd436..3f7843f17 100644 --- a/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/library/items/StringItem.java +++ b/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/library/items/StringItem.java @@ -58,7 +58,7 @@ public class StringItem extends GenericItem { @Override public State getStateAs(Class typeClass) { - ArrayList> list = new ArrayList<>(); + List> list = new ArrayList<>(); list.add(typeClass); State convertedState = TypeParser.parseState(list, state.toString()); if (convertedState != null) { diff --git a/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/persistence/internal/QueryablePersistenceServiceDelegate.java b/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/persistence/internal/QueryablePersistenceServiceDelegate.java index 8fc4d8335..07ae8b7f3 100644 --- a/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/persistence/internal/QueryablePersistenceServiceDelegate.java +++ b/bundles/org.openhab.core.compat1x/src/main/java/org/openhab/core/persistence/internal/QueryablePersistenceServiceDelegate.java @@ -15,6 +15,7 @@ package org.openhab.core.persistence.internal; import java.util.ArrayList; import java.util.Collections; import java.util.Date; +import java.util.List; import java.util.Set; import org.eclipse.smarthome.core.persistence.FilterCriteria; @@ -49,7 +50,7 @@ public class QueryablePersistenceServiceDelegate extends PersistenceServiceDeleg .setState(mapState(filter.getState())); org.openhab.core.persistence.QueryablePersistenceService pService = (org.openhab.core.persistence.QueryablePersistenceService) service; Iterable historicItems = pService.query(mappedFilter); - ArrayList result = new ArrayList<>(); + List result = new ArrayList<>(); if (historicItems != null) { for (final org.openhab.core.persistence.HistoricItem item : historicItems) { result.add(new HistoricItem() { diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescription.java b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescription.java index cf7ebadb0..42ecf741b 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescription.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescription.java @@ -99,13 +99,13 @@ public class ConfigDescription implements Identifiable { if (parameters != null) { this.parameters = Collections.unmodifiableList(parameters); } else { - this.parameters = Collections.unmodifiableList(new ArrayList(0)); + this.parameters = Collections.unmodifiableList(new ArrayList<>(0)); } if (groups != null) { this.parameterGroups = Collections.unmodifiableList(groups); } else { - this.parameterGroups = Collections.unmodifiableList(new ArrayList(0)); + this.parameterGroups = Collections.unmodifiableList(new ArrayList<>(0)); } } diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescriptionParameter.java b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescriptionParameter.java index 8f38852a1..777979297 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescriptionParameter.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescriptionParameter.java @@ -97,17 +97,17 @@ public class ConfigDescriptionParameter { private String label; private String description; - private List options = new ArrayList(); - private List filterCriteria = new ArrayList(); + private List options = new ArrayList<>(); + private List filterCriteria = new ArrayList<>(); private boolean limitToOptions = true; private boolean advanced = false; private boolean verify = false; private static final Set UNITS = Collections - .unmodifiableSet(new HashSet(Arrays.asList("A", "cd", "K", "kg", "m", "mol", "s", "g", "rad", "sr", - "Hz", "N", "Pa", "J", "W", "C", "V", "F", "Ω", "S", "Wb", "T", "H", "Cel", "lm", "lx", "Bq", "Gy", - "Sv", "kat", "m/s2", "m2v", "m3", "kph", "%", "l", "ms", "min", "h", "d", "week", "y"))); + .unmodifiableSet(new HashSet<>(Arrays.asList("A", "cd", "K", "kg", "m", "mol", "s", "g", "rad", "sr", "Hz", + "N", "Pa", "J", "W", "C", "V", "F", "Ω", "S", "Wb", "T", "H", "Cel", "lm", "lx", "Bq", "Gy", "Sv", + "kat", "m/s2", "m2v", "m3", "kph", "%", "l", "ms", "min", "h", "d", "week", "y"))); /** * Default constructor. @@ -239,12 +239,12 @@ public class ConfigDescriptionParameter { if (options != null) { this.options = Collections.unmodifiableList(options); } else { - this.options = Collections.unmodifiableList(new LinkedList()); + this.options = Collections.unmodifiableList(new LinkedList<>()); } if (filterCriteria != null) { this.filterCriteria = Collections.unmodifiableList(filterCriteria); } else { - this.filterCriteria = Collections.unmodifiableList(new LinkedList()); + this.filterCriteria = Collections.unmodifiableList(new LinkedList<>()); } } @@ -320,23 +320,29 @@ public class ConfigDescriptionParameter { /** * Returns the context of the configuration parameter. - *

A context is a hint for user interfaces and input validators.

- *

Any string can be used, but the following have a special meaning:

- * + *

+ * A context is a hint for user interfaces and input validators. + *

+ *

+ * Any string can be used, but the following have a special meaning: + *

+ * * - network-address: The configuration value represents an IPv4 or IPv6 address. * - password: A password value (a user-interface might obscure the visible value) * - password-create: A passwort generator widget might be shown * - color: This value represents an RGB color value like #ffffff or 12,12,12. * - date: A date string * - time: A time string - * - cronexpression: A cron expression like "* * * * *". A user interface would probably show a cron expression generator. + * - cronexpression: A cron expression like "* * * * *". A user interface would probably show a cron expression + * generator. * - datetime: A date and time string * - email: The configuration value represents an email address * - month: A number [1-12] - * - week: A week [0-52] + * - week: A week [0-52] * - tel: A tel no * - url: A web address - * - script: The configuration value represents a script (javascript, python etc). A user-interface would probably render a multi line editor. + * - script: The configuration value represents a script (javascript, python etc). A user-interface would probably + * render a multi line editor. * - location: A lat,long,alt GPS location. A user-interface would probably render a world map for selection. * - tag: One tag or multiple tags separated by comma. * - item: A valid item "name". A user-interface would probably show an item selection widget. diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescriptionParameterBuilder.java b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescriptionParameterBuilder.java index a6c53ccc0..25483b8f4 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescriptionParameterBuilder.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescriptionParameterBuilder.java @@ -51,8 +51,8 @@ public class ConfigDescriptionParameterBuilder { private Boolean advanced; private Boolean verify; - private List options = new ArrayList(); - private List filterCriteria = new ArrayList(); + private List options = new ArrayList<>(); + private List filterCriteria = new ArrayList<>(); private ConfigDescriptionParameterBuilder(String name, Type type) { this.name = name; diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescriptionRegistry.java b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescriptionRegistry.java index e5358c718..035bf75c7 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescriptionRegistry.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/ConfigDescriptionRegistry.java @@ -106,7 +106,7 @@ public class ConfigDescriptionRegistry { * description exists */ public Collection getConfigDescriptions(Locale locale) { - Map configMap = new HashMap(); + Map configMap = new HashMap<>(); // Loop over all providers for (ConfigDescriptionProvider configDescriptionProvider : this.configDescriptionProviders) { @@ -116,11 +116,11 @@ public class ConfigDescriptionRegistry { ConfigDescription configFromMap = configMap.get(configDescription.getUID()); if (configFromMap != null) { // Yes - Merge the groups and parameters - List parameters = new ArrayList(); + List parameters = new ArrayList<>(); parameters.addAll(configFromMap.getParameters()); parameters.addAll(configDescription.getParameters()); - List parameterGroups = new ArrayList(); + List parameterGroups = new ArrayList<>(); parameterGroups.addAll(configFromMap.getParameterGroups()); parameterGroups.addAll(configDescription.getParameterGroups()); @@ -135,7 +135,7 @@ public class ConfigDescriptionRegistry { } // Now convert the map into the collection - Collection configDescriptions = new ArrayList(configMap.size()); + Collection configDescriptions = new ArrayList<>(configMap.size()); for (ConfigDescription configDescription : configMap.values()) { configDescriptions.add(configDescription); } @@ -170,8 +170,8 @@ public class ConfigDescriptionRegistry { * the given name */ public @Nullable ConfigDescription getConfigDescription(URI uri, Locale locale) { - List parameters = new ArrayList(); - List parameterGroups = new ArrayList(); + List parameters = new ArrayList<>(); + List parameterGroups = new ArrayList<>(); boolean found = false; Set aliases = getAliases(uri); @@ -183,8 +183,7 @@ public class ConfigDescriptionRegistry { found |= fillFromProviders(uri, locale, parameters, parameterGroups); if (found) { - List parametersWithOptions = new ArrayList( - parameters.size()); + List parametersWithOptions = new ArrayList<>(parameters.size()); for (ConfigDescriptionParameter parameter : parameters) { parametersWithOptions.add(getConfigOptions(uri, aliases, parameter, locale)); } @@ -254,7 +253,7 @@ public class ConfigDescriptionRegistry { */ private ConfigDescriptionParameter getConfigOptions(URI uri, Set aliases, ConfigDescriptionParameter parameter, Locale locale) { - List options = new ArrayList(); + List options = new ArrayList<>(); // Add all the existing options that may be provided by the initial config description provider options.addAll(parameter.getOptions()); diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/dto/ConfigDescriptionDTOMapper.java b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/dto/ConfigDescriptionDTOMapper.java index 0ce5aa57e..a2e9a711c 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/dto/ConfigDescriptionDTOMapper.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/dto/ConfigDescriptionDTOMapper.java @@ -75,7 +75,7 @@ public class ConfigDescriptionDTOMapper { if (filterCriteria == null) { return null; } - List result = new LinkedList(); + List result = new LinkedList<>(); for (FilterCriteriaDTO criteria : filterCriteria) { result.add(new FilterCriteria(criteria.name, criteria.value)); } @@ -86,7 +86,7 @@ public class ConfigDescriptionDTOMapper { if (options == null) { return null; } - List result = new LinkedList(); + List result = new LinkedList<>(); for (ParameterOptionDTO option : options) { result.add(new ParameterOption(option.value, option.label)); } @@ -143,7 +143,7 @@ public class ConfigDescriptionDTOMapper { if (filterCriteria == null) { return null; } - List result = new LinkedList(); + List result = new LinkedList<>(); for (FilterCriteria criteria : filterCriteria) { result.add(new FilterCriteriaDTO(criteria.getName(), criteria.getValue())); } @@ -154,7 +154,7 @@ public class ConfigDescriptionDTOMapper { if (options == null) { return null; } - List result = new LinkedList(); + List result = new LinkedList<>(); for (ParameterOption option : options) { result.add(new ParameterOptionDTO(option.getValue(), option.getLabel())); } diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/internal/ConfigMapper.java b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/internal/ConfigMapper.java index 643a30683..9c5d66e77 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/internal/ConfigMapper.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/internal/ConfigMapper.java @@ -115,7 +115,7 @@ public class ConfigMapper { * @return A list of Field objects */ private static List getAllFields(Class clazz) { - List fields = new ArrayList(); + List fields = new ArrayList<>(); Class currentClass = clazz; while (currentClass != null) { diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/internal/net/NetworkConfigOptionProvider.java b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/internal/net/NetworkConfigOptionProvider.java index a2980e69b..ab392a649 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/internal/net/NetworkConfigOptionProvider.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/internal/net/NetworkConfigOptionProvider.java @@ -16,6 +16,7 @@ import java.net.Inet4Address; import java.net.URI; import java.util.ArrayList; import java.util.Collection; +import java.util.List; import java.util.Locale; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -50,7 +51,7 @@ public class NetworkConfigOptionProvider implements ConfigOptionProvider { } if (param.equals(PARAM_BROADCAST_ADDRESS)) { - ArrayList broadcastAddrList = new ArrayList<>(NetUtil.getAllBroadcastAddresses()); + List broadcastAddrList = new ArrayList<>(NetUtil.getAllBroadcastAddresses()); broadcastAddrList.add("255.255.255.255"); return broadcastAddrList.stream().map(a -> new ParameterOption(a, a)).collect(Collectors.toList()); } diff --git a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/internal/normalization/NormalizerFactory.java b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/internal/normalization/NormalizerFactory.java index 2cc2d4718..5befb51e6 100644 --- a/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/internal/normalization/NormalizerFactory.java +++ b/bundles/org.openhab.core.config.core/src/main/java/org/eclipse/smarthome/config/core/internal/normalization/NormalizerFactory.java @@ -31,7 +31,7 @@ public final class NormalizerFactory { private static final Map NORMALIZERS; static { - Map map = new HashMap(11); + Map map = new HashMap<>(11); map.put(Type.BOOLEAN, new BooleanNormalizer()); map.put(Type.TEXT, new TextNormalizer()); map.put(Type.INTEGER, new IntNormalizer()); diff --git a/bundles/org.openhab.core.config.core/src/test/java/org/eclipse/smarthome/config/core/ConfigDescriptionRegistryTest.java b/bundles/org.openhab.core.config.core/src/test/java/org/eclipse/smarthome/config/core/ConfigDescriptionRegistryTest.java index dd5044a4f..aaba83934 100644 --- a/bundles/org.openhab.core.config.core/src/test/java/org/eclipse/smarthome/config/core/ConfigDescriptionRegistryTest.java +++ b/bundles/org.openhab.core.config.core/src/test/java/org/eclipse/smarthome/config/core/ConfigDescriptionRegistryTest.java @@ -62,7 +62,7 @@ public class ConfigDescriptionRegistryTest extends JavaTest { configDescriptionRegistry = new ConfigDescriptionRegistry(); ConfigDescriptionParameter param1 = new ConfigDescriptionParameter("param1", ConfigDescriptionParameter.Type.INTEGER); - List pList1 = new ArrayList(); + List pList1 = new ArrayList<>(); pList1.add(param1); configDescription = new ConfigDescription(URI_DUMMY, pList1); @@ -84,7 +84,7 @@ public class ConfigDescriptionRegistryTest extends JavaTest { ConfigDescriptionParameter param2 = new ConfigDescriptionParameter("param2", ConfigDescriptionParameter.Type.INTEGER); - List pList2 = new ArrayList(); + List pList2 = new ArrayList<>(); pList2.add(param2); configDescription2 = new ConfigDescription(URI_DUMMY, pList2); when(configDescriptionProviderMock2.getConfigDescriptions(any())) diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/DiscoveryResultImpl.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/DiscoveryResultImpl.java index 0ec5a1d3e..bae92fc38 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/DiscoveryResultImpl.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/DiscoveryResultImpl.java @@ -100,7 +100,7 @@ public class DiscoveryResultImpl implements DiscoveryResult { this.thingTypeUID = thingTypeUID; this.bridgeUID = bridgeUID; this.properties = Collections - .unmodifiableMap((properties != null) ? new HashMap<>(properties) : new HashMap()); + .unmodifiableMap((properties != null) ? new HashMap<>(properties) : new HashMap<>()); this.representationProperty = representationProperty; this.label = label == null ? "" : label; diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/DiscoveryServiceRegistryImpl.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/DiscoveryServiceRegistryImpl.java index 0c8b788b4..9c9c49292 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/DiscoveryServiceRegistryImpl.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/DiscoveryServiceRegistryImpl.java @@ -302,7 +302,7 @@ public final class DiscoveryServiceRegistryImpl implements DiscoveryServiceRegis @Override public @Nullable Collection removeOlderResults(final DiscoveryService source, final long timestamp, final @Nullable Collection thingTypeUIDs, @Nullable ThingUID bridgeUID) { - HashSet removedResults = new HashSet<>(); + Set removedResults = new HashSet<>(); for (final DiscoveryListener listener : this.listeners) { try { Collection olderResults = AccessController diff --git a/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/PersistentInbox.java b/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/PersistentInbox.java index 84989075b..dd67f0774 100644 --- a/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/PersistentInbox.java +++ b/bundles/org.openhab.core.config.discovery/src/main/java/org/eclipse/smarthome/config/discovery/internal/PersistentInbox.java @@ -386,7 +386,7 @@ public final class PersistentInbox implements Inbox, DiscoveryListener, ThingReg @Override public @Nullable Collection removeOlderResults(DiscoveryService source, long timestamp, @Nullable Collection thingTypeUIDs, @Nullable ThingUID bridgeUID) { - HashSet removedThings = new HashSet<>(); + Set removedThings = new HashSet<>(); for (DiscoveryResult discoveryResult : getAll()) { Class discoverer = resultDiscovererMap.get(discoveryResult); if (thingTypeUIDs != null && thingTypeUIDs.contains(discoveryResult.getThingTypeUID()) diff --git a/bundles/org.openhab.core.config.dispatch/src/main/java/org/eclipse/smarthome/config/dispatch/internal/ConfigDispatcher.java b/bundles/org.openhab.core.config.dispatch/src/main/java/org/eclipse/smarthome/config/dispatch/internal/ConfigDispatcher.java index b81bc78af..f24154b8a 100644 --- a/bundles/org.openhab.core.config.dispatch/src/main/java/org/eclipse/smarthome/config/dispatch/internal/ConfigDispatcher.java +++ b/bundles/org.openhab.core.config.dispatch/src/main/java/org/eclipse/smarthome/config/dispatch/internal/ConfigDispatcher.java @@ -300,10 +300,10 @@ public class ConfigDispatcher { // we need to remember which configuration needs to be updated // because values have changed. - Map configsToUpdate = new HashMap(); + Map configsToUpdate = new HashMap<>(); // also cache the already retrieved configurations for each pid - Map configMap = new HashMap(); + Map configMap = new HashMap<>(); String pid = pidFromFilename(configFile); String context = null; diff --git a/bundles/org.openhab.core.config.xml/src/main/java/org/eclipse/smarthome/config/xml/AbstractXmlBasedProvider.java b/bundles/org.openhab.core.config.xml/src/main/java/org/eclipse/smarthome/config/xml/AbstractXmlBasedProvider.java index 4a06a2918..44e651c1a 100644 --- a/bundles/org.openhab.core.config.xml/src/main/java/org/eclipse/smarthome/config/xml/AbstractXmlBasedProvider.java +++ b/bundles/org.openhab.core.config.xml/src/main/java/org/eclipse/smarthome/config/xml/AbstractXmlBasedProvider.java @@ -91,7 +91,7 @@ public abstract class AbstractXmlBasedProvider objects = bundleObjectMap.get(bundle); if (objects == null) { - objects = new CopyOnWriteArrayList(); + objects = new CopyOnWriteArrayList<>(); bundleObjectMap.put(bundle, objects); } return objects; diff --git a/bundles/org.openhab.core.config.xml/src/main/java/org/eclipse/smarthome/config/xml/ConfigDescriptionConverter.java b/bundles/org.openhab.core.config.xml/src/main/java/org/eclipse/smarthome/config/xml/ConfigDescriptionConverter.java index ac4d712a8..176b5cc89 100644 --- a/bundles/org.openhab.core.config.xml/src/main/java/org/eclipse/smarthome/config/xml/ConfigDescriptionConverter.java +++ b/bundles/org.openhab.core.config.xml/src/main/java/org/eclipse/smarthome/config/xml/ConfigDescriptionConverter.java @@ -66,8 +66,7 @@ public class ConfigDescriptionConverter extends GenericUnmarshaller configDescriptionParams = new ArrayList(); - List configDescriptionGroups = new ArrayList(); + List configDescriptionParams = new ArrayList<>(); + List configDescriptionGroups = new ArrayList<>(); // read values List nodes = (List) context.convertAnother(context, List.class); diff --git a/bundles/org.openhab.core.config.xml/src/main/java/org/eclipse/smarthome/config/xml/osgi/XmlDocumentBundleTracker.java b/bundles/org.openhab.core.config.xml/src/main/java/org/eclipse/smarthome/config/xml/osgi/XmlDocumentBundleTracker.java index 912060530..fedd0f7c3 100644 --- a/bundles/org.openhab.core.config.xml/src/main/java/org/eclipse/smarthome/config/xml/osgi/XmlDocumentBundleTracker.java +++ b/bundles/org.openhab.core.config.xml/src/main/java/org/eclipse/smarthome/config/xml/osgi/XmlDocumentBundleTracker.java @@ -298,8 +298,8 @@ public class XmlDocumentBundleTracker extends BundleTracker { * @return the URLs of the resources, never {@code null} */ private Collection filterPatches(Enumeration xmlDocumentPaths, Bundle bundle) { - List hostResources = new ArrayList(); - List fragmentResources = new ArrayList(); + List hostResources = new ArrayList<>(); + List fragmentResources = new ArrayList<>(); while (xmlDocumentPaths.hasMoreElements()) { URL path = xmlDocumentPaths.nextElement(); @@ -310,7 +310,7 @@ public class XmlDocumentBundleTracker extends BundleTracker { } } if (!fragmentResources.isEmpty()) { - Map helper = new HashMap(); + Map helper = new HashMap<>(); for (URL url : hostResources) { helper.put(url.getPath(), url); } diff --git a/bundles/org.openhab.core.io.console.eclipse/src/main/java/org/eclipse/smarthome/io/console/eclipse/internal/ConsoleSupportEclipse.java b/bundles/org.openhab.core.io.console.eclipse/src/main/java/org/eclipse/smarthome/io/console/eclipse/internal/ConsoleSupportEclipse.java index 88b277a43..c10055dc0 100644 --- a/bundles/org.openhab.core.io.console.eclipse/src/main/java/org/eclipse/smarthome/io/console/eclipse/internal/ConsoleSupportEclipse.java +++ b/bundles/org.openhab.core.io.console.eclipse/src/main/java/org/eclipse/smarthome/io/console/eclipse/internal/ConsoleSupportEclipse.java @@ -46,7 +46,7 @@ public class ConsoleSupportEclipse implements CommandProvider { private static final String BASE = "smarthome"; private final SortedMap consoleCommandExtensions = Collections - .synchronizedSortedMap(new TreeMap()); + .synchronizedSortedMap(new TreeMap<>()); public ConsoleSupportEclipse() { } @@ -90,7 +90,7 @@ public class ConsoleSupportEclipse implements CommandProvider { console.println(String.format("No handler for command '%s' was found.", cmd)); } else { // Build argument list - final List argsList = new ArrayList(); + final List argsList = new ArrayList<>(); while (true) { final String narg = interpreter.nextArgument(); if (!StringUtils.isEmpty(narg)) { diff --git a/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/eclipse/smarthome/io/console/rfc147/internal/ConsoleSupportRfc147.java b/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/eclipse/smarthome/io/console/rfc147/internal/ConsoleSupportRfc147.java index 96dce8521..2eff022d3 100644 --- a/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/eclipse/smarthome/io/console/rfc147/internal/ConsoleSupportRfc147.java +++ b/bundles/org.openhab.core.io.console.rfc147/src/main/java/org/eclipse/smarthome/io/console/rfc147/internal/ConsoleSupportRfc147.java @@ -68,7 +68,7 @@ public class ConsoleSupportRfc147 implements ConsoleCommandsContainer { * known). Otherwise it stores the registered service reference, so we could unregister the command extension later. */ private final Map> commands = Collections - .synchronizedMap(new HashMap>()); + .synchronizedMap(new HashMap<>()); public ConsoleSupportRfc147() { // Add our custom help console command extensions. diff --git a/bundles/org.openhab.core.io.console/src/main/java/org/eclipse/smarthome/io/console/ConsoleInterpreter.java b/bundles/org.openhab.core.io.console/src/main/java/org/eclipse/smarthome/io/console/ConsoleInterpreter.java index ec69d1004..c875a4347 100644 --- a/bundles/org.openhab.core.io.console/src/main/java/org/eclipse/smarthome/io/console/ConsoleInterpreter.java +++ b/bundles/org.openhab.core.io.console/src/main/java/org/eclipse/smarthome/io/console/ConsoleInterpreter.java @@ -71,7 +71,7 @@ public class ConsoleInterpreter { /** returns an array of the usage texts for all available commands */ public static List getUsages(Collection consoleCommandExtensions) { - List usages = new ArrayList(); + List usages = new ArrayList<>(); for (ConsoleCommandExtension consoleCommandExtension : consoleCommandExtensions) { usages.addAll(consoleCommandExtension.getUsages()); } diff --git a/bundles/org.openhab.core.io.http/src/main/java/org/eclipse/smarthome/io/http/servlet/BaseSmartHomeServlet.java b/bundles/org.openhab.core.io.http/src/main/java/org/eclipse/smarthome/io/http/servlet/BaseSmartHomeServlet.java index 5dc6a9d8c..d1167a8a7 100644 --- a/bundles/org.openhab.core.io.http/src/main/java/org/eclipse/smarthome/io/http/servlet/BaseSmartHomeServlet.java +++ b/bundles/org.openhab.core.io.http/src/main/java/org/eclipse/smarthome/io/http/servlet/BaseSmartHomeServlet.java @@ -54,7 +54,7 @@ public abstract class BaseSmartHomeServlet extends HttpServlet { try { logger.debug("Starting up {} at {}", getClass().getSimpleName(), alias); - Hashtable props = new Hashtable(); + Hashtable props = new Hashtable<>(); httpService.registerServlet(alias, this, props, httpContext); } catch (NamespaceException e) { logger.error("Error during servlet registration - alias {} already in use", alias, e); diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/config/ConfigurationService.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/config/ConfigurationService.java index 17acd820c..c13f5e99f 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/config/ConfigurationService.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/config/ConfigurationService.java @@ -178,7 +178,7 @@ public class ConfigurationService { private Dictionary getProperties(org.osgi.service.cm.Configuration configuration) { Dictionary properties = configuration.getProperties(); - return properties != null ? properties : new Hashtable(); + return properties != null ? properties : new Hashtable<>(); } @Reference diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/internal/persistence/PersistenceResource.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/internal/persistence/PersistenceResource.java index 2f5311a9d..4cf8cb22c 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/internal/persistence/PersistenceResource.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/internal/persistence/PersistenceResource.java @@ -369,7 +369,7 @@ public class PersistenceResource implements RESTResource { * @return list of persistence services as {@link ServiceBean} */ private List getPersistenceServiceList(Locale locale) { - List dtoList = new ArrayList(); + List dtoList = new ArrayList<>(); for (PersistenceService service : persistenceServiceRegistry.getAll()) { PersistenceServiceDTO serviceDTO = new PersistenceServiceDTO(); diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/persistence/ItemHistoryListDTO.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/persistence/ItemHistoryListDTO.java index c22c9d3e1..6e5bb62a2 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/persistence/ItemHistoryListDTO.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/persistence/ItemHistoryListDTO.java @@ -24,7 +24,7 @@ import org.eclipse.smarthome.core.persistence.dto.ItemHistoryDTO; * @author Chris Jackson - Initial contribution */ public class ItemHistoryListDTO { - public final List item = new ArrayList(); + public final List item = new ArrayList<>(); public ItemHistoryListDTO() { } diff --git a/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/thing/EnrichedChannelDTO.java b/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/thing/EnrichedChannelDTO.java index 7c28b001c..d032b7bd6 100644 --- a/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/thing/EnrichedChannelDTO.java +++ b/bundles/org.openhab.core.io.rest.core/src/main/java/org/eclipse/smarthome/io/rest/core/thing/EnrichedChannelDTO.java @@ -14,6 +14,7 @@ package org.eclipse.smarthome.io.rest.core.thing; import java.util.HashSet; import java.util.Set; + import org.eclipse.smarthome.core.thing.dto.ChannelDTO; /** @@ -36,6 +37,6 @@ public class EnrichedChannelDTO extends ChannelDTO { this.properties = channelDTO.properties; this.configuration = channelDTO.configuration; this.defaultTags = channelDTO.defaultTags; - this.linkedItems = linkedItems != null ? new HashSet<>(linkedItems) : new HashSet(); + this.linkedItems = linkedItems != null ? new HashSet<>(linkedItems) : new HashSet<>(); } } diff --git a/bundles/org.openhab.core.io.rest.mdns/src/main/java/org/eclipse/smarthome/io/rest/mdns/internal/MDNSAnnouncer.java b/bundles/org.openhab.core.io.rest.mdns/src/main/java/org/eclipse/smarthome/io/rest/mdns/internal/MDNSAnnouncer.java index 21cd9b82e..e9b5ed689 100644 --- a/bundles/org.openhab.core.io.rest.mdns/src/main/java/org/eclipse/smarthome/io/rest/mdns/internal/MDNSAnnouncer.java +++ b/bundles/org.openhab.core.io.rest.mdns/src/main/java/org/eclipse/smarthome/io/rest/mdns/internal/MDNSAnnouncer.java @@ -91,7 +91,7 @@ public class MDNSAnnouncer { } private ServiceDescription getDefaultServiceDescription() { - Hashtable serviceProperties = new Hashtable(); + Hashtable serviceProperties = new Hashtable<>(); serviceProperties.put("uri", RESTConstants.REST_URI); return new ServiceDescription("_" + mdnsName + "-server._tcp.local.", mdnsName, httpPort, serviceProperties); } diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/SitemapSubscriptionService.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/SitemapSubscriptionService.java index c4b631379..20c3bdf2c 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/SitemapSubscriptionService.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/SitemapSubscriptionService.java @@ -268,7 +268,7 @@ public class SitemapSubscriptionService implements ModelRepositoryChangeListener } private EList collectWidgets(String sitemapName, String pageId) { - EList widgets = new BasicEList(); + EList widgets = new BasicEList<>(); Sitemap sitemap = getSitemap(sitemapName); if (sitemap != null) { diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/PageChangeListener.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/PageChangeListener.java index 358a271bc..9781181d8 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/PageChangeListener.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/PageChangeListener.java @@ -54,8 +54,7 @@ public class PageChangeListener implements StateChangeListener { private final ItemUIRegistry itemUIRegistry; private EList widgets; private Set items; - private final List callbacks = Collections - .synchronizedList(new ArrayList()); + private final List callbacks = Collections.synchronizedList(new ArrayList<>()); private Set distinctCallbacks = Collections.emptySet(); /** @@ -134,7 +133,7 @@ public class PageChangeListener implements StateChangeListener { * @return all items that are represented by the list of widgets */ private Set getAllItems(EList widgets) { - Set items = new HashSet(); + Set items = new HashSet<>(); if (itemUIRegistry != null) { for (Widget widget : widgets) { addItemWithName(items, widget.getItem()); @@ -235,8 +234,8 @@ public class PageChangeListener implements StateChangeListener { // the widget including its state (in event.item.state) final Item itemToBeSent = itemBelongsToWidget ? item : getItemForWidget(w); if (itemToBeSent != null) { - String widgetTypeName = w.eClass().getInstanceTypeName().substring( - w.eClass().getInstanceTypeName().lastIndexOf(".") + 1); + String widgetTypeName = w.eClass().getInstanceTypeName() + .substring(w.eClass().getInstanceTypeName().lastIndexOf(".") + 1); boolean drillDown = "mapview".equalsIgnoreCase(widgetTypeName); Predicate itemFilter = (i -> i.getType().equals(CoreItemFactory.LOCATION)); event.item = EnrichedItemDTOMapper.map(itemToBeSent, drillDown, itemFilter, null, null); diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/PageDTO.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/PageDTO.java index 521aee459..dc4ba6c4b 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/PageDTO.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/PageDTO.java @@ -31,7 +31,7 @@ public class PageDTO { public boolean leaf; public boolean timeout; - public List widgets = new ArrayList(); + public List widgets = new ArrayList<>(); public PageDTO() { } diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/SitemapResource.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/SitemapResource.java index 45f349a30..84da6a672 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/SitemapResource.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/SitemapResource.java @@ -400,7 +400,7 @@ public class SitemapResource implements RESTResource, SitemapSubscriptionCallbac } public Collection getSitemapBeans(URI uri) { - Collection beans = new LinkedList(); + Collection beans = new LinkedList<>(); Set names = new HashSet<>(); logger.debug("Received HTTP GET request at '{}'.", UriBuilder.fromUri(uri).build().toASCIIString()); for (SitemapProvider provider : sitemapProviders) { @@ -699,7 +699,7 @@ public class SitemapResource implements RESTResource, SitemapSubscriptionCallbac * @return all items that are represented by the list of widgets */ private Set getAllItems(EList widgets) { - Set items = new HashSet(); + Set items = new HashSet<>(); if (itemUIRegistry != null) { for (Widget widget : widgets) { // We skip the chart widgets having a refresh argument @@ -733,7 +733,7 @@ public class SitemapResource implements RESTResource, SitemapSubscriptionCallbac } private Set getItemsInVisibilityCond(EList ruleList) { - Set items = new HashSet(); + Set items = new HashSet<>(); for (VisibilityRule rule : ruleList) { String itemName = rule.getItem(); if (itemName != null) { @@ -751,7 +751,7 @@ public class SitemapResource implements RESTResource, SitemapSubscriptionCallbac } private Set getItemsInColorCond(EList colorList) { - Set items = new HashSet(); + Set items = new HashSet<>(); for (ColorArray color : colorList) { String itemName = color.getItem(); if (itemName != null) { diff --git a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/WidgetDTO.java b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/WidgetDTO.java index e3d10fa68..e224fb0aa 100644 --- a/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/WidgetDTO.java +++ b/bundles/org.openhab.core.io.rest.sitemap/src/main/java/org/eclipse/smarthome/io/rest/sitemap/internal/WidgetDTO.java @@ -37,7 +37,7 @@ public class WidgetDTO { public String valuecolor; // widget-specific attributes - public List mappings = new ArrayList(); + public final List mappings = new ArrayList<>(); public Boolean switchSupport; public Integer sendFrequency; public String separator; @@ -57,7 +57,7 @@ public class WidgetDTO { public PageDTO linkedPage; // only for frames, other linkable widgets link to a page - public final List widgets = new ArrayList(); + public final List widgets = new ArrayList<>(); public WidgetDTO() { } diff --git a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/eclipse/smarthome/io/rest/sse/internal/util/SseUtil.java b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/eclipse/smarthome/io/rest/sse/internal/util/SseUtil.java index 26f7d4a3d..0e758df1e 100644 --- a/bundles/org.openhab.core.io.rest.sse/src/main/java/org/eclipse/smarthome/io/rest/sse/internal/util/SseUtil.java +++ b/bundles/org.openhab.core.io.rest.sse/src/main/java/org/eclipse/smarthome/io/rest/sse/internal/util/SseUtil.java @@ -72,7 +72,7 @@ public class SseUtil { * @return */ public static List convertToRegex(String topicFilter) { - List filters = new ArrayList(); + List filters = new ArrayList<>(); if (StringUtils.isEmpty(topicFilter)) { filters.add(".*"); diff --git a/bundles/org.openhab.core.io.rest.voice/src/main/java/org/eclipse/smarthome/io/rest/voice/internal/HLIMapper.java b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/eclipse/smarthome/io/rest/voice/internal/HLIMapper.java index 6be3420ea..5e7fed45c 100644 --- a/bundles/org.openhab.core.io.rest.voice/src/main/java/org/eclipse/smarthome/io/rest/voice/internal/HLIMapper.java +++ b/bundles/org.openhab.core.io.rest.voice/src/main/java/org/eclipse/smarthome/io/rest/voice/internal/HLIMapper.java @@ -39,7 +39,7 @@ public class HLIMapper { dto.label = hli.getLabel(locale); final Set supportedLocales = hli.getSupportedLocales(); if (supportedLocales != null) { - dto.locales = new HashSet(supportedLocales.size()); + dto.locales = new HashSet<>(supportedLocales.size()); for (final Locale supportedLocale : supportedLocales) { dto.locales.add(supportedLocale.toString()); } diff --git a/bundles/org.openhab.core.io.rest/src/main/java/org/eclipse/smarthome/io/rest/internal/resources/RootResource.java b/bundles/org.openhab.core.io.rest/src/main/java/org/eclipse/smarthome/io/rest/internal/resources/RootResource.java index 3e199f0ce..224e0e4e4 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/eclipse/smarthome/io/rest/internal/resources/RootResource.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/eclipse/smarthome/io/rest/internal/resources/RootResource.java @@ -59,7 +59,7 @@ public class RootResource { private final transient Logger logger = LoggerFactory.getLogger(RootResource.class); - private List restResources = new ArrayList(); + private final List restResources = new ArrayList<>(); private ConfigurationAdmin configurationAdmin; diff --git a/bundles/org.openhab.core.io.rest/src/main/java/org/eclipse/smarthome/io/rest/internal/resources/beans/RootBean.java b/bundles/org.openhab.core.io.rest/src/main/java/org/eclipse/smarthome/io/rest/internal/resources/beans/RootBean.java index 35e136ddb..cea76cd1b 100644 --- a/bundles/org.openhab.core.io.rest/src/main/java/org/eclipse/smarthome/io/rest/internal/resources/beans/RootBean.java +++ b/bundles/org.openhab.core.io.rest/src/main/java/org/eclipse/smarthome/io/rest/internal/resources/beans/RootBean.java @@ -25,7 +25,7 @@ public class RootBean { public final String version = "3"; - public final List links = new ArrayList(); + public final List links = new ArrayList<>(); public static class Links { public Links(String type, String url) { diff --git a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/MqttBrokerConnection.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/MqttBrokerConnection.java index d24587120..de9f10de5 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/MqttBrokerConnection.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/MqttBrokerConnection.java @@ -115,7 +115,7 @@ public class MqttBrokerConnection { public class ConnectionCallback implements IMqttActionListener { private final MqttBrokerConnection connection; private final Runnable cancelTimeoutFuture; - private CompletableFuture future = new CompletableFuture(); + private CompletableFuture future = new CompletableFuture<>(); public ConnectionCallback(MqttBrokerConnection mqttBrokerConnectionImpl) { this.connection = mqttBrokerConnectionImpl; @@ -163,7 +163,7 @@ public class MqttBrokerConnection { } public CompletableFuture createFuture() { - future = new CompletableFuture(); + future = new CompletableFuture<>(); return future; } } @@ -481,7 +481,7 @@ public class MqttBrokerConnection { * @return Completes with true if successful. Completes with false if not connected yet. Exceptionally otherwise. */ public CompletableFuture subscribe(String topic, MqttMessageSubscriber subscriber) { - CompletableFuture future = new CompletableFuture(); + CompletableFuture future = new CompletableFuture<>(); synchronized (subscribers) { TopicSubscribers subscriberList = subscribers.getOrDefault(topic, new TopicSubscribers(topic)); subscribers.put(topic, subscriberList); @@ -513,7 +513,7 @@ public class MqttBrokerConnection { */ protected CompletableFuture subscribeRaw(String topic) { logger.trace("subscribeRaw message consumer for topic '{}' from broker '{}'", topic, host); - CompletableFuture future = new CompletableFuture(); + CompletableFuture future = new CompletableFuture<>(); try { MqttAsyncClient client = this.client; if (client != null && client.isConnected()) { @@ -569,7 +569,7 @@ public class MqttBrokerConnection { */ protected CompletableFuture unsubscribeRaw(MqttAsyncClient client, String topic) { logger.trace("Unsubscribing message consumer for topic '{}' from broker '{}'", topic, host); - CompletableFuture future = new CompletableFuture(); + CompletableFuture future = new CompletableFuture<>(); try { if (client.isConnected()) { client.unsubscribe(topic, future, actionCallback); @@ -823,7 +823,7 @@ public class MqttBrokerConnection { reconnectStrategy.stop(); } - CompletableFuture future = new CompletableFuture(); + CompletableFuture future = new CompletableFuture<>(); // Close connection if (client.isConnected()) { // We need to thread change here. Because paho does not allow to disconnect within a callback method @@ -910,7 +910,7 @@ public class MqttBrokerConnection { return CompletableFuture.completedFuture(false); } // publish message asynchronously - CompletableFuture f = new CompletableFuture(); + CompletableFuture f = new CompletableFuture<>(); try { client.publish(topic, payload, qos, retain, f, actionCallback); } catch (org.eclipse.paho.client.mqttv3.MqttException e) { diff --git a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/internal/MqttServiceImpl.java b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/internal/MqttServiceImpl.java index 4951c2d1b..318302be8 100644 --- a/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/internal/MqttServiceImpl.java +++ b/bundles/org.openhab.core.io.transport.mqtt/src/main/java/org/eclipse/smarthome/io/transport/mqtt/internal/MqttServiceImpl.java @@ -46,7 +46,7 @@ import org.slf4j.LoggerFactory; @NonNullByDefault public class MqttServiceImpl implements MqttService { private final Logger logger = LoggerFactory.getLogger(MqttServiceImpl.class); - private final Map brokerConnections = new ConcurrentHashMap(); + private final Map brokerConnections = new ConcurrentHashMap<>(); private final List brokersObservers = new CopyOnWriteArrayList<>(); @Override diff --git a/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/eclipse/smarthome/io/transport/serial/internal/SerialPortUtil.java b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/eclipse/smarthome/io/transport/serial/internal/SerialPortUtil.java index 1ec56b623..579a11e34 100644 --- a/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/eclipse/smarthome/io/transport/serial/internal/SerialPortUtil.java +++ b/bundles/org.openhab.core.io.transport.serial.rxtx/src/main/java/org/eclipse/smarthome/io/transport/serial/internal/SerialPortUtil.java @@ -109,7 +109,7 @@ public class SerialPortUtil { if (serialPortsProperty != null) { serialPorts = Stream.of(serialPortsProperty.split(pathSeparator)).collect(Collectors.toSet()); } else { - serialPorts = new HashSet(); + serialPorts = new HashSet<>(); } if (serialPorts.add(port)) { return serialPorts.stream().collect(Collectors.joining(pathSeparator)); // see diff --git a/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/eclipse/smarthome/io/transport/upnp/internal/UpnpIOServiceImpl.java b/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/eclipse/smarthome/io/transport/upnp/internal/UpnpIOServiceImpl.java index f03d806a3..ad8d3c59b 100644 --- a/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/eclipse/smarthome/io/transport/upnp/internal/UpnpIOServiceImpl.java +++ b/bundles/org.openhab.core.io.transport.upnp/src/main/java/org/eclipse/smarthome/io/transport/upnp/internal/UpnpIOServiceImpl.java @@ -78,9 +78,9 @@ public class UpnpIOServiceImpl implements UpnpIOService, RegistryListener { private UpnpService upnpService; final Set participants = new CopyOnWriteArraySet<>(); - final Map pollingJobs = new ConcurrentHashMap(); - final Map currentStates = new ConcurrentHashMap(); - final Map subscriptionCallbacks = new ConcurrentHashMap(); + final Map pollingJobs = new ConcurrentHashMap<>(); + final Map currentStates = new ConcurrentHashMap<>(); + final Map subscriptionCallbacks = new ConcurrentHashMap<>(); public class UpnpSubscriptionCallback extends SubscriptionCallback { @@ -288,7 +288,7 @@ public class UpnpIOServiceImpl implements UpnpIOService, RegistryListener { @Override public Map invokeAction(UpnpIOParticipant participant, String serviceID, String actionID, Map inputs) { - HashMap resultMap = new HashMap<>(); + Map resultMap = new HashMap<>(); if (serviceID != null && actionID != null && participant != null) { registerParticipant(participant); diff --git a/bundles/org.openhab.core.model.core/src/main/java/org/eclipse/smarthome/model/core/internal/ModelRepositoryImpl.java b/bundles/org.openhab.core.model.core/src/main/java/org/eclipse/smarthome/model/core/internal/ModelRepositoryImpl.java index faec900c4..c0c55fe55 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/eclipse/smarthome/model/core/internal/ModelRepositoryImpl.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/eclipse/smarthome/model/core/internal/ModelRepositoryImpl.java @@ -121,7 +121,7 @@ public class ModelRepositoryImpl implements ModelRepository { resource = resourceSet.createResource(URI.createURI(name)); if (resource != null) { logger.info("Loading model '{}'", name); - Map options = new HashMap(); + Map options = new HashMap<>(); options.put(XtextResource.OPTION_ENCODING, "UTF-8"); if (inputStream == null) { logger.warn( @@ -178,7 +178,7 @@ public class ModelRepositoryImpl implements ModelRepository { public Iterable getAllModelNamesOfType(final String modelType) { synchronized (resourceSet) { // Make a copy to avoid ConcurrentModificationException - List resourceListCopy = new ArrayList(resourceSet.getResources()); + List resourceListCopy = new ArrayList<>(resourceSet.getResources()); return resourceListCopy.stream().filter(input -> { return input != null && input.getURI().lastSegment().contains(".") && input.isLoaded() @@ -193,7 +193,7 @@ public class ModelRepositoryImpl implements ModelRepository { public void reloadAllModelsOfType(final String modelType) { synchronized (resourceSet) { // Make a copy to avoid ConcurrentModificationException - List resourceListCopy = new ArrayList(resourceSet.getResources()); + List resourceListCopy = new ArrayList<>(resourceSet.getResources()); for (Resource resource : resourceListCopy) { if (resource != null && resource.getURI().lastSegment().contains(".") && resource.isLoaded()) { if (modelType.equalsIgnoreCase(resource.getURI().fileExtension())) { @@ -215,7 +215,7 @@ public class ModelRepositoryImpl implements ModelRepository { Set ret = new HashSet<>(); synchronized (resourceSet) { // Make a copy to avoid ConcurrentModificationException - List resourceListCopy = new ArrayList(resourceSet.getResources()); + List resourceListCopy = new ArrayList<>(resourceSet.getResources()); for (Resource resource : resourceListCopy) { if (resource != null && resource.getURI().lastSegment().contains(".") && resource.isLoaded()) { if (modelType.equalsIgnoreCase(resource.getURI().fileExtension())) { diff --git a/bundles/org.openhab.core.model.core/src/main/java/org/eclipse/smarthome/model/core/internal/folder/FolderObserver.java b/bundles/org.openhab.core.model.core/src/main/java/org/eclipse/smarthome/model/core/internal/folder/FolderObserver.java index c4248d25a..092e261ca 100644 --- a/bundles/org.openhab.core.model.core/src/main/java/org/eclipse/smarthome/model/core/internal/folder/FolderObserver.java +++ b/bundles/org.openhab.core.model.core/src/main/java/org/eclipse/smarthome/model/core/internal/folder/FolderObserver.java @@ -68,7 +68,7 @@ public class FolderObserver extends AbstractWatchService { private ModelRepository modelRepo = null; /* map that stores a list of valid file extensions for each folder */ - private final Map folderFileExtMap = new ConcurrentHashMap(); + private final Map folderFileExtMap = new ConcurrentHashMap<>(); /* set of file extensions for which we have parsers already registered */ private final Set parsers = new HashSet<>(); @@ -144,7 +144,7 @@ public class FolderObserver extends AbstractWatchService { } private void processIgnoredFiles(String extension) { - HashSet clonedSet = new HashSet<>(this.ignoredFiles); + Set clonedSet = new HashSet<>(this.ignoredFiles); for (File file : clonedSet) { if (extension.equals(getExtension(file.getPath()))) { checkFile(modelRepo, file, ENTRY_CREATE); diff --git a/bundles/org.openhab.core.model.item/src/org/eclipse/smarthome/model/item/internal/GenericItemProvider.java b/bundles/org.openhab.core.model.item/src/org/eclipse/smarthome/model/item/internal/GenericItemProvider.java index 3ab687ebd..04d2af058 100644 --- a/bundles/org.openhab.core.model.item/src/org/eclipse/smarthome/model/item/internal/GenericItemProvider.java +++ b/bundles/org.openhab.core.model.item/src/org/eclipse/smarthome/model/item/internal/GenericItemProvider.java @@ -75,7 +75,7 @@ public class GenericItemProvider extends AbstractProvider private final Logger logger = LoggerFactory.getLogger(GenericItemProvider.class); /** to keep track of all binding config readers */ - private final Map bindingConfigReaders = new HashMap(); + private final Map bindingConfigReaders = new HashMap<>(); private final ModelRepository modelRepository; @@ -83,7 +83,7 @@ public class GenericItemProvider extends AbstractProvider private final Map> itemsMap = new ConcurrentHashMap<>(); - private final Collection itemFactorys = new ArrayList(); + private final Collection itemFactorys = new ArrayList<>(); private final Map stateDescriptionFragments = new ConcurrentHashMap<>(); @@ -160,7 +160,7 @@ public class GenericItemProvider extends AbstractProvider @Override public Collection getAll() { - List items = new ArrayList(); + List items = new ArrayList<>(); stateDescriptionFragments.clear(); for (String name : modelRepository.getAllModelNamesOfType("items")) { items.addAll(getItemsFromModel(name)); @@ -171,7 +171,7 @@ public class GenericItemProvider extends AbstractProvider private Collection getItemsFromModel(String modelName) { logger.debug("Read items from model '{}'", modelName); - List items = new ArrayList(); + List items = new ArrayList<>(); ItemModel model = (ItemModel) modelRepository.getModel(modelName); if (model != null) { for (ModelItem modelItem : model.getItems()) { diff --git a/bundles/org.openhab.core.model.rule.runtime/src/org/eclipse/smarthome/model/rule/runtime/internal/engine/RuleTriggerManager.java b/bundles/org.openhab.core.model.rule.runtime/src/org/eclipse/smarthome/model/rule/runtime/internal/engine/RuleTriggerManager.java index 01698175c..a589048a7 100644 --- a/bundles/org.openhab.core.model.rule.runtime/src/org/eclipse/smarthome/model/rule/runtime/internal/engine/RuleTriggerManager.java +++ b/bundles/org.openhab.core.model.rule.runtime/src/org/eclipse/smarthome/model/rule/runtime/internal/engine/RuleTriggerManager.java @@ -374,7 +374,7 @@ public class RuleTriggerManager { if ((!isGroup) && (t instanceof CommandEventTrigger)) { final CommandEventTrigger ct = (CommandEventTrigger) t; if (ct.getItem().equals(name)) { - triggerCommandString = ct.getCommand()!=null?ct.getCommand().getValue() : null; + triggerCommandString = ct.getCommand() != null ? ct.getCommand().getValue() : null; } else { continue; } @@ -574,7 +574,7 @@ public class RuleTriggerManager { CommandEventTrigger ceTrigger = (CommandEventTrigger) t; Set rules = commandEventTriggeredRules.get(ceTrigger.getItem()); if (rules == null) { - rules = new HashSet(); + rules = new HashSet<>(); commandEventTriggeredRules.put(ceTrigger.getItem(), rules); } rules.add(rule); @@ -582,7 +582,7 @@ public class RuleTriggerManager { GroupMemberCommandEventTrigger gmceTrigger = (GroupMemberCommandEventTrigger) t; Set rules = commandEventTriggeredRules.get(GROUP_NAME_PREFIX + gmceTrigger.getGroup()); if (rules == null) { - rules = new HashSet(); + rules = new HashSet<>(); commandEventTriggeredRules.put(GROUP_NAME_PREFIX + gmceTrigger.getGroup(), rules); } rules.add(rule); @@ -590,7 +590,7 @@ public class RuleTriggerManager { UpdateEventTrigger ueTrigger = (UpdateEventTrigger) t; Set rules = updateEventTriggeredRules.get(ueTrigger.getItem()); if (rules == null) { - rules = new HashSet(); + rules = new HashSet<>(); updateEventTriggeredRules.put(ueTrigger.getItem(), rules); } rules.add(rule); @@ -598,7 +598,7 @@ public class RuleTriggerManager { GroupMemberUpdateEventTrigger gmueTrigger = (GroupMemberUpdateEventTrigger) t; Set rules = updateEventTriggeredRules.get(GROUP_NAME_PREFIX + gmueTrigger.getGroup()); if (rules == null) { - rules = new HashSet(); + rules = new HashSet<>(); updateEventTriggeredRules.put(GROUP_NAME_PREFIX + gmueTrigger.getGroup(), rules); } rules.add(rule); @@ -606,7 +606,7 @@ public class RuleTriggerManager { ChangedEventTrigger ceTrigger = (ChangedEventTrigger) t; Set rules = changedEventTriggeredRules.get(ceTrigger.getItem()); if (rules == null) { - rules = new HashSet(); + rules = new HashSet<>(); changedEventTriggeredRules.put(ceTrigger.getItem(), rules); } rules.add(rule); @@ -614,7 +614,7 @@ public class RuleTriggerManager { GroupMemberChangedEventTrigger gmceTrigger = (GroupMemberChangedEventTrigger) t; Set rules = changedEventTriggeredRules.get(GROUP_NAME_PREFIX + gmceTrigger.getGroup()); if (rules == null) { - rules = new HashSet(); + rules = new HashSet<>(); changedEventTriggeredRules.put(GROUP_NAME_PREFIX + gmceTrigger.getGroup(), rules); } rules.add(rule); @@ -629,7 +629,7 @@ public class RuleTriggerManager { EventEmittedTrigger eeTrigger = (EventEmittedTrigger) t; Set rules = triggerEventTriggeredRules.get(eeTrigger.getChannel()); if (rules == null) { - rules = new HashSet(); + rules = new HashSet<>(); triggerEventTriggeredRules.put(eeTrigger.getChannel(), rules); } rules.add(rule); @@ -637,7 +637,7 @@ public class RuleTriggerManager { ThingStateUpdateEventTrigger tsuTrigger = (ThingStateUpdateEventTrigger) t; Set rules = thingUpdateEventTriggeredRules.get(tsuTrigger.getThing()); if (rules == null) { - rules = new HashSet(); + rules = new HashSet<>(); thingUpdateEventTriggeredRules.put(tsuTrigger.getThing(), rules); } rules.add(rule); @@ -645,7 +645,7 @@ public class RuleTriggerManager { ThingStateChangedEventTrigger tscTrigger = (ThingStateChangedEventTrigger) t; Set rules = thingChangedEventTriggeredRules.get(tscTrigger.getThing()); if (rules == null) { - rules = new HashSet(); + rules = new HashSet<>(); thingChangedEventTriggeredRules.put(tscTrigger.getThing(), rules); } rules.add(rule); @@ -734,7 +734,7 @@ public class RuleTriggerManager { private void removeRules(TriggerTypes type, Collection> ruleSets, RuleModel model) { for (Collection ruleSet : ruleSets) { - Set clonedSet = new HashSet(ruleSet); + Set clonedSet = new HashSet<>(ruleSet); // first remove all rules of the model, if not null (=non-existent) if (model != null) { for (Rule newRule : model.getRules()) { @@ -750,7 +750,7 @@ public class RuleTriggerManager { } // now also remove all proxified rules from the set - clonedSet = new HashSet(ruleSet); + clonedSet = new HashSet<>(ruleSet); for (Rule rule : clonedSet) { if (rule.eResource() == null) { ruleSet.remove(rule); diff --git a/bundles/org.openhab.core.model.script/src/org/eclipse/smarthome/model/script/engine/ScriptException.java b/bundles/org.openhab.core.model.script/src/org/eclipse/smarthome/model/script/engine/ScriptException.java index 937bc13ae..d11f5782b 100644 --- a/bundles/org.openhab.core.model.script/src/org/eclipse/smarthome/model/script/engine/ScriptException.java +++ b/bundles/org.openhab.core.model.script/src/org/eclipse/smarthome/model/script/engine/ScriptException.java @@ -29,13 +29,13 @@ public abstract class ScriptException extends Exception { protected ScriptException(String message) { super(message); - this.errors = new ArrayList(1); + this.errors = new ArrayList<>(1); errors.add(new ScriptError(message, 0, 0, -1)); } protected ScriptException(ScriptError scriptError) { super(scriptError.getMessage()); - this.errors = new ArrayList(1); + this.errors = new ArrayList<>(1); errors.add(scriptError); } @@ -46,13 +46,13 @@ public abstract class ScriptException extends Exception { protected ScriptException(final String message, final String scriptText, final Throwable cause) { super(message, cause); this.scriptText = scriptText; - this.errors = new LinkedList(); + this.errors = new LinkedList<>(); } protected ScriptException(final String message, final String scriptText) { super(message); this.scriptText = scriptText; - this.errors = new LinkedList(); + this.errors = new LinkedList<>(); } public ScriptException(final String message, final String scriptText, final int line, final int column, @@ -68,7 +68,7 @@ public abstract class ScriptException extends Exception { private ScriptException(final Throwable cause, final String scriptText, final ScriptError error) { super(error.getMessage(), cause); // ? this.scriptText = scriptText; - this.errors = new ArrayList(1); + this.errors = new ArrayList<>(1); errors.add(error); } @@ -80,13 +80,13 @@ public abstract class ScriptException extends Exception { private ScriptException(final String scriptText, final ScriptError error) { super(error.getMessage()); // ? this.scriptText = scriptText; - this.errors = new ArrayList(1); + this.errors = new ArrayList<>(1); errors.add(error); } public ScriptException(String message, Throwable cause) { super(message, cause); - this.errors = new ArrayList(0); + this.errors = new ArrayList<>(0); } /** diff --git a/bundles/org.openhab.core.model.script/src/org/eclipse/smarthome/model/script/scoping/ScriptImplicitlyImportedTypes.java b/bundles/org.openhab.core.model.script/src/org/eclipse/smarthome/model/script/scoping/ScriptImplicitlyImportedTypes.java index 4a1df987d..d9b1d1a8e 100644 --- a/bundles/org.openhab.core.model.script/src/org/eclipse/smarthome/model/script/scoping/ScriptImplicitlyImportedTypes.java +++ b/bundles/org.openhab.core.model.script/src/org/eclipse/smarthome/model/script/scoping/ScriptImplicitlyImportedTypes.java @@ -117,8 +117,7 @@ public class ScriptImplicitlyImportedTypes extends ImplicitlyImportedFeatures { } protected List> getActionClasses() { - - List> localActionClasses = new ArrayList>(); + List> localActionClasses = new ArrayList<>(); List services = actionServiceProvider.get(); if (services != null) { diff --git a/bundles/org.openhab.core.model.thing/src.moved/test/java/org/eclipse/smarthome/model/thing/internal/GenericThingProviderMultipleBundlesTest.java b/bundles/org.openhab.core.model.thing/src.moved/test/java/org/eclipse/smarthome/model/thing/internal/GenericThingProviderMultipleBundlesTest.java index 9935178b0..5f326858c 100644 --- a/bundles/org.openhab.core.model.thing/src.moved/test/java/org/eclipse/smarthome/model/thing/internal/GenericThingProviderMultipleBundlesTest.java +++ b/bundles/org.openhab.core.model.thing/src.moved/test/java/org/eclipse/smarthome/model/thing/internal/GenericThingProviderMultipleBundlesTest.java @@ -99,7 +99,7 @@ public class GenericThingProviderMultipleBundlesTest { EList modelThings = createModelThing(); when(bridge.getThings()).thenReturn(modelThings); - BasicEList result = new BasicEList(); + BasicEList result = new BasicEList<>(); result.add(bridge); return result; } @@ -113,7 +113,7 @@ public class GenericThingProviderMultipleBundlesTest { when(thing.getProperties()).thenReturn(new BasicEList<>(0)); when(thing.getChannels()).thenReturn(new BasicEList<>(0)); - BasicEList result = new BasicEList(); + BasicEList result = new BasicEList<>(); result.add(thing); return result; } diff --git a/bundles/org.openhab.core.persistence/src/main/java/org/eclipse/smarthome/core/persistence/dto/ItemHistoryDTO.java b/bundles/org.openhab.core.persistence/src/main/java/org/eclipse/smarthome/core/persistence/dto/ItemHistoryDTO.java index 8ed46d9f7..ce55764cb 100644 --- a/bundles/org.openhab.core.persistence/src/main/java/org/eclipse/smarthome/core/persistence/dto/ItemHistoryDTO.java +++ b/bundles/org.openhab.core.persistence/src/main/java/org/eclipse/smarthome/core/persistence/dto/ItemHistoryDTO.java @@ -28,7 +28,7 @@ public class ItemHistoryDTO { public String totalrecords; public String datapoints; - public List data = new ArrayList(); + public List data = new ArrayList<>(); public ItemHistoryDTO() { }; diff --git a/bundles/org.openhab.core.storage.json/src/main/java/org/eclipse/smarthome/storage/json/internal/JsonStorageService.java b/bundles/org.openhab.core.storage.json/src/main/java/org/eclipse/smarthome/storage/json/internal/JsonStorageService.java index 976d22eb9..b0e35b8cb 100644 --- a/bundles/org.openhab.core.storage.json/src/main/java/org/eclipse/smarthome/storage/json/internal/JsonStorageService.java +++ b/bundles/org.openhab.core.storage.json/src/main/java/org/eclipse/smarthome/storage/json/internal/JsonStorageService.java @@ -127,8 +127,7 @@ public class JsonStorageService implements StorageService { file = legacyFile; } - JsonStorage newStorage = new JsonStorage(file, classLoader, maxBackupFiles, writeDelay, - maxDeferredPeriod); + JsonStorage newStorage = new JsonStorage<>(file, classLoader, maxBackupFiles, writeDelay, maxDeferredPeriod); JsonStorage oldStorage = storageList.put(name, (JsonStorage) newStorage); if (oldStorage != null) { diff --git a/bundles/org.openhab.core.test.magic/src/main/java/org/eclipse/smarthome/magic/binding/handler/MagicChattyThingHandler.java b/bundles/org.openhab.core.test.magic/src/main/java/org/eclipse/smarthome/magic/binding/handler/MagicChattyThingHandler.java index 48ff0362b..f33d694dd 100644 --- a/bundles/org.openhab.core.test.magic/src/main/java/org/eclipse/smarthome/magic/binding/handler/MagicChattyThingHandler.java +++ b/bundles/org.openhab.core.test.magic/src/main/java/org/eclipse/smarthome/magic/binding/handler/MagicChattyThingHandler.java @@ -21,8 +21,6 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.measure.quantity.Temperature; - import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.smarthome.config.core.Configuration; @@ -98,7 +96,7 @@ public class MagicChattyThingHandler extends BaseThingHandler { int intValue = (int) randomValue; State cmd; if (intValue % 2 == 0) { - cmd = new QuantityType(randomValue + "°C"); + cmd = new QuantityType<>(randomValue + "°C"); } else { cmd = new DecimalType(randomValue); } diff --git a/bundles/org.openhab.core.test/src/main/java/org/eclipse/smarthome/test/storage/VolatileStorage.java b/bundles/org.openhab.core.test/src/main/java/org/eclipse/smarthome/test/storage/VolatileStorage.java index b60f9878c..b557e831b 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/eclipse/smarthome/test/storage/VolatileStorage.java +++ b/bundles/org.openhab.core.test/src/main/java/org/eclipse/smarthome/test/storage/VolatileStorage.java @@ -29,7 +29,7 @@ import org.eclipse.smarthome.core.storage.Storage; @NonNullByDefault public class VolatileStorage implements Storage { - Map storage = new ConcurrentHashMap(); + Map storage = new ConcurrentHashMap<>(); @Override public @Nullable T put(String key, @Nullable T value) { diff --git a/bundles/org.openhab.core.test/src/main/java/org/eclipse/smarthome/test/storage/VolatileStorageService.java b/bundles/org.openhab.core.test/src/main/java/org/eclipse/smarthome/test/storage/VolatileStorageService.java index 98dc2cc9a..1740cec0b 100644 --- a/bundles/org.openhab.core.test/src/main/java/org/eclipse/smarthome/test/storage/VolatileStorageService.java +++ b/bundles/org.openhab.core.test/src/main/java/org/eclipse/smarthome/test/storage/VolatileStorageService.java @@ -27,13 +27,13 @@ import org.eclipse.smarthome.core.storage.StorageService; public class VolatileStorageService implements StorageService { @SuppressWarnings("rawtypes") - Map storages = new ConcurrentHashMap(); + Map storages = new ConcurrentHashMap<>(); @Override @SuppressWarnings("unchecked") public synchronized Storage getStorage(String name) { if (!storages.containsKey(name)) { - storages.put(name, new VolatileStorage()); + storages.put(name, new VolatileStorage<>()); } return storages.get(name); } diff --git a/bundles/org.openhab.core.thing.xml/src/main/java/org/eclipse/smarthome/core/thing/xml/internal/XmlThingTypeProvider.java b/bundles/org.openhab.core.thing.xml/src/main/java/org/eclipse/smarthome/core/thing/xml/internal/XmlThingTypeProvider.java index 9fc6e29db..f8de33f47 100644 --- a/bundles/org.openhab.core.thing.xml/src/main/java/org/eclipse/smarthome/core/thing/xml/internal/XmlThingTypeProvider.java +++ b/bundles/org.openhab.core.thing.xml/src/main/java/org/eclipse/smarthome/core/thing/xml/internal/XmlThingTypeProvider.java @@ -75,7 +75,7 @@ public class XmlThingTypeProvider extends AbstractXmlBasedProvider> thingTypeReader = new ThingDescriptionReader(); - thingTypeTracker = new XmlDocumentBundleTracker>(bundleContext, XML_DIRECTORY, thingTypeReader, this, + thingTypeTracker = new XmlDocumentBundleTracker<>(bundleContext, XML_DIRECTORY, thingTypeReader, this, READY_MARKER, readyService); trackerJob = scheduler.submit(() -> { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/Channel.java b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/Channel.java index c59e5717b..c345a5b00 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/Channel.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/Channel.java @@ -70,7 +70,7 @@ public class Channel { Channel() { this.kind = ChannelKind.STATE; this.configuration = new Configuration(); - this.properties = Collections.unmodifiableMap(new HashMap(0)); + this.properties = Collections.unmodifiableMap(new HashMap<>(0)); } /** @@ -82,7 +82,7 @@ public class Channel { this.acceptedItemType = acceptedItemType; this.kind = ChannelKind.STATE; this.configuration = new Configuration(); - this.properties = Collections.unmodifiableMap(new HashMap(0)); + this.properties = Collections.unmodifiableMap(new HashMap<>(0)); } /** @@ -90,8 +90,7 @@ public class Channel { */ @Deprecated public Channel(ChannelUID uid, String acceptedItemType, Configuration configuration) { - this(uid, null, acceptedItemType, ChannelKind.STATE, configuration, new HashSet(0), null, null, null, - null); + this(uid, null, acceptedItemType, ChannelKind.STATE, configuration, new HashSet<>(0), null, null, null, null); } /** @@ -126,14 +125,14 @@ public class Channel { this.label = label; this.description = description; this.autoUpdatePolicy = autoUpdatePolicy; - this.defaultTags = Collections. unmodifiableSet(new HashSet(defaultTags)); + this.defaultTags = Collections. unmodifiableSet(new HashSet<>(defaultTags)); if (configuration == null) { this.configuration = new Configuration(); } else { this.configuration = configuration; } if (properties == null) { - this.properties = Collections.unmodifiableMap(new HashMap(0)); + this.properties = Collections.unmodifiableMap(new HashMap<>(0)); } else { this.properties = properties; } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/binding/BaseThingHandlerFactory.java b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/binding/BaseThingHandlerFactory.java index 8b4720d17..24396599c 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/binding/BaseThingHandlerFactory.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/binding/BaseThingHandlerFactory.java @@ -14,6 +14,7 @@ package org.eclipse.smarthome.core.thing.binding; import java.util.HashSet; import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -158,7 +159,7 @@ public abstract class BaseThingHandlerFactory implements ThingHandlerFactory { } Class[] interfaces = c.getInterfaces(); - LinkedList serviceNames = new LinkedList<>(); + List serviceNames = new LinkedList<>(); if (interfaces != null) { for (Class i : interfaces) { String className = i.getCanonicalName(); @@ -179,7 +180,7 @@ public abstract class BaseThingHandlerFactory implements ThingHandlerFactory { if (serviceReg != null) { Set> serviceRegs = this.thingHandlerServices.get(thingUID); if (serviceRegs == null) { - HashSet> set = new HashSet<>(); + Set> set = new HashSet<>(); set.add(serviceReg); this.thingHandlerServices.put(thingUID, set); } else { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/binding/builder/ChannelBuilder.java b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/binding/builder/ChannelBuilder.java index e24f12c30..fc7a0262d 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/binding/builder/ChannelBuilder.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/binding/builder/ChannelBuilder.java @@ -62,7 +62,7 @@ public class ChannelBuilder { * @return channel builder */ public static ChannelBuilder create(ChannelUID channelUID, @Nullable String acceptedItemType) { - return new ChannelBuilder(channelUID, acceptedItemType, new HashSet()); + return new ChannelBuilder(channelUID, acceptedItemType, new HashSet<>()); } /** diff --git a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/internal/profiles/SystemOffsetProfile.java b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/internal/profiles/SystemOffsetProfile.java index 01f69d389..ed14f19de 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/internal/profiles/SystemOffsetProfile.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/internal/profiles/SystemOffsetProfile.java @@ -15,7 +15,6 @@ package org.eclipse.smarthome.core.thing.internal.profiles; import java.math.BigDecimal; import javax.measure.UnconvertibleException; -import javax.measure.quantity.Dimensionless; import javax.measure.quantity.Temperature; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -115,7 +114,7 @@ public class SystemOffsetProfile implements StateProfile { if (finalOffset == null) { logger.warn( "Offset not configured correctly, please make sure it is of type QuantityType, e.g. \"3\", \"-1.4\", \"3.2°C\". Using offset 0 now."); - finalOffset = new QuantityType("0"); + finalOffset = new QuantityType<>("0"); } if (!towardsItem) { diff --git a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/type/ChannelGroupType.java b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/type/ChannelGroupType.java index d5d937f01..3746996d2 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/type/ChannelGroupType.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/type/ChannelGroupType.java @@ -58,7 +58,7 @@ public class ChannelGroupType extends AbstractDescriptionType { if (channelDefinitions != null) { this.channelDefinitions = Collections.unmodifiableList(channelDefinitions); } else { - this.channelDefinitions = Collections.unmodifiableList(new ArrayList(0)); + this.channelDefinitions = Collections.unmodifiableList(new ArrayList<>(0)); } } @@ -87,7 +87,7 @@ public class ChannelGroupType extends AbstractDescriptionType { if (channelDefinitions != null) { this.channelDefinitions = Collections.unmodifiableList(channelDefinitions); } else { - this.channelDefinitions = Collections.unmodifiableList(new ArrayList(0)); + this.channelDefinitions = Collections.unmodifiableList(new ArrayList<>(0)); } } diff --git a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/type/ChannelType.java b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/type/ChannelType.java index bc0b53dd5..3b7685b37 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/type/ChannelType.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/type/ChannelType.java @@ -147,9 +147,9 @@ public class ChannelType extends AbstractDescriptionType { this.configDescriptionURI = configDescriptionURI; if (tags != null) { - this.tags = Collections.unmodifiableSet(new HashSet(tags)); + this.tags = Collections.unmodifiableSet(new HashSet<>(tags)); } else { - this.tags = Collections.unmodifiableSet(new HashSet(0)); + this.tags = Collections.unmodifiableSet(new HashSet<>(0)); } this.advanced = advanced; diff --git a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/util/ThingHelper.java b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/util/ThingHelper.java index cbe52efe7..0cfb804d1 100644 --- a/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/util/ThingHelper.java +++ b/bundles/org.openhab.core.thing/src/main/java/org/eclipse/smarthome/core/thing/util/ThingHelper.java @@ -19,6 +19,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import org.apache.commons.collections.iterators.ArrayIterator; @@ -112,7 +113,7 @@ public class ThingHelper { */ @Deprecated public static void ensureUnique(Collection channels) { - HashSet ids = new HashSet<>(); + Set ids = new HashSet<>(); for (Channel channel : channels) { if (!ids.add(channel.getUID())) { throw new IllegalArgumentException("Duplicate channels " + channel.getUID().getAsString()); @@ -130,7 +131,7 @@ public class ThingHelper { @SuppressWarnings("unchecked") final Iterator it = new ArrayIterator(channels); - ensureUniqueChannels(it, new HashSet(channels.length)); + ensureUniqueChannels(it, new HashSet<>(channels.length)); } /** @@ -140,7 +141,7 @@ public class ThingHelper { * @throws IllegalArgumentException in case there are duplicate channels found */ public static void ensureUniqueChannels(final Collection channels) { - ensureUniqueChannels(channels.iterator(), new HashSet(channels.size())); + ensureUniqueChannels(channels.iterator(), new HashSet<>(channels.size())); } /** @@ -157,7 +158,7 @@ public class ThingHelper { private static void ensureUniqueChannels(final Collection channels1, final Collection channels2) { ensureUniqueChannels(channels1.iterator(), - ensureUniqueChannels(channels2.iterator(), new HashSet(channels1.size() + channels2.size()))); + ensureUniqueChannels(channels2.iterator(), new HashSet<>(channels1.size() + channels2.size()))); } private static HashSet ensureUniqueChannels(final Iterator channels, final HashSet ids) { diff --git a/bundles/org.openhab.core.thing/src/test/java/org/eclipse/smarthome/core/thing/internal/profiles/SystemOffsetProfileTest.java b/bundles/org.openhab.core.thing/src/test/java/org/eclipse/smarthome/core/thing/internal/profiles/SystemOffsetProfileTest.java index 47dc43f06..614ffc59a 100644 --- a/bundles/org.openhab.core.thing/src/test/java/org/eclipse/smarthome/core/thing/internal/profiles/SystemOffsetProfileTest.java +++ b/bundles/org.openhab.core.thing/src/test/java/org/eclipse/smarthome/core/thing/internal/profiles/SystemOffsetProfileTest.java @@ -84,7 +84,7 @@ public class SystemOffsetProfileTest { ProfileCallback callback = mock(ProfileCallback.class); SystemOffsetProfile offsetProfile = createProfile(callback, "3°C"); - Command cmd = new QuantityType("23°C"); + Command cmd = new QuantityType<>("23°C"); offsetProfile.onCommandFromItem(cmd); ArgumentCaptor capture = ArgumentCaptor.forClass(Command.class); @@ -102,7 +102,7 @@ public class SystemOffsetProfileTest { ProfileCallback callback = mock(ProfileCallback.class); SystemOffsetProfile offsetProfile = createProfile(callback, "3°C"); - State state = new QuantityType("23°C"); + State state = new QuantityType<>("23°C"); offsetProfile.onStateUpdateFromItem(state); ArgumentCaptor capture = ArgumentCaptor.forClass(State.class); @@ -152,7 +152,7 @@ public class SystemOffsetProfileTest { ProfileCallback callback = mock(ProfileCallback.class); SystemOffsetProfile offsetProfile = createProfile(callback, "3°C"); - Command cmd = new QuantityType("23°C"); + Command cmd = new QuantityType<>("23°C"); offsetProfile.onCommandFromHandler(cmd); ArgumentCaptor capture = ArgumentCaptor.forClass(Command.class); @@ -170,7 +170,7 @@ public class SystemOffsetProfileTest { ProfileCallback callback = mock(ProfileCallback.class); SystemOffsetProfile offsetProfile = createProfile(callback, "3°C"); - State state = new QuantityType("23°C"); + State state = new QuantityType<>("23°C"); offsetProfile.onStateUpdateFromHandler(state); ArgumentCaptor capture = ArgumentCaptor.forClass(State.class); @@ -188,7 +188,7 @@ public class SystemOffsetProfileTest { ProfileCallback callback = mock(ProfileCallback.class); SystemOffsetProfile offsetProfile = createProfile(callback, "3 °F"); - State state = new QuantityType("23 °C"); + State state = new QuantityType<>("23 °C"); offsetProfile.onStateUpdateFromHandler(state); ArgumentCaptor capture = ArgumentCaptor.forClass(State.class); @@ -206,7 +206,7 @@ public class SystemOffsetProfileTest { ProfileCallback callback = mock(ProfileCallback.class); SystemOffsetProfile offsetProfile = createProfile(callback, "3"); - State state = new QuantityType("23 °C"); + State state = new QuantityType<>("23 °C"); offsetProfile.onStateUpdateFromHandler(state); ArgumentCaptor capture = ArgumentCaptor.forClass(State.class); diff --git a/bundles/org.openhab.core.transform/src/main/java/org/eclipse/smarthome/core/transform/AbstractFileTransformationService.java b/bundles/org.openhab.core.transform/src/main/java/org/eclipse/smarthome/core/transform/AbstractFileTransformationService.java index e0ca6eb0f..53b1a582d 100644 --- a/bundles/org.openhab.core.transform/src/main/java/org/eclipse/smarthome/core/transform/AbstractFileTransformationService.java +++ b/bundles/org.openhab.core.transform/src/main/java/org/eclipse/smarthome/core/transform/AbstractFileTransformationService.java @@ -58,7 +58,7 @@ public abstract class AbstractFileTransformationService implements Transforma protected final Map cachedFiles = new ConcurrentHashMap<>(); private final Map registeredKeys = new ConcurrentHashMap<>(); - protected final List watchedDirectories = new ArrayList(); + protected final List watchedDirectories = new ArrayList<>(); private final Logger logger = LoggerFactory.getLogger(AbstractFileTransformationService.class); diff --git a/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/chart/ChartServlet.java b/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/chart/ChartServlet.java index 947aef4bc..7dc73c17d 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/chart/ChartServlet.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/chart/ChartServlet.java @@ -82,7 +82,7 @@ public class ChartServlet extends SmartHomeServlet { // The URI of this servlet public static final String SERVLET_NAME = "/chart"; - protected static final Map PERIODS = new HashMap(); + protected static final Map PERIODS = new HashMap<>(); static { PERIODS.put("h", 3600000L); @@ -100,7 +100,7 @@ public class ChartServlet extends SmartHomeServlet { PERIODS.put("Y", 31536000000L); } - protected static Map chartProviders = new ConcurrentHashMap(); + protected static Map chartProviders = new ConcurrentHashMap<>(); @Override @Reference diff --git a/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/chart/defaultchartprovider/DefaultChartProvider.java b/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/chart/defaultchartprovider/DefaultChartProvider.java index 7cffee77e..a8a1e0c90 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/chart/defaultchartprovider/DefaultChartProvider.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/chart/defaultchartprovider/DefaultChartProvider.java @@ -234,8 +234,8 @@ public class DefaultChartProvider implements ChartProvider { // always hide the legend showLegend = false; - List xData = new ArrayList(); - List yData = new ArrayList(); + List xData = new ArrayList<>(); + List yData = new ArrayList<>(); xData.add(startTime); yData.add(0); @@ -312,8 +312,8 @@ public class DefaultChartProvider implements ChartProvider { FilterCriteria filter; // Generate data collections - List xData = new ArrayList(); - List yData = new ArrayList(); + List xData = new ArrayList<>(); + List yData = new ArrayList<>(); // Declare state here so it will hold the last value at the end of the process State state = null; diff --git a/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/items/ItemUIRegistryImpl.java b/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/items/ItemUIRegistryImpl.java index 74515ef13..f90dec449 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/items/ItemUIRegistryImpl.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/items/ItemUIRegistryImpl.java @@ -121,13 +121,13 @@ public class ItemUIRegistryImpl implements ItemUIRegistry { private static final Pattern LABEL_PATTERN = Pattern.compile(".*?\\[.*? (.*?)\\]"); - protected Set itemUIProviders = new HashSet(); + protected Set itemUIProviders = new HashSet<>(); protected ItemRegistry itemRegistry; private ItemBuilderFactory itemBuilderFactory; - private final Map defaultWidgets = Collections.synchronizedMap(new WeakHashMap()); + private final Map defaultWidgets = Collections.synchronizedMap(new WeakHashMap<>()); public ItemUIRegistryImpl() { } @@ -673,7 +673,7 @@ public class ItemUIRegistryImpl implements ItemUIRegistry { public EList getChildren(Sitemap sitemap) { EList widgets = sitemap.getChildren(); - EList result = new BasicEList(); + EList result = new BasicEList<>(); for (Widget widget : widgets) { Widget resolvedWidget = resolveDefault(widget); if (resolvedWidget != null) { @@ -692,7 +692,7 @@ public class ItemUIRegistryImpl implements ItemUIRegistry { widgets = w.getChildren(); } - EList result = new BasicEList(); + EList result = new BasicEList<>(); for (Widget widget : widgets) { Widget resolvedWidget = resolveDefault(widget); if (resolvedWidget != null) { @@ -746,7 +746,7 @@ public class ItemUIRegistryImpl implements ItemUIRegistry { * @return a list of default widgets provided for the member items */ private EList getDynamicGroupChildren(Group group) { - EList children = new BasicEList(); + EList children = new BasicEList<>(); String itemName = group.getItem(); try { if (itemName != null) { diff --git a/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/proxy/ProxyServletService.java b/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/proxy/ProxyServletService.java index 0a494a595..1f79826df 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/proxy/ProxyServletService.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/eclipse/smarthome/ui/internal/proxy/ProxyServletService.java @@ -146,7 +146,7 @@ public class ProxyServletService extends HttpServlet { * @return properties to pass to servlet for initialization */ private Hashtable propsFromConfig(Map config) { - Hashtable props = new Hashtable(); + Hashtable props = new Hashtable<>(); if (config != null) { for (String key : config.keySet()) { diff --git a/bundles/org.openhab.core.ui/src/test/java/org/eclipse/smarthome/ui/internal/items/ItemUIRegistryImplTest.java b/bundles/org.openhab.core.ui/src/test/java/org/eclipse/smarthome/ui/internal/items/ItemUIRegistryImplTest.java index 0d04578b1..f1cbce2fa 100644 --- a/bundles/org.openhab.core.ui/src/test/java/org/eclipse/smarthome/ui/internal/items/ItemUIRegistryImplTest.java +++ b/bundles/org.openhab.core.ui/src/test/java/org/eclipse/smarthome/ui/internal/items/ItemUIRegistryImplTest.java @@ -501,7 +501,7 @@ public class ItemUIRegistryImplTest { Switch switchWidget = mock(Switch.class); when(switchWidget.getItem()).thenReturn("myItem"); - when(switchWidget.getMappings()).thenReturn(new BasicEList()); + when(switchWidget.getMappings()).thenReturn(new BasicEList<>()); State stateForSwitch = uiRegistry.getState(switchWidget); @@ -522,7 +522,7 @@ public class ItemUIRegistryImplTest { when(switchWidget.getItem()).thenReturn("myItem"); Mapping mapping = mock(Mapping.class); - BasicEList mappings = new BasicEList(); + BasicEList mappings = new BasicEList<>(); mappings.add(mapping); when(switchWidget.getMappings()).thenReturn(mappings); @@ -661,7 +661,7 @@ public class ItemUIRegistryImplTest { when(colorArray.getState()).thenReturn("21"); when(colorArray.getCondition()).thenReturn("<"); when(colorArray.getArg()).thenReturn("yellow"); - BasicEList colorArrays = new BasicEList(); + BasicEList colorArrays = new BasicEList<>(); colorArrays.add(colorArray); when(widget.getLabelColor()).thenReturn(colorArrays); @@ -681,7 +681,7 @@ public class ItemUIRegistryImplTest { when(colorArray.getState()).thenReturn("20"); when(colorArray.getCondition()).thenReturn("=="); when(colorArray.getArg()).thenReturn("yellow"); - BasicEList colorArrays = new BasicEList(); + BasicEList colorArrays = new BasicEList<>(); colorArrays.add(colorArray); when(widget.getLabelColor()).thenReturn(colorArrays); diff --git a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/internal/DialogProcessor.java b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/internal/DialogProcessor.java index 58bf2b552..bccc56466 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/internal/DialogProcessor.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/internal/DialogProcessor.java @@ -132,7 +132,7 @@ public class DialogProcessor implements KSListener, STTListener { if (stt != null) { try { this.sttServiceHandle = stt.recognize(this, source.getInputStream(format), this.locale, - new HashSet()); + new HashSet<>()); } catch (STTException e) { say("Error during recognition: " + e.getMessage()); } catch (AudioException e) { diff --git a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/internal/VoiceManagerImpl.java b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/internal/VoiceManagerImpl.java index b513a1ac9..28200e85d 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/internal/VoiceManagerImpl.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/internal/VoiceManagerImpl.java @@ -423,7 +423,7 @@ public class VoiceManagerImpl implements VoiceManager, ConfigOptionProvider { Locale locale = localeProvider.getLocale(); // Get collection of voice locales - Collection locales = new ArrayList(); + Collection locales = new ArrayList<>(); for (Voice currentVoice : voices) { locales.add(currentVoice.getLocale()); } diff --git a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/AbstractRuleBasedInterpreter.java b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/AbstractRuleBasedInterpreter.java index 8de122023..c298939fb 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/AbstractRuleBasedInterpreter.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/AbstractRuleBasedInterpreter.java @@ -18,6 +18,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.ResourceBundle; import java.util.Set; @@ -62,9 +63,9 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter private Logger logger = LoggerFactory.getLogger(AbstractRuleBasedInterpreter.class); - private HashMap> languageRules; - private HashMap> allItemTokens = null; - private HashMap>>> itemTokens = null; + private Map> languageRules; + private Map> allItemTokens = null; + private Map>>> itemTokens = null; private ItemRegistry itemRegistry; private EventPublisher eventPublisher; @@ -134,13 +135,13 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter * @param locale The locale that is to be used for preparing the tokens. * @return the identifier tokens */ - HashSet getAllItemTokens(Locale locale) { + Set getAllItemTokens(Locale locale) { if (allItemTokens == null) { - allItemTokens = new HashMap>(); + allItemTokens = new HashMap<>(); } - HashSet localeTokens = allItemTokens.get(locale); + Set localeTokens = allItemTokens.get(locale); if (localeTokens == null) { - allItemTokens.put(locale, localeTokens = new HashSet()); + allItemTokens.put(locale, localeTokens = new HashSet<>()); for (Item item : itemRegistry.getAll()) { localeTokens.addAll(tokenize(locale, item.getLabel())); } @@ -157,29 +158,28 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter * @param locale The locale that is to be used for preparing the tokens. * @return the list of identifier token sets per item */ - HashMap>> getItemTokens(Locale locale) { + Map>> getItemTokens(Locale locale) { if (itemTokens == null) { - itemTokens = new HashMap>>>(); + itemTokens = new HashMap<>(); } - HashMap>> localeTokens = itemTokens.get(locale); + Map>> localeTokens = itemTokens.get(locale); if (localeTokens == null) { - itemTokens.put(locale, localeTokens = new HashMap>>()); + itemTokens.put(locale, localeTokens = new HashMap<>()); for (Item item : itemRegistry.getItems()) { if (item.getGroupNames().isEmpty()) { - addItem(locale, localeTokens, new HashSet(), item); + addItem(locale, localeTokens, new HashSet<>(), item); } } } return localeTokens; } - private void addItem(Locale locale, HashMap>> target, HashSet tokens, - Item item) { - HashSet nt = new HashSet(tokens); + private void addItem(Locale locale, Map>> target, Set tokens, Item item) { + Set nt = new HashSet<>(tokens); nt.addAll(tokenize(locale, item.getLabel())); - ArrayList> list = target.get(item); + List> list = target.get(item); if (list == null) { - target.put(item, list = new ArrayList>()); + target.put(item, list = new ArrayList<>()); } list.add(nt); if (item instanceof GroupItem) { @@ -212,9 +212,9 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter return tag(NAME, star(new ExpressionIdentifier(this, stopper))); } - private HashMap> getLanguageRules() { + private Map> getLanguageRules() { if (languageRules == null) { - languageRules = new HashMap>(); + languageRules = new HashMap<>(); createRules(); } return languageRules; @@ -228,10 +228,10 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter * @return Rules in descending match priority order. */ public Rule[] getRules(Locale locale) { - HashMap> lr = getLanguageRules(); - ArrayList rules = new ArrayList(); - HashSet> ruleSets = new HashSet>(); - ArrayList ruleSet = lr.get(locale); + Map> lr = getLanguageRules(); + List rules = new ArrayList<>(); + Set> ruleSets = new HashSet<>(); + List ruleSet = lr.get(locale); if (ruleSet != null) { ruleSets.add(ruleSet); rules.addAll(ruleSet); @@ -257,9 +257,9 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter * @param rules Rules to add. */ protected void addRules(Locale locale, Rule... rules) { - ArrayList ruleSet = languageRules.get(locale); + List ruleSet = languageRules.get(locale); if (ruleSet == null) { - languageRules.put(locale, ruleSet = new ArrayList()); + languageRules.put(locale, ruleSet = new ArrayList<>()); } for (Rule rule : rules) { ruleSet.add(rule); @@ -343,7 +343,7 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter * @return resulting expression array */ protected Expression[] exps(Object... objects) { - ArrayList result = new ArrayList(); + List result = new ArrayList<>(); for (int i = 0; i < objects.length; i++) { Expression e = exp(objects[i]); if (e != null) { @@ -481,7 +481,7 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter */ protected String executeSingle(ResourceBundle language, String[] labelFragments, Command command) throws InterpretationException { - ArrayList items = getMatchingItems(language, labelFragments, command.getClass()); + List items = getMatchingItems(language, labelFragments, command.getClass()); if (items.size() < 1) { if (getMatchingItems(language, labelFragments, null).size() >= 1) { throw new InterpretationException( @@ -520,14 +520,13 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter /** * Filters the item registry by matching each item's name with the provided name fragments. - * The item's label and its parent group's labels are tokenizend {@link tokenize} and then altogether looked up + * The item's label and its parent group's labels are tokenized {@link tokenize} and then altogether looked up * by each and every provided fragment. * For the item to get included into the result list, every provided fragment has to be found among the label * tokens. * If a command type is provided, the item also has to support it. * In case of channels and their owners being ambiguous due to sharing most of the label sequence, only the top - * most item with support for the - * given command type is kept. + * most item with support for the given command type is kept. * * @param language Language information that is used for matching * @param labelFragments label fragments that are used to match an item's label. @@ -537,11 +536,11 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter * Provide {null} if there is no need for a certain command to be supported. * @return All matching items from the item registry. */ - protected ArrayList getMatchingItems(ResourceBundle language, String[] labelFragments, Class commandType) { - ArrayList items = new ArrayList(); - HashMap>> map = getItemTokens(language.getLocale()); + protected List getMatchingItems(ResourceBundle language, String[] labelFragments, Class commandType) { + List items = new ArrayList<>(); + Map>> map = getItemTokens(language.getLocale()); for (Item item : map.keySet()) { - for (HashSet parts : map.get(item)) { + for (Set parts : map.get(item)) { boolean allMatch = true; for (String fragment : labelFragments) { if (!parts.contains(fragment.toLowerCase(language.getLocale()))) { @@ -582,9 +581,9 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter * @param text the text that should be tokenized * @return resulting tokens */ - protected ArrayList tokenize(Locale locale, String text) { + protected List tokenize(Locale locale, String text) { final Locale localeSafe = locale != null ? locale : Locale.getDefault(); - ArrayList parts = new ArrayList(); + List parts = new ArrayList<>(); if (text == null) { return parts; } @@ -624,13 +623,13 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter private ResourceBundle language; - private HashMap ids = new HashMap(); - private HashSet exported = new HashSet(); - private HashSet shared = new HashSet(); + private Map ids = new HashMap<>(); + private Set exported = new HashSet<>(); + private Set shared = new HashSet<>(); private int counter = 0; - private HashSet identifierExcludes = new HashSet(); - private HashSet identifiers = new HashSet(); + private Set identifierExcludes = new HashSet<>(); + private Set identifiers = new HashSet<>(); private StringBuilder builder = new StringBuilder(); @@ -749,9 +748,9 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter } private void emitItemIdentifierExpression(ExpressionIdentifier expression) { - HashSet remainder = new HashSet(identifierExcludes); + Set remainder = new HashSet<>(identifierExcludes); Expression stopper = expression.getStopper(); - HashSet excludes = stopper == null ? new HashSet() : stopper.getFirsts(language); + Set excludes = stopper == null ? new HashSet<>() : stopper.getFirsts(language); if (excludes.size() > 0) { remainder.removeAll(excludes); if (remainder.size() > 0) { @@ -786,7 +785,7 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter } } - private void emitSet(HashSet set, String separator) { + private void emitSet(Set set, String separator) { boolean sep = false; for (String p : set) { if (sep) { @@ -817,7 +816,7 @@ public abstract class AbstractRuleBasedInterpreter implements HumanLanguageInter emit("#JSGF V1.0;\n\n"); if (identifierExcludes.size() > 0) { - HashSet identifierBase = new HashSet(identifiers); + Set identifierBase = new HashSet<>(identifiers); identifierBase.removeAll(identifierExcludes); emit(" = "); emitSet(identifierBase, " | "); diff --git a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/Expression.java b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/Expression.java index b27b20592..7579a0656 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/Expression.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/Expression.java @@ -16,6 +16,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.ResourceBundle; +import java.util.Set; /** * Base class for all expressions. @@ -36,10 +37,10 @@ public abstract class Expression { return Collections.emptyList(); } - abstract boolean collectFirsts(ResourceBundle language, HashSet firsts); + abstract boolean collectFirsts(ResourceBundle language, Set firsts); - HashSet getFirsts(ResourceBundle language) { - HashSet firsts = new HashSet(); + Set getFirsts(ResourceBundle language) { + Set firsts = new HashSet<>(); collectFirsts(language, firsts); return firsts; } diff --git a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionAlternatives.java b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionAlternatives.java index a806cdaf5..bfe9f157c 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionAlternatives.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionAlternatives.java @@ -14,9 +14,9 @@ package org.eclipse.smarthome.core.voice.text; import java.util.Arrays; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.ResourceBundle; +import java.util.Set; /** * Expression that successfully parses, if one of the given alternative expressions matches. This class is immutable. @@ -61,7 +61,7 @@ final class ExpressionAlternatives extends Expression { } @Override - boolean collectFirsts(ResourceBundle language, HashSet firsts) { + boolean collectFirsts(ResourceBundle language, Set firsts) { boolean blocking = true; for (Expression e : subExpressions) { blocking = blocking && e.collectFirsts(language, firsts); diff --git a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionCardinality.java b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionCardinality.java index 4be94b3de..c7e234ae1 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionCardinality.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionCardinality.java @@ -15,9 +15,9 @@ package org.eclipse.smarthome.core.voice.text; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.ResourceBundle; +import java.util.Set; /** * Expression that successfully parses, if a given expression occurs or repeats with a specified cardinality. This class @@ -48,8 +48,8 @@ public final class ExpressionCardinality extends Expression { ASTNode parse(ResourceBundle language, TokenList tokenList) { TokenList list = tokenList; ASTNode node = new ASTNode(), cr; - ArrayList nodes = new ArrayList(); - ArrayList values = new ArrayList(); + List nodes = new ArrayList<>(); + List values = new ArrayList<>(); while ((cr = subExpression.parse(language, list)).isSuccess()) { nodes.add(cr); values.add(cr.getValue()); @@ -74,7 +74,7 @@ public final class ExpressionCardinality extends Expression { } @Override - boolean collectFirsts(ResourceBundle language, HashSet firsts) { + boolean collectFirsts(ResourceBundle language, Set firsts) { return subExpression.collectFirsts(language, firsts) || atLeastOne; } diff --git a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionIdentifier.java b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionIdentifier.java index 76ba00f82..4850d1a91 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionIdentifier.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionIdentifier.java @@ -14,6 +14,7 @@ package org.eclipse.smarthome.core.voice.text; import java.util.HashSet; import java.util.ResourceBundle; +import java.util.Set; /** * Expression that successfully parses, if a thing identifier token is found. This class is immutable. @@ -60,8 +61,8 @@ public final class ExpressionIdentifier extends Expression { } @Override - boolean collectFirsts(ResourceBundle language, HashSet firsts) { - HashSet f = new HashSet(interpreter.getAllItemTokens(language.getLocale())); + boolean collectFirsts(ResourceBundle language, Set firsts) { + Set f = new HashSet<>(interpreter.getAllItemTokens(language.getLocale())); if (stopper != null) { f.removeAll(stopper.getFirsts(language)); } diff --git a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionLet.java b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionLet.java index 169b899bd..30b94384a 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionLet.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionLet.java @@ -14,9 +14,9 @@ package org.eclipse.smarthome.core.voice.text; import java.util.Arrays; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.ResourceBundle; +import java.util.Set; /** * Expression that decorates the resulting (proxied) AST node of a given expression by a name, value and tag. @@ -94,7 +94,7 @@ public final class ExpressionLet extends Expression { } @Override - boolean collectFirsts(ResourceBundle language, HashSet firsts) { + boolean collectFirsts(ResourceBundle language, Set firsts) { return subExpression.collectFirsts(language, firsts); } diff --git a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionMatch.java b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionMatch.java index 197c02f94..9139e56d8 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionMatch.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionMatch.java @@ -12,8 +12,8 @@ */ package org.eclipse.smarthome.core.voice.text; -import java.util.HashSet; import java.util.ResourceBundle; +import java.util.Set; /** * Expression that successfully parses, if a given string constant is found. This class is immutable. @@ -48,7 +48,7 @@ public final class ExpressionMatch extends Expression { } @Override - boolean collectFirsts(ResourceBundle language, HashSet firsts) { + boolean collectFirsts(ResourceBundle language, Set firsts) { firsts.add(pattern); return true; } diff --git a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionSequence.java b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionSequence.java index c403d8c3a..5bb914b57 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionSequence.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/ExpressionSequence.java @@ -14,9 +14,9 @@ package org.eclipse.smarthome.core.voice.text; import java.util.Arrays; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.ResourceBundle; +import java.util.Set; /** * Expression that successfully parses, if a sequence of given expressions is matching. This class is immutable. @@ -67,7 +67,7 @@ public final class ExpressionSequence extends Expression { } @Override - boolean collectFirsts(ResourceBundle language, HashSet firsts) { + boolean collectFirsts(ResourceBundle language, Set firsts) { boolean blocking = false; for (Expression e : subExpressions) { blocking = e.collectFirsts(language, firsts); @@ -75,7 +75,7 @@ public final class ExpressionSequence extends Expression { break; } } - + return blocking; } diff --git a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/TokenList.java b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/TokenList.java index 7e5c82f14..2ead087e6 100644 --- a/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/TokenList.java +++ b/bundles/org.openhab.core.voice/src/main/java/org/eclipse/smarthome/core/voice/text/TokenList.java @@ -34,7 +34,7 @@ public class TokenList { * @param list of the initial tokens */ public TokenList(List list) { - this.list = Collections.unmodifiableList(new ArrayList(list)); + this.list = Collections.unmodifiableList(new ArrayList<>(list)); this.head = 0; this.tail = list.size() - 1; } diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/QueueingThreadPoolExecutor.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/QueueingThreadPoolExecutor.java index a2af9962a..7b1bbc3d5 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/QueueingThreadPoolExecutor.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/QueueingThreadPoolExecutor.java @@ -85,8 +85,8 @@ public class QueueingThreadPoolExecutor extends ThreadPoolExecutor { private QueueingThreadPoolExecutor(String threadPoolName, ThreadFactory threadFactory, int threadPoolSize, RejectedExecutionHandler rejectionHandler) { - super(CORE_THREAD_POOL_SIZE, threadPoolSize, 10L, TimeUnit.SECONDS, new SynchronousQueue(), - threadFactory, rejectionHandler); + super(CORE_THREAD_POOL_SIZE, threadPoolSize, 10L, TimeUnit.SECONDS, new SynchronousQueue<>(), threadFactory, + rejectionHandler); if (threadPoolName == null || threadPoolName.trim().isEmpty()) { throw new IllegalArgumentException("A thread pool name must be provided!"); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/osgi/ResourceBundleClassLoader.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/osgi/ResourceBundleClassLoader.java index e8e5383f3..653252cde 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/osgi/ResourceBundleClassLoader.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/osgi/ResourceBundleClassLoader.java @@ -36,7 +36,7 @@ import org.osgi.framework.Bundle; * * @author Michael Grammling - Initial contribution * @author Martin Herbst - UTF-8 replaced by ISO-8859-1 to follow Java standards - * + * */ public class ResourceBundleClassLoader extends ClassLoader { @@ -70,7 +70,7 @@ public class ResourceBundleClassLoader extends ClassLoader { public URL getResource(String name) { Enumeration resourceFiles = this.bundle.findEntries(this.path, this.filePattern, true); - List allResources = new LinkedList(); + List allResources = new LinkedList<>(); if (resourceFiles != null) { while (resourceFiles.hasMoreElements()) { URL resourceURL = resourceFiles.nextElement(); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/registry/AbstractProvider.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/registry/AbstractProvider.java index b69c01318..eeeba480c 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/registry/AbstractProvider.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/registry/AbstractProvider.java @@ -36,7 +36,7 @@ public abstract class AbstractProvider implements Provider { } protected final Logger logger = LoggerFactory.getLogger(AbstractProvider.class); - protected List> listeners = new CopyOnWriteArrayList>(); + protected List> listeners = new CopyOnWriteArrayList<>(); @Override public void addProviderChangeListener(ProviderChangeListener listener) { @@ -65,7 +65,8 @@ public abstract class AbstractProvider implements Provider { break; } } catch (Exception ex) { - logger.error("Could not inform the listener '{}' about the '{}' event!: {}", listener, eventType.name(), ex.getMessage(), ex); + logger.error("Could not inform the listener '{}' about the '{}' event!: {}", listener, eventType.name(), + ex.getMessage(), ex); } } } diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/registry/AbstractRegistry.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/registry/AbstractRegistry.java index b533ce719..4d69e8c6b 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/registry/AbstractRegistry.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/common/registry/AbstractRegistry.java @@ -71,7 +71,7 @@ public abstract class AbstractRegistry, K, P extends P private final Map identifierToElement = new HashMap<>(); private final Set elements = new HashSet<>(); - private final Collection> listeners = new CopyOnWriteArraySet>(); + private final Collection> listeners = new CopyOnWriteArraySet<>(); private Optional> managedProvider = Optional.empty(); @@ -311,7 +311,7 @@ public abstract class AbstractRegistry, K, P extends P if (element == null) { return null; } - return new SimpleEntry, E>(elementToProvider.get(element), element); + return new SimpleEntry<>(elementToProvider.get(element), element); } finally { elementReadLock.unlock(); } diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/common/SafeCallerBuilderImpl.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/common/SafeCallerBuilderImpl.java index 735ef0461..b051a4635 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/common/SafeCallerBuilderImpl.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/common/SafeCallerBuilderImpl.java @@ -59,10 +59,10 @@ public class SafeCallerBuilderImpl implements SafeCallerBuilder { return AccessController.doPrivileged((PrivilegedAction) () -> { InvocationHandler handler; if (async) { - handler = new InvocationHandlerAsync(manager, target, identifier, timeout, exceptionHandler, + handler = new InvocationHandlerAsync<>(manager, target, identifier, timeout, exceptionHandler, timeoutHandler); } else { - handler = new InvocationHandlerSync(manager, target, identifier, timeout, exceptionHandler, + handler = new InvocationHandlerSync<>(manager, target, identifier, timeout, exceptionHandler, timeoutHandler); } return (T) Proxy.newProxyInstance( diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/events/OSGiEventPublisher.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/events/OSGiEventPublisher.java index 101fa0c2e..13d5da29c 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/events/OSGiEventPublisher.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/events/OSGiEventPublisher.java @@ -60,7 +60,7 @@ public class OSGiEventPublisher implements EventPublisher { AccessController.doPrivileged(new PrivilegedExceptionAction() { @Override public Void run() throws Exception { - Dictionary properties = new Hashtable(3); + Dictionary properties = new Hashtable<>(3); properties.put("type", event.getType()); properties.put("payload", event.getPayload()); properties.put("topic", event.getTopic()); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/i18n/LanguageResourceBundleManager.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/i18n/LanguageResourceBundleManager.java index b86d3c282..1aa675e52 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/i18n/LanguageResourceBundleManager.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/i18n/LanguageResourceBundleManager.java @@ -99,7 +99,7 @@ public class LanguageResourceBundleManager { } private List determineResourceNames() { - List resourceNames = new ArrayList(); + List resourceNames = new ArrayList<>(); Enumeration resourceFiles = this.bundle.findEntries(RESOURCE_DIRECTORY, RESOURCE_FILE_PATTERN, true); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/i18n/ResourceBundleTracker.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/i18n/ResourceBundleTracker.java index 55638255a..70a4c815c 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/i18n/ResourceBundleTracker.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/i18n/ResourceBundleTracker.java @@ -49,7 +49,7 @@ public class ResourceBundleTracker extends BundleTracker { this.localeProvider = localeProvider; pkgAdmin = (PackageAdmin) bundleContext .getService(bundleContext.getServiceReference(PackageAdmin.class.getName())); - this.bundleLanguageResourceMap = new LinkedHashMap(); + this.bundleLanguageResourceMap = new LinkedHashMap<>(); } @Override @@ -124,7 +124,7 @@ public class ResourceBundleTracker extends BundleTracker { * @return a list with the hosts of the fragment parameter. */ private List returnHostBundles(Bundle fragment) { - List hosts = new ArrayList(); + List hosts = new ArrayList<>(); Bundle[] bundles = pkgAdmin.getHosts(fragment); if (bundles != null) { for (int i = 0; i < bundles.length; i++) { diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/items/ItemRegistryImpl.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/items/ItemRegistryImpl.java index d8e9683d1..2d66fda34 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/items/ItemRegistryImpl.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/items/ItemRegistryImpl.java @@ -113,7 +113,7 @@ public class ItemRegistryImpl extends AbstractRegistry getItemsOfType(String type) { - Collection matchedItems = new ArrayList(); + Collection matchedItems = new ArrayList<>(); for (Item item : getItems()) { if (item.getType().equals(type)) { @@ -127,7 +127,7 @@ public class ItemRegistryImpl extends AbstractRegistry getItems(String pattern) { String regex = pattern.replace("?", ".?").replace("*", ".*?"); - Collection matchedItems = new ArrayList(); + Collection matchedItems = new ArrayList<>(); for (Item item : getItems()) { if (item.getName().matches(regex)) { @@ -309,7 +309,7 @@ public class ItemRegistryImpl extends AbstractRegistry getItemsByTag(String... tags) { - List filteredItems = new ArrayList(); + List filteredItems = new ArrayList<>(); for (Item item : getItems()) { if (itemHasTags(item, tags)) { filteredItems.add(item); @@ -330,7 +330,7 @@ public class ItemRegistryImpl extends AbstractRegistry Collection getItemsByTag(Class typeFilter, String... tags) { - Collection filteredItems = new ArrayList(); + Collection filteredItems = new ArrayList<>(); Collection items = getItemsByTag(tags); for (Item item : items) { @@ -343,7 +343,7 @@ public class ItemRegistryImpl extends AbstractRegistry getItemsByTagAndType(String type, String... tags) { - List filteredItems = new ArrayList(); + List filteredItems = new ArrayList<>(); for (Item item : getItemsOfType(type)) { if (itemHasTags(item, tags)) { filteredItems.add(item); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/scheduler/CronAdjuster.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/scheduler/CronAdjuster.java index ace3a6def..3935a6981 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/scheduler/CronAdjuster.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/scheduler/CronAdjuster.java @@ -59,11 +59,10 @@ class CronAdjuster implements SchedulerTemporalAdjuster { private static final String[] MONTHS2 = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; private static final Map MONTHS = IntStream.range(0, MONTHS2.length) - .mapToObj(i -> new SimpleEntry(MONTHS2[i], i)) - .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); + .mapToObj(i -> new SimpleEntry<>(MONTHS2[i], i)).collect(Collectors.toMap(Entry::getKey, Entry::getValue)); private static final String[] WEEK_DAYS_STRINGS = { "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN" }; private static final Map WEEK_DAYS = IntStream.range(0, WEEK_DAYS_STRINGS.length) - .mapToObj(i -> new SimpleEntry(WEEK_DAYS_STRINGS[i], i)) + .mapToObj(i -> new SimpleEntry<>(WEEK_DAYS_STRINGS[i], i)) .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); private final List fields = new ArrayList<>(7); @@ -131,10 +130,10 @@ class CronAdjuster implements SchedulerTemporalAdjuster { * @return Map with environment variables */ private Map parseEnvironment(String[] entries) { - final Map map = new HashMap(); + final Map map = new HashMap<>(); if (entries.length > 1) { - // Skip the last entry it contains the cron expression no varables. + // Skip the last entry it contains the cron expression no variables. for (int i = 0; i < entries.length - 1; i++) { final String entry = entries[i]; diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/scheduler/SchedulerImpl.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/scheduler/SchedulerImpl.java index bd8f85071..a2cb1d465 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/scheduler/SchedulerImpl.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/internal/scheduler/SchedulerImpl.java @@ -65,7 +65,7 @@ public class SchedulerImpl implements Scheduler { @Override public ScheduledCompletableFuture after(Callable callable, Duration duration) { - return afterInternal(new ScheduledCompletableFutureOnce(), callable, duration); + return afterInternal(new ScheduledCompletableFutureOnce<>(), callable, duration); } private ScheduledCompletableFutureOnce afterInternal(ScheduledCompletableFutureOnce deferred, @@ -127,7 +127,7 @@ public class SchedulerImpl implements Scheduler { @Override public ScheduledCompletableFuture at(Callable callable, Instant instant) { - return atInternal(new ScheduledCompletableFutureOnce(), callable, instant); + return atInternal(new ScheduledCompletableFutureOnce<>(), callable, instant); } private ScheduledCompletableFuture atInternal(ScheduledCompletableFutureOnce deferred, @@ -140,7 +140,7 @@ public class SchedulerImpl implements Scheduler { @Override public ScheduledCompletableFuture schedule(SchedulerRunnable runnable, SchedulerTemporalAdjuster temporalAdjuster) { - final ScheduledCompletableFutureRecurring schedule = new ScheduledCompletableFutureRecurring(); + final ScheduledCompletableFutureRecurring schedule = new ScheduledCompletableFutureRecurring<>(); schedule(schedule, runnable, temporalAdjuster); return schedule; diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/GenericItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/GenericItem.java index 39b0720ab..c8b286277 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/GenericItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/GenericItem.java @@ -62,12 +62,12 @@ public abstract class GenericItem implements ActiveItem { protected @Nullable EventPublisher eventPublisher; - protected Set listeners = new CopyOnWriteArraySet( - Collections.newSetFromMap(new WeakHashMap())); + protected Set listeners = new CopyOnWriteArraySet<>( + Collections.newSetFromMap(new WeakHashMap<>())); - protected List groupNames = new ArrayList(); + protected List groupNames = new ArrayList<>(); - protected Set tags = new HashSet(); + protected Set tags = new HashSet<>(); protected final String name; @@ -249,7 +249,7 @@ public abstract class GenericItem implements ActiveItem { protected void notifyListeners(final State oldState, final State newState) { // if nothing has changed, we send update notifications Set clonedListeners = null; - clonedListeners = new CopyOnWriteArraySet(listeners); + clonedListeners = new CopyOnWriteArraySet<>(listeners); ExecutorService pool = ThreadPoolManager.getPool(ITEM_THREADPOOLNAME); for (final StateChangeListener listener : clonedListeners) { pool.execute(new Runnable() { diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/GroupItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/GroupItem.java index 1ff122389..3c1fa82a3 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/GroupItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/GroupItem.java @@ -82,7 +82,7 @@ public class GroupItem extends GenericItem implements StateChangeListener { this.baseItem = baseItem; } - members = new CopyOnWriteArrayList(); + members = new CopyOnWriteArrayList<>(); } @Override @@ -154,7 +154,7 @@ public class GroupItem extends GenericItem implements StateChangeListener { * @return Set of member items filtered by filterItem */ public Set getMembers(Predicate filterItem) { - Set allMembers = new LinkedHashSet(); + Set allMembers = new LinkedHashSet<>(); collectMembers(allMembers, members); return allMembers.stream().filter(filterItem).collect(Collectors.toSet()); } @@ -172,7 +172,7 @@ public class GroupItem extends GenericItem implements StateChangeListener { boolean added = members.addIfAbsent(item); - // in case membership is constructed programmatically this sanitises + // in case membership is constructed programmatically this sanitizes // the group names on the item: if (added && item instanceof GenericItem) { ((GenericItem) item).addGroupName(this.getName()); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/ManagedItemProvider.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/ManagedItemProvider.java index 5bc71f06e..43a8991c5 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/ManagedItemProvider.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/ManagedItemProvider.java @@ -83,7 +83,7 @@ public class ManagedItemProvider extends AbstractManagedProvider itemFactories = new CopyOnWriteArrayList(); + private final Collection itemFactories = new CopyOnWriteArrayList<>(); private final Map failedToCreate = new ConcurrentHashMap<>(); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/dto/ItemDTOMapper.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/dto/ItemDTOMapper.java index 4994ab64f..b130c0c53 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/dto/ItemDTOMapper.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/dto/ItemDTOMapper.java @@ -104,7 +104,7 @@ public class ItemDTOMapper { } private static List parseStates(@Nullable Item baseItem, String @Nullable [] params) { - List states = new ArrayList(); + List states = new ArrayList<>(); if (params == null || baseItem == null) { return states; diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/events/ItemEventFactory.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/events/ItemEventFactory.java index 2cd4d85ab..f2d6cd461 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/events/ItemEventFactory.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/items/events/ItemEventFactory.java @@ -358,7 +358,7 @@ public class ItemEventFactory extends AbstractEventFactory { String topic = buildTopic(ITEM_UPDATED_EVENT_TOPIC, item.getName()); ItemDTO itemDTO = map(item); ItemDTO oldItemDTO = map(oldItem); - List itemDTOs = new LinkedList(); + List itemDTOs = new LinkedList<>(); itemDTOs.add(itemDTO); itemDTOs.add(oldItemDTO); String payload = serializePayload(itemDTOs); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/CallItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/CallItem.java index 70179f878..74cccdfd0 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/CallItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/CallItem.java @@ -33,8 +33,8 @@ import org.eclipse.smarthome.core.types.UnDefType; @NonNullByDefault public class CallItem extends GenericItem { - private static List> acceptedDataTypes = new ArrayList>(); - private static List> acceptedCommandTypes = new ArrayList>(); + private static List> acceptedDataTypes = new ArrayList<>(); + private static List> acceptedCommandTypes = new ArrayList<>(); static { acceptedDataTypes.add(StringListType.class); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/ColorItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/ColorItem.java index 15cf7253b..61b77df69 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/ColorItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/ColorItem.java @@ -37,8 +37,8 @@ import org.eclipse.smarthome.core.types.UnDefType; @NonNullByDefault public class ColorItem extends DimmerItem { - private static List> acceptedDataTypes = new ArrayList>(); - private static List> acceptedCommandTypes = new ArrayList>(); + private static List> acceptedDataTypes = new ArrayList<>(); + private static List> acceptedCommandTypes = new ArrayList<>(); static { acceptedDataTypes.add(HSBType.class); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/ContactItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/ContactItem.java index 04c305ff8..29d46ac18 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/ContactItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/ContactItem.java @@ -34,8 +34,8 @@ import org.eclipse.smarthome.core.types.UnDefType; @NonNullByDefault public class ContactItem extends GenericItem { - private static List> acceptedDataTypes = new ArrayList>(); - private static List> acceptedCommandTypes = new ArrayList>(); + private static List> acceptedDataTypes = new ArrayList<>(); + private static List> acceptedCommandTypes = new ArrayList<>(); static { acceptedDataTypes.add(OpenClosedType.class); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/DateTimeItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/DateTimeItem.java index c9ad3a82f..00a63acc2 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/DateTimeItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/DateTimeItem.java @@ -34,8 +34,8 @@ import org.eclipse.smarthome.core.types.UnDefType; @NonNullByDefault public class DateTimeItem extends GenericItem { - private static List> acceptedDataTypes = new ArrayList>(); - private static List> acceptedCommandTypes = new ArrayList>(); + private static List> acceptedDataTypes = new ArrayList<>(); + private static List> acceptedCommandTypes = new ArrayList<>(); static { acceptedDataTypes.add((DateTimeType.class)); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/DimmerItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/DimmerItem.java index b058ddeb6..efaed4924 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/DimmerItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/DimmerItem.java @@ -36,8 +36,8 @@ import org.eclipse.smarthome.core.types.UnDefType; @NonNullByDefault public class DimmerItem extends SwitchItem { - private static List> acceptedDataTypes = new ArrayList>(); - private static List> acceptedCommandTypes = new ArrayList>(); + private static List> acceptedDataTypes = new ArrayList<>(); + private static List> acceptedCommandTypes = new ArrayList<>(); static { acceptedDataTypes.add(PercentType.class); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/ImageItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/ImageItem.java index a2cd13678..cd2048a4f 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/ImageItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/ImageItem.java @@ -33,8 +33,8 @@ import org.eclipse.smarthome.core.types.UnDefType; @NonNullByDefault public class ImageItem extends GenericItem { - private static List> acceptedDataTypes = new ArrayList>(); - private static List> acceptedCommandTypes = new ArrayList>(); + private static List> acceptedDataTypes = new ArrayList<>(); + private static List> acceptedCommandTypes = new ArrayList<>(); static { acceptedDataTypes.add(RawType.class); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/LocationItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/LocationItem.java index 4b2745a95..8689fe8d8 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/LocationItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/LocationItem.java @@ -36,8 +36,8 @@ import org.eclipse.smarthome.core.types.UnDefType; @NonNullByDefault public class LocationItem extends GenericItem { - private static List> acceptedDataTypes = new ArrayList>(); - private static List> acceptedCommandTypes = new ArrayList>(); + private static List> acceptedDataTypes = new ArrayList<>(); + private static List> acceptedCommandTypes = new ArrayList<>(); static { acceptedDataTypes.add(PointType.class); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/NumberItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/NumberItem.java index b2b7fbb09..e58de73d6 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/NumberItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/NumberItem.java @@ -47,8 +47,8 @@ import org.eclipse.smarthome.core.types.util.UnitUtils; @NonNullByDefault public class NumberItem extends GenericItem { - private static List> acceptedDataTypes = new ArrayList>(); - private static List> acceptedCommandTypes = new ArrayList>(); + private static List> acceptedDataTypes = new ArrayList<>(); + private static List> acceptedCommandTypes = new ArrayList<>(); @Nullable private Class> dimension; diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/PlayerItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/PlayerItem.java index 9a6a4be30..c26b43a51 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/PlayerItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/PlayerItem.java @@ -35,8 +35,8 @@ import org.eclipse.smarthome.core.types.UnDefType; @NonNullByDefault public class PlayerItem extends GenericItem { - private static List> acceptedDataTypes = new ArrayList>(); - private static List> acceptedCommandTypes = new ArrayList>(); + private static List> acceptedDataTypes = new ArrayList<>(); + private static List> acceptedCommandTypes = new ArrayList<>(); static { acceptedDataTypes.add(PlayPauseType.class); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/RollershutterItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/RollershutterItem.java index fece7823e..743b979ec 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/RollershutterItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/RollershutterItem.java @@ -37,8 +37,8 @@ import org.eclipse.smarthome.core.types.UnDefType; @NonNullByDefault public class RollershutterItem extends GenericItem { - private static List> acceptedDataTypes = new ArrayList>(); - private static List> acceptedCommandTypes = new ArrayList>(); + private static List> acceptedDataTypes = new ArrayList<>(); + private static List> acceptedCommandTypes = new ArrayList<>(); static { acceptedDataTypes.add(PercentType.class); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/StringItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/StringItem.java index 6037689f4..e29e251b2 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/StringItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/StringItem.java @@ -37,8 +37,8 @@ import org.eclipse.smarthome.core.types.UnDefType; @NonNullByDefault public class StringItem extends GenericItem { - private static List> acceptedDataTypes = new ArrayList>(); - private static List> acceptedCommandTypes = new ArrayList>(); + private static List> acceptedDataTypes = new ArrayList<>(); + private static List> acceptedCommandTypes = new ArrayList<>(); static { acceptedDataTypes.add(UnDefType.class); @@ -69,7 +69,7 @@ public class StringItem extends GenericItem { @Override public @Nullable T getStateAs(Class typeClass) { - ArrayList> list = new ArrayList>(); + List> list = new ArrayList<>(); list.add(typeClass); State convertedState = TypeParser.parseState(list, state.toString()); if (typeClass.isInstance(convertedState)) { diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/SwitchItem.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/SwitchItem.java index 5c684e722..5fa636303 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/SwitchItem.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/library/items/SwitchItem.java @@ -34,8 +34,8 @@ import org.eclipse.smarthome.core.types.UnDefType; @NonNullByDefault public class SwitchItem extends GenericItem { - private static List> acceptedDataTypes = new ArrayList>(); - private static List> acceptedCommandTypes = new ArrayList>(); + private static List> acceptedDataTypes = new ArrayList<>(); + private static List> acceptedCommandTypes = new ArrayList<>(); static { acceptedDataTypes.add(OnOffType.class); diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/net/NetUtil.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/net/NetUtil.java index 0f1cfa850..9ffb00e7a 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/net/NetUtil.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/net/NetUtil.java @@ -274,7 +274,7 @@ public class NetUtil implements NetworkAddressService { * @return list of broadcast addresses, empty list if no broadcast addresses found */ public static List getAllBroadcastAddresses() { - List broadcastAddresses = new LinkedList(); + List broadcastAddresses = new LinkedList<>(); try { final Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces(); while (networkInterfaces.hasMoreElements()) { diff --git a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/types/EventDescription.java b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/types/EventDescription.java index 1119686aa..c3aab10be 100644 --- a/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/types/EventDescription.java +++ b/bundles/org.openhab.core/src/main/java/org/eclipse/smarthome/core/types/EventDescription.java @@ -31,9 +31,9 @@ public class EventDescription { */ public EventDescription(List options) { if (options != null) { - this.options = Collections.unmodifiableList(new ArrayList(options)); + this.options = Collections.unmodifiableList(new ArrayList<>(options)); } else { - this.options = Collections.unmodifiableList(new ArrayList(0)); + this.options = Collections.unmodifiableList(new ArrayList<>(0)); } } diff --git a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/common/osgi/ResourceBundleClassLoaderTest.java b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/common/osgi/ResourceBundleClassLoaderTest.java index f3d583284..37d578e21 100644 --- a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/common/osgi/ResourceBundleClassLoaderTest.java +++ b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/common/osgi/ResourceBundleClassLoaderTest.java @@ -21,9 +21,9 @@ import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.List; import org.junit.Test; import org.osgi.framework.Bundle; @@ -58,7 +58,7 @@ public class ResourceBundleClassLoaderTest { ResourceBundleClassLoader classloader = new ResourceBundleClassLoader(bundleMock, "/ESH-INF/i18n", "*.properties"); - ArrayList propertiesURLs = Collections.list(bundleMock.findEntries("/ESH-INF/i18n", "*.properties", true)); + List propertiesURLs = Collections.list(bundleMock.findEntries("/ESH-INF/i18n", "*.properties", true)); assertEquals(2, propertiesURLs.size()); assertTrue(propertiesURLs.contains(hostPropertiesURL)); diff --git a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/internal/i18n/I18nProviderImplTest.java b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/internal/i18n/I18nProviderImplTest.java index 826c183c5..e62fabc6c 100644 --- a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/internal/i18n/I18nProviderImplTest.java +++ b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/internal/i18n/I18nProviderImplTest.java @@ -99,7 +99,7 @@ public class I18nProviderImplTest { @Test public void assertThatDefaultLocaleWillBeUsed() { - i18nProviderImpl.modified(new Hashtable()); + i18nProviderImpl.modified(new Hashtable<>()); PointType location = i18nProviderImpl.getLocation(); Locale setLocale = i18nProviderImpl.getLocale(); diff --git a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/items/StateUtil.java b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/items/StateUtil.java index 3ad004ed5..ecaa02291 100644 --- a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/items/StateUtil.java +++ b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/items/StateUtil.java @@ -17,6 +17,7 @@ import static org.junit.Assert.*; import java.util.HashSet; import java.util.LinkedList; import java.util.List; +import java.util.Set; import javax.measure.quantity.Temperature; @@ -46,7 +47,7 @@ import org.eclipse.smarthome.core.types.UnDefType; public class StateUtil { public static List getAllStates() { - LinkedList states = new LinkedList<>(); + List states = new LinkedList<>(); DateTimeType dateTime = new DateTimeType(); states.add(dateTime); @@ -90,14 +91,14 @@ public class StateUtil { states.add(UpDownType.UP); states.add(UpDownType.DOWN); - QuantityType quantityType = new QuantityType("12 °C"); + QuantityType quantityType = new QuantityType<>("12 °C"); states.add(quantityType); return states; } public static void testAcceptedStates(GenericItem item) { - HashSet> successfullStates = new HashSet<>(); + Set> successfullStates = new HashSet<>(); for (State s : getAllStates()) { item.setState(s); diff --git a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/ArithmeticGroupFunctionTest.java b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/ArithmeticGroupFunctionTest.java index 41941a805..2b47eec79 100644 --- a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/ArithmeticGroupFunctionTest.java +++ b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/ArithmeticGroupFunctionTest.java @@ -40,7 +40,7 @@ public class ArithmeticGroupFunctionTest { @Before public void init() { - items = new HashSet(); + items = new HashSet<>(); } @Test diff --git a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/DateTimeGroupFunctionTest.java b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/DateTimeGroupFunctionTest.java index bf21e73da..65ff848eb 100644 --- a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/DateTimeGroupFunctionTest.java +++ b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/DateTimeGroupFunctionTest.java @@ -39,7 +39,7 @@ public class DateTimeGroupFunctionTest { @Before public void init() { - items = new HashSet(); + items = new HashSet<>(); } @Test diff --git a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/DateTimeTypeTest.java b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/DateTimeTypeTest.java index a0f0e832b..c899b05b0 100644 --- a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/DateTimeTypeTest.java +++ b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/DateTimeTypeTest.java @@ -225,7 +225,7 @@ public class DateTimeTypeTest { } private static Map initTimeMap() { - Map inputTimeMap = new HashMap(); + Map inputTimeMap = new HashMap<>(); inputTimeMap.put("year", 2014); inputTimeMap.put("month", 2); inputTimeMap.put("date", 30); diff --git a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/QuantityTypeArithmeticGroupFunctionTest.java b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/QuantityTypeArithmeticGroupFunctionTest.java index 8d4c40aef..46b9e654d 100644 --- a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/QuantityTypeArithmeticGroupFunctionTest.java +++ b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/QuantityTypeArithmeticGroupFunctionTest.java @@ -60,189 +60,189 @@ public class QuantityTypeArithmeticGroupFunctionTest { @Test public void testSumFunctionQuantityType() { - items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType("23.54 °C"))); + items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); - items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType("89 °C"))); + items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType<>("89 °C"))); items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); - items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType("122.41 °C"))); + items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("122.41 °C"))); function = new QuantityTypeArithmeticGroupFunction.Sum(Temperature.class); State state = function.calculate(items); - assertEquals(new QuantityType("234.95 °C"), state); + assertEquals(new QuantityType<>("234.95 °C"), state); } @Test public void testSumFunctionQuantityTypeDifferentUnits() { - items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType("23.54 °C"))); + items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); - items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType("192.2 °F"))); + items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType<>("192.2 °F"))); items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); - items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType("395.56 K"))); + items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("395.56 K"))); function = new QuantityTypeArithmeticGroupFunction.Sum(Temperature.class); State state = function.calculate(items); - assertEquals(new QuantityType("234.95 °C"), state); + assertEquals(new QuantityType<>("234.95 °C"), state); } @Test public void testSumFunctionQuantityTypeIncompatibleUnits() { - items = new LinkedHashSet(); // we need an ordered set to guarantee the Unit of the first entry - items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType("23.54 °C"))); + items = new LinkedHashSet<>(); // we need an ordered set to guarantee the Unit of the first entry + items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); - items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType("192.2 hPa"))); + items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<>("192.2 hPa"))); function = new QuantityTypeArithmeticGroupFunction.Sum(Temperature.class); State state = function.calculate(items); - assertEquals(new QuantityType("23.54 °C"), state); + assertEquals(new QuantityType<>("23.54 °C"), state); } @Test public void testAvgFunctionQuantityType() { - items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType("100 °C"))); + items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("100 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); - items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType("200 °C"))); + items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType<>("200 °C"))); items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); - items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType("300 °C"))); + items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("300 °C"))); function = new QuantityTypeArithmeticGroupFunction.Avg(Temperature.class); State state = function.calculate(items); - assertEquals(new QuantityType("200 °C"), state); + assertEquals(new QuantityType<>("200 °C"), state); } @Test public void testAvgFunctionQuantityTypeDifferentUnits() { - items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType("100 °C"))); + items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("100 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); - items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType("113 °F"))); + items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType<>("113 °F"))); items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); - items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType("294.15 K"))); + items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("294.15 K"))); function = new QuantityTypeArithmeticGroupFunction.Avg(Temperature.class); State state = function.calculate(items); - assertEquals(new QuantityType("55.33 °C"), state); + assertEquals(new QuantityType<>("55.33 °C"), state); } @Test public void testAvgFunctionQuantityTypeIncompatibleUnits() { - items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType("23.54 °C"))); + items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); - items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType("192.2 hPa"))); + items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<>("192.2 hPa"))); function = new QuantityTypeArithmeticGroupFunction.Avg(Temperature.class); State state = function.calculate(items); - assertEquals(new QuantityType("23.54 °C"), state); + assertEquals(new QuantityType<>("23.54 °C"), state); } @Test public void testMaxFunctionQuantityType() { - items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType("100 °C"))); + items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("100 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); - items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType("200 °C"))); + items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType<>("200 °C"))); items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); - items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType("300 °C"))); + items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("300 °C"))); function = new QuantityTypeArithmeticGroupFunction.Max(Temperature.class); State state = function.calculate(items); - assertEquals(new QuantityType("300 °C"), state); + assertEquals(new QuantityType<>("300 °C"), state); } @Test public void testMaxFunctionQuantityTypeDifferentUnits() { - items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType("100 °C"))); + items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("100 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); - items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType("113 °F"))); + items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType<>("113 °F"))); items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); - items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType("294.15 K"))); + items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("294.15 K"))); function = new QuantityTypeArithmeticGroupFunction.Max(Temperature.class); State state = function.calculate(items); - assertEquals(new QuantityType("100 °C"), state); + assertEquals(new QuantityType<>("100 °C"), state); } @Test public void testMaxFunctionQuantityTypeIncompatibleUnits() { - items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType("23.54 °C"))); + items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); - items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType("192.2 hPa"))); + items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<>("192.2 hPa"))); function = new QuantityTypeArithmeticGroupFunction.Max(Temperature.class); State state = function.calculate(items); - assertEquals(new QuantityType("23.54 °C"), state); + assertEquals(new QuantityType<>("23.54 °C"), state); } @Test public void testMinFunctionQuantityType() { - items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType("100 °C"))); + items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("100 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); - items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType("200 °C"))); + items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType<>("200 °C"))); items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); - items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType("300 °C"))); + items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("300 °C"))); function = new QuantityTypeArithmeticGroupFunction.Min(Temperature.class); State state = function.calculate(items); - assertEquals(new QuantityType("100 °C"), state); + assertEquals(new QuantityType<>("100 °C"), state); } @Test public void testMaxFunctionQuantityTypeOnDimensionless() { - items.add(createNumberItem("TestItem1", Dimensionless.class, new QuantityType("48 %"))); - items.add(createNumberItem("TestItem2", Dimensionless.class, new QuantityType("36 %"))); - items.add(createNumberItem("TestItem3", Dimensionless.class, new QuantityType("0 %"))); - items.add(createNumberItem("TestItem4", Dimensionless.class, new QuantityType("48 %"))); - items.add(createNumberItem("TestItem5", Dimensionless.class, new QuantityType("0 %"))); - items.add(createNumberItem("TestItem6", Dimensionless.class, new QuantityType("0 %"))); + items.add(createNumberItem("TestItem1", Dimensionless.class, new QuantityType<>("48 %"))); + items.add(createNumberItem("TestItem2", Dimensionless.class, new QuantityType<>("36 %"))); + items.add(createNumberItem("TestItem3", Dimensionless.class, new QuantityType<>("0 %"))); + items.add(createNumberItem("TestItem4", Dimensionless.class, new QuantityType<>("48 %"))); + items.add(createNumberItem("TestItem5", Dimensionless.class, new QuantityType<>("0 %"))); + items.add(createNumberItem("TestItem6", Dimensionless.class, new QuantityType<>("0 %"))); function = new QuantityTypeArithmeticGroupFunction.Max(Dimensionless.class); State state = function.calculate(items); - assertEquals(new QuantityType("48 %"), state); + assertEquals(new QuantityType<>("48 %"), state); } @Test public void testMinFunctionQuantityTypeDifferentUnits() { - items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType("100 °C"))); + items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("100 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); - items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType("113 °F"))); + items.add(createNumberItem("TestItem3", Temperature.class, new QuantityType<>("113 °F"))); items.add(createNumberItem("TestItem4", Temperature.class, UnDefType.UNDEF)); - items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType("294.15 K"))); + items.add(createNumberItem("TestItem5", Temperature.class, new QuantityType<>("294.15 K"))); function = new QuantityTypeArithmeticGroupFunction.Min(Temperature.class); State state = function.calculate(items); - assertEquals(new QuantityType("294.15 K"), state); + assertEquals(new QuantityType<>("294.15 K"), state); } @Test public void testMinFunctionQuantityTypeIncompatibleUnits() { - items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType("23.54 °C"))); + items.add(createNumberItem("TestItem1", Temperature.class, new QuantityType<>("23.54 °C"))); items.add(createNumberItem("TestItem2", Temperature.class, UnDefType.NULL)); - items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType("192.2 hPa"))); + items.add(createNumberItem("TestItem3", Pressure.class, new QuantityType<>("192.2 hPa"))); function = new QuantityTypeArithmeticGroupFunction.Min(Temperature.class); State state = function.calculate(items); - assertEquals(new QuantityType("23.54 °C"), state); + assertEquals(new QuantityType<>("23.54 °C"), state); } @Test public void testSumFunctionQuantityTypeWithGroups() { - items.add(createNumberItem("TestItem1", Power.class, new QuantityType("5 W"))); - items.add(createGroupItem("TestGroup1", Power.class, new QuantityType("5 W"))); + items.add(createNumberItem("TestItem1", Power.class, new QuantityType<>("5 W"))); + items.add(createGroupItem("TestGroup1", Power.class, new QuantityType<>("5 W"))); function = new QuantityTypeArithmeticGroupFunction.Sum(Power.class); State state = function.calculate(items); - assertEquals(new QuantityType("10 W"), state); + assertEquals(new QuantityType<>("10 W"), state); } private NumberItem createNumberItem(String name, Class> dimension, State state) { diff --git a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/QuantityTypeTest.java b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/QuantityTypeTest.java index 6500685be..6e7c40e9e 100644 --- a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/QuantityTypeTest.java +++ b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/types/QuantityTypeTest.java @@ -46,7 +46,7 @@ public class QuantityTypeTest { @Test public void testDimensionless() { // Dimensionless value that works - new QuantityType("57%"); + new QuantityType<>("57%"); QuantityType dt0 = new QuantityType<>("12"); assertTrue(dt0.getUnit().getDimension() == QuantityDimension.NONE); @@ -97,7 +97,7 @@ public class QuantityTypeTest { assertEquals(dt1.intValue(), dt2.intValue()); - QuantityType dt3 = new QuantityType("200cm"); + QuantityType dt3 = new QuantityType<>("200cm"); assertEquals(dt3.compareTo(dt2), 0); assertTrue(dt3.equals(dt2)); @@ -262,11 +262,11 @@ public class QuantityTypeTest { density = density.toUnit("W/cm²"); assertEquals("0.001 W/cm²", density.toString()); - density = new QuantityType(2, SmartHomeUnits.IRRADIANCE); + density = new QuantityType<>(2, SmartHomeUnits.IRRADIANCE); assertEquals(2, density.doubleValue(), 1E-5); assertEquals("2 W/m²", density.toString()); - density = new QuantityType("3 W/m^2"); + density = new QuantityType<>("3 W/m^2"); assertEquals(3, density.doubleValue(), 1E-5); assertEquals("3 W/m²", density.toString()); } diff --git a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/unit/SmartHomeUnitsTest.java b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/unit/SmartHomeUnitsTest.java index 13397deb1..8f49b903d 100644 --- a/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/unit/SmartHomeUnitsTest.java +++ b/bundles/org.openhab.core/src/test/java/org/eclipse/smarthome/core/library/unit/SmartHomeUnitsTest.java @@ -248,7 +248,7 @@ public class SmartHomeUnitsTest { @Test public void testDobsonUnits() { // https://en.wikipedia.org/wiki/Dobson_unit - QuantityType oneDU = new QuantityType("1 DU"); + QuantityType oneDU = new QuantityType<>("1 DU"); QuantityType mmolpsq = oneDU.toUnit(MetricPrefix.MILLI(Units.MOLE).multiply(Units.METRE.pow(-2))); assertThat(mmolpsq.doubleValue(), is(closeTo(0.4462d, DEFAULT_ERROR))); assertThat(mmolpsq.toUnit(SmartHomeUnits.DOBSON_UNIT).doubleValue(), is(closeTo(1, DEFAULT_ERROR))); diff --git a/itests/org.openhab.core.auth.oauth2client.tests/src/main/java/org/eclipse/smarthome/auth/oauth2client/test/internal/cipher/CipherTest.java b/itests/org.openhab.core.auth.oauth2client.tests/src/main/java/org/eclipse/smarthome/auth/oauth2client/test/internal/cipher/CipherTest.java index 849137ed4..96ecea4de 100644 --- a/itests/org.openhab.core.auth.oauth2client.tests/src/main/java/org/eclipse/smarthome/auth/oauth2client/test/internal/cipher/CipherTest.java +++ b/itests/org.openhab.core.auth.oauth2client.tests/src/main/java/org/eclipse/smarthome/auth/oauth2client/test/internal/cipher/CipherTest.java @@ -72,7 +72,7 @@ public class CipherTest { } private Configuration mockConfiguration() { - Dictionary properties = new Hashtable(); + Dictionary properties = new Hashtable<>(); Configuration configurationMock = mock(Configuration.class); when(configurationMock.getPid()).thenReturn("PID"); when(configurationMock.getProperties()).thenReturn(properties); diff --git a/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/internal/RuleEngineTest.java b/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/internal/RuleEngineTest.java index 167291348..f97da3dad 100644 --- a/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/internal/RuleEngineTest.java +++ b/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/internal/RuleEngineTest.java @@ -115,13 +115,13 @@ public class RuleEngineTest extends JavaOSGiTest { @Test public void testRuleTags() { RuleImpl rule1 = new RuleImpl("ruleWithTag1"); - Set ruleTags = new LinkedHashSet(); + Set ruleTags = new LinkedHashSet<>(); ruleTags.add("tag1"); rule1.setTags(ruleTags); ruleRegistry.add(rule1); RuleImpl rule2 = new RuleImpl("ruleWithTags12"); - ruleTags = new LinkedHashSet(); + ruleTags = new LinkedHashSet<>(); ruleTags.add("tag1"); ruleTags.add("tag2"); rule2.setTags(ruleTags); @@ -190,7 +190,7 @@ public class RuleEngineTest extends JavaOSGiTest { @Test public void testRuleActions() { RuleImpl rule1 = createRule(); - List actions = new ArrayList(rule1.getActions()); + List actions = new ArrayList<>(rule1.getActions()); ruleRegistry.add(rule1); Rule rule1Get = ruleEngine.getRule("rule1"); @@ -225,7 +225,7 @@ public class RuleEngineTest extends JavaOSGiTest { @Test public void testRuleTriggers() { RuleImpl rule1 = createRule(); - List triggers = new ArrayList(rule1.getTriggers()); + List triggers = new ArrayList<>(rule1.getTriggers()); ruleRegistry.add(rule1); Rule rule1Get = ruleEngine.getRule("rule1"); List triggersGet = rule1Get.getTriggers(); @@ -286,7 +286,7 @@ public class RuleEngineTest extends JavaOSGiTest { } private List createTriggers(String type) { - List triggers = new ArrayList(); + List triggers = new ArrayList<>(); Configuration configurations = new Configuration(); configurations.put("a", "x"); configurations.put("b", "y"); @@ -297,12 +297,12 @@ public class RuleEngineTest extends JavaOSGiTest { } private List createConditions(String type) { - List conditions = new ArrayList(); + List conditions = new ArrayList<>(); Configuration configurations = new Configuration(); configurations.put("a", "x"); configurations.put("b", "y"); configurations.put("c", "z"); - Map inputs = new HashMap(11); + Map inputs = new HashMap<>(11); String ouputModuleId = "triggerId"; String outputName = "triggerOutput"; String inputName = "conditionInput"; @@ -313,12 +313,12 @@ public class RuleEngineTest extends JavaOSGiTest { } private List createActions(String type) { - List actions = new ArrayList(); + List actions = new ArrayList<>(); Configuration configurations = new Configuration(); configurations.put("a", "x"); configurations.put("b", "y"); configurations.put("c", "z"); - Map inputs = new HashMap(11); + Map inputs = new HashMap<>(11); String ouputModuleId = "triggerId"; String outputName = "triggerOutput"; String inputName = "actionInput"; @@ -330,8 +330,8 @@ public class RuleEngineTest extends JavaOSGiTest { } private List createConfigDescriptions() { - List configDescriptions = new ArrayList(); - List options = new ArrayList(); + List configDescriptions = new ArrayList<>(); + List options = new ArrayList<>(); options.add(new ParameterOption("1", "one")); options.add(new ParameterOption("2", "two")); @@ -354,7 +354,7 @@ public class RuleEngineTest extends JavaOSGiTest { String typeStr = ConfigDescriptionParameter.Type.INTEGER.name(); String defValue = "3"; - List filter = new ArrayList(); + List filter = new ArrayList<>(); String configPropertyName = "config1"; diff --git a/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/internal/TestModuleTypeProvider.java b/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/internal/TestModuleTypeProvider.java index f57c6bcd2..8c28f23d6 100644 --- a/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/internal/TestModuleTypeProvider.java +++ b/itests/org.openhab.core.automation.tests/src/main/java/org/openhab/core/automation/internal/TestModuleTypeProvider.java @@ -50,7 +50,7 @@ public class TestModuleTypeProvider implements ModuleTypeProvider { } private TriggerType createTriggerType() { - List outputs = new ArrayList(3); + List outputs = new ArrayList<>(3); outputs.add(createOutput("out1", new String[] { "tagA" })); outputs.add(createOutput("out2", new String[] { "tagB", "tagC" })); outputs.add(createOutput("out3", new String[] { "tagA", "tagB", "tagC" })); @@ -59,7 +59,7 @@ public class TestModuleTypeProvider implements ModuleTypeProvider { } private ConditionType createConditionType() { - List inputs = new ArrayList(3); + List inputs = new ArrayList<>(3); inputs.add(createInput("in0", new String[] { "tagE" })); // no connection, missing condition tag inputs.add(createInput("in1", new String[] { "tagA" })); // conflict in2 -> out1 or in2 -> out3 inputs.add(createInput("in2", new String[] { "tagA", "tagB" })); // in2 -> out3 @@ -68,13 +68,13 @@ public class TestModuleTypeProvider implements ModuleTypeProvider { } private ActionType createActionType() { - List inputs = new ArrayList(3); + List inputs = new ArrayList<>(3); inputs.add(createInput("in3", new String[] { "tagD" })); // conflict in3 -> out4 or in3 -> out5 inputs.add(createInput("in4", new String[] { "tagD", "tagE" })); // in4 -> out5 inputs.add(createInput("in5", new String[] { "tagA", "tagB", "tagC" })); // in5 -> out3 inputs.add(createInput("in6", new String[] { "tagA", "tagB" })); // conflict in6 has user defined connection - List outputs = new ArrayList(3); + List outputs = new ArrayList<>(3); outputs.add(createOutput("out4", new String[] { "tagD" })); outputs.add(createOutput("out5", new String[] { "tagD", "tagE" })); ActionType t = new ActionType(ACTION_TYPE, null, inputs, outputs); @@ -82,12 +82,12 @@ public class TestModuleTypeProvider implements ModuleTypeProvider { } private Output createOutput(String name, String[] tags) { - Set tagSet = new HashSet(Arrays.asList(tags)); + Set tagSet = new HashSet<>(Arrays.asList(tags)); return new Output(name, String.class.getName(), null, null, tagSet, null, null); } private Input createInput(String name, String[] tags) { - Set tagSet = new HashSet(Arrays.asList(tags)); + Set tagSet = new HashSet<>(Arrays.asList(tags)); return new Input(name, String.class.getName(), null, null, tagSet, false, null, null); } diff --git a/itests/org.openhab.core.config.core.tests/src/main/java/org/eclipse/smarthome/config/core/ConfigOptionRegistryOSGiTest.java b/itests/org.openhab.core.config.core.tests/src/main/java/org/eclipse/smarthome/config/core/ConfigOptionRegistryOSGiTest.java index d97862265..56167f578 100644 --- a/itests/org.openhab.core.config.core.tests/src/main/java/org/eclipse/smarthome/config/core/ConfigOptionRegistryOSGiTest.java +++ b/itests/org.openhab.core.config.core.tests/src/main/java/org/eclipse/smarthome/config/core/ConfigOptionRegistryOSGiTest.java @@ -46,7 +46,7 @@ public class ConfigOptionRegistryOSGiTest extends JavaOSGiTest { configDescriptionRegistry = getService(ConfigDescriptionRegistry.class); ConfigDescriptionParameter parm1 = new ConfigDescriptionParameter("Parm1", ConfigDescriptionParameter.Type.INTEGER); - List pList1 = new ArrayList(); + List pList1 = new ArrayList<>(); pList1.add(parm1); configDescription = new ConfigDescription(new URI("config:Dummy"), pList1); diff --git a/itests/org.openhab.core.config.discovery.tests/src/main/java/org/eclipse/smarthome/config/discovery/internal/InboxOSGiTest.java b/itests/org.openhab.core.config.discovery.tests/src/main/java/org/eclipse/smarthome/config/discovery/internal/InboxOSGiTest.java index 115a0dc82..984fd2934 100644 --- a/itests/org.openhab.core.config.discovery.tests/src/main/java/org/eclipse/smarthome/config/discovery/internal/InboxOSGiTest.java +++ b/itests/org.openhab.core.config.discovery.tests/src/main/java/org/eclipse/smarthome/config/discovery/internal/InboxOSGiTest.java @@ -469,9 +469,9 @@ public class InboxOSGiTest extends JavaOSGiTest { DiscoveryResult discoveryResult = new DiscoveryResultImpl(thingTypeUID, thingUID, null, props, "property1", "DummyLabel1", DEFAULT_TTL); - AsyncResultWrapper addedDiscoveryResultWrapper = new AsyncResultWrapper(); - AsyncResultWrapper updatedDiscoveryResultWrapper = new AsyncResultWrapper(); - AsyncResultWrapper removedDiscoveryResultWrapper = new AsyncResultWrapper(); + AsyncResultWrapper addedDiscoveryResultWrapper = new AsyncResultWrapper<>(); + AsyncResultWrapper updatedDiscoveryResultWrapper = new AsyncResultWrapper<>(); + AsyncResultWrapper removedDiscoveryResultWrapper = new AsyncResultWrapper<>(); @NonNullByDefault InboxListener inboxListener = new InboxListener() { @@ -542,9 +542,9 @@ public class InboxOSGiTest extends JavaOSGiTest { discoveryResult = new DiscoveryResultImpl(thingTypeUID, thingUID, null, props, "property3", "DummyLabel2", DEFAULT_TTL); - AsyncResultWrapper addedDiscoveryResultWrapper = new AsyncResultWrapper(); - AsyncResultWrapper updatedDiscoveryResultWrapper = new AsyncResultWrapper(); - AsyncResultWrapper removedDiscoveryResultWrapper = new AsyncResultWrapper(); + AsyncResultWrapper addedDiscoveryResultWrapper = new AsyncResultWrapper<>(); + AsyncResultWrapper updatedDiscoveryResultWrapper = new AsyncResultWrapper<>(); + AsyncResultWrapper removedDiscoveryResultWrapper = new AsyncResultWrapper<>(); @NonNullByDefault InboxListener inboxListener = new InboxListener() { @@ -607,9 +607,9 @@ public class InboxOSGiTest extends JavaOSGiTest { "DummyLabel1", DEFAULT_TTL); assertTrue(addDiscoveryResult(discoveryResult)); - AsyncResultWrapper addedDiscoveryResultWrapper = new AsyncResultWrapper(); - AsyncResultWrapper updatedDiscoveryResultWrapper = new AsyncResultWrapper(); - AsyncResultWrapper removedDiscoveryResultWrapper = new AsyncResultWrapper(); + AsyncResultWrapper addedDiscoveryResultWrapper = new AsyncResultWrapper<>(); + AsyncResultWrapper updatedDiscoveryResultWrapper = new AsyncResultWrapper<>(); + AsyncResultWrapper removedDiscoveryResultWrapper = new AsyncResultWrapper<>(); @NonNullByDefault InboxListener inboxListener = new InboxListener() { diff --git a/itests/org.openhab.core.io.rest.core.tests/src/main/java/org/eclipse/smarthome/io/rest/core/internal/persistence/PersistenceResourceTest.java b/itests/org.openhab.core.io.rest.core.tests/src/main/java/org/eclipse/smarthome/io/rest/core/internal/persistence/PersistenceResourceTest.java index 59a710436..df436e7be 100644 --- a/itests/org.openhab.core.io.rest.core.tests/src/main/java/org/eclipse/smarthome/io/rest/core/internal/persistence/PersistenceResourceTest.java +++ b/itests/org.openhab.core.io.rest.core.tests/src/main/java/org/eclipse/smarthome/io/rest/core/internal/persistence/PersistenceResourceTest.java @@ -18,6 +18,7 @@ import static org.mockito.Mockito.*; import java.util.ArrayList; import java.util.Date; +import java.util.List; import java.util.TimeZone; import org.eclipse.smarthome.core.i18n.TimeZoneProvider; @@ -41,7 +42,7 @@ public class PersistenceResourceTest { private static final String PERSISTENCE_SERVICE_ID = "TestServiceID"; private PersistenceResource pResource; - private ArrayList items; + private List items; @Before public void setup() { @@ -49,7 +50,7 @@ public class PersistenceResourceTest { int startValue = 2016; int endValue = 2018; - items = new ArrayList(endValue - startValue); + items = new ArrayList<>(endValue - startValue); for (int i = startValue; i <= endValue; i++) { final int year = i; items.add(new HistoricItem() { diff --git a/itests/org.openhab.core.model.persistence.tests/src/main/java/org/eclipse/smarthome/model/persistence/tests/TestPersistenceService.java b/itests/org.openhab.core.model.persistence.tests/src/main/java/org/eclipse/smarthome/model/persistence/tests/TestPersistenceService.java index 2daf9c73a..038375576 100644 --- a/itests/org.openhab.core.model.persistence.tests/src/main/java/org/eclipse/smarthome/model/persistence/tests/TestPersistenceService.java +++ b/itests/org.openhab.core.model.persistence.tests/src/main/java/org/eclipse/smarthome/model/persistence/tests/TestPersistenceService.java @@ -15,6 +15,7 @@ package org.eclipse.smarthome.model.persistence.tests; import java.util.ArrayList; import java.util.Collections; import java.util.Date; +import java.util.List; import java.util.Locale; import java.util.Set; @@ -64,7 +65,7 @@ public class TestPersistenceService implements QueryablePersistenceService { return Collections.emptyList(); } - ArrayList results = new ArrayList(endValue - startValue); + List results = new ArrayList<>(endValue - startValue); for (int i = startValue; i <= endValue; i++) { final int year = i; results.add(new HistoricItem() { diff --git a/itests/org.openhab.core.model.script.tests/src/main/java/org/eclipse/smarthome/model/script/lib/NumberExtensionsTest.java b/itests/org.openhab.core.model.script.tests/src/main/java/org/eclipse/smarthome/model/script/lib/NumberExtensionsTest.java index 8dc446704..02fe8d11f 100644 --- a/itests/org.openhab.core.model.script.tests/src/main/java/org/eclipse/smarthome/model/script/lib/NumberExtensionsTest.java +++ b/itests/org.openhab.core.model.script.tests/src/main/java/org/eclipse/smarthome/model/script/lib/NumberExtensionsTest.java @@ -36,11 +36,11 @@ public class NumberExtensionsTest { private static final DecimalType DECIMAL1 = new DecimalType(1); private static final DecimalType DECIMAL2 = new DecimalType(2); - private static final QuantityType Q_CELSIUS_1 = new QuantityType("1 °C"); - private static final QuantityType Q_CELSIUS_2 = new QuantityType("2 °C"); + private static final QuantityType Q_CELSIUS_1 = new QuantityType<>("1 °C"); + private static final QuantityType Q_CELSIUS_2 = new QuantityType<>("2 °C"); - private static final QuantityType Q_LENGTH_1_M = new QuantityType("1 m"); - private static final QuantityType Q_LENGTH_2_CM = new QuantityType("2 cm"); + private static final QuantityType Q_LENGTH_1_M = new QuantityType<>("1 m"); + private static final QuantityType Q_LENGTH_2_CM = new QuantityType<>("2 cm"); private static final QuantityType Q_ONE_1 = new QuantityType<>(1, SmartHomeUnits.ONE); private static final QuantityType Q_ONE_2 = new QuantityType<>(2, SmartHomeUnits.ONE); @@ -127,7 +127,7 @@ public class NumberExtensionsTest { @Test public void operatorEqualsQuantityQuantityTrue() { - assertTrue(NumberExtensions.operator_equals(Q_LENGTH_1_M, new QuantityType("100 cm"))); + assertTrue(NumberExtensions.operator_equals(Q_LENGTH_1_M, new QuantityType<>("100 cm"))); } @Test @@ -172,8 +172,7 @@ public class NumberExtensionsTest { @Test public void operatorLessEqualsThanNumberQuantity() { - assertFalse( - NumberExtensions.operator_lessEqualsThan(BigDecimal.valueOf(100), new QuantityType("100 cm"))); + assertFalse(NumberExtensions.operator_lessEqualsThan(BigDecimal.valueOf(100), new QuantityType<>("100 cm"))); } @Test @@ -193,14 +192,12 @@ public class NumberExtensionsTest { @Test public void operatorGreaterEqualsThanNumberQuantity() { - assertFalse( - NumberExtensions.operator_greaterEqualsThan(BigDecimal.valueOf(1), new QuantityType("1 km"))); + assertFalse(NumberExtensions.operator_greaterEqualsThan(BigDecimal.valueOf(1), new QuantityType<>("1 km"))); } @Test public void operatorGreaterEqualsThanTypeQuantity() { - assertTrue( - NumberExtensions.operator_greaterEqualsThan((Type) Q_LENGTH_1_M, new QuantityType("100 cm"))); + assertTrue(NumberExtensions.operator_greaterEqualsThan((Type) Q_LENGTH_1_M, new QuantityType<>("100 cm"))); } @Test diff --git a/itests/org.openhab.core.model.thing.testsupport/src/main/java/org/eclipse/smarthome/model/thing/testsupport/hue/DumbThingTypeProvider.java b/itests/org.openhab.core.model.thing.testsupport/src/main/java/org/eclipse/smarthome/model/thing/testsupport/hue/DumbThingTypeProvider.java index 92e41644f..16a6a7dfb 100644 --- a/itests/org.openhab.core.model.thing.testsupport/src/main/java/org/eclipse/smarthome/model/thing/testsupport/hue/DumbThingTypeProvider.java +++ b/itests/org.openhab.core.model.thing.testsupport/src/main/java/org/eclipse/smarthome/model/thing/testsupport/hue/DumbThingTypeProvider.java @@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory; public class DumbThingTypeProvider implements ThingTypeProvider { private final Logger logger = LoggerFactory.getLogger(DumbThingTypeProvider.class); - private static final Map THING_TYPES = new HashMap(); + private static final Map THING_TYPES = new HashMap<>(); public DumbThingTypeProvider() { logger.debug("DumbThingTypeProvider created"); diff --git a/itests/org.openhab.core.model.thing.testsupport/src/main/java/org/eclipse/smarthome/model/thing/testsupport/hue/TestHueThingTypeProvider.java b/itests/org.openhab.core.model.thing.testsupport/src/main/java/org/eclipse/smarthome/model/thing/testsupport/hue/TestHueThingTypeProvider.java index c4aee1ecb..093159314 100644 --- a/itests/org.openhab.core.model.thing.testsupport/src/main/java/org/eclipse/smarthome/model/thing/testsupport/hue/TestHueThingTypeProvider.java +++ b/itests/org.openhab.core.model.thing.testsupport/src/main/java/org/eclipse/smarthome/model/thing/testsupport/hue/TestHueThingTypeProvider.java @@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory; public class TestHueThingTypeProvider implements ThingTypeProvider { private final Logger logger = LoggerFactory.getLogger(TestHueThingTypeProvider.class); - private static final Map THING_TYPES = new HashMap(); + private static final Map THING_TYPES = new HashMap<>(); public TestHueThingTypeProvider() { logger.debug("TestHueThingTypeProvider created"); diff --git a/itests/org.openhab.core.tests/src/main/java/org/eclipse/smarthome/core/cache/ExpiringCacheAsyncTest.java b/itests/org.openhab.core.tests/src/main/java/org/eclipse/smarthome/core/cache/ExpiringCacheAsyncTest.java index 0396084d2..26dd0e052 100644 --- a/itests/org.openhab.core.tests/src/main/java/org/eclipse/smarthome/core/cache/ExpiringCacheAsyncTest.java +++ b/itests/org.openhab.core.tests/src/main/java/org/eclipse/smarthome/core/cache/ExpiringCacheAsyncTest.java @@ -28,17 +28,18 @@ import org.junit.Test; * @author David Graeff - Initial contribution */ public class ExpiringCacheAsyncTest extends JavaTest { - double theValue = 0; + + private double theValue = 0; @Test(expected = IllegalArgumentException.class) public void testConstructorWrongCacheTime() { // Fail if cache time is <= 0 - new ExpiringCacheAsync(0); + new ExpiringCacheAsync<>(0); } @Test public void testFetchValue() throws InterruptedException, ExecutionException { - ExpiringCacheAsync t = new ExpiringCacheAsync(500); + ExpiringCacheAsync t = new ExpiringCacheAsync<>(500); assertTrue(t.isExpired()); // We should always be able to get the raw value, expired or not assertNull(t.getLastKnownValue()); @@ -75,9 +76,9 @@ public class ExpiringCacheAsyncTest extends JavaTest { @Test public void testMutipleGetsWhileRefetching() { - ExpiringCacheAsync t = new ExpiringCacheAsync(100); + ExpiringCacheAsync t = new ExpiringCacheAsync<>(100); - CompletableFuture v = new CompletableFuture(); + CompletableFuture v = new CompletableFuture<>(); // Define a supplier which returns a future that is not yet completed Supplier> s = () -> v; diff --git a/itests/org.openhab.core.tests/src/main/java/org/eclipse/smarthome/core/internal/items/ItemUpdaterOSGiTest.java b/itests/org.openhab.core.tests/src/main/java/org/eclipse/smarthome/core/internal/items/ItemUpdaterOSGiTest.java index 5f677ae23..d37656a64 100644 --- a/itests/org.openhab.core.tests/src/main/java/org/eclipse/smarthome/core/internal/items/ItemUpdaterOSGiTest.java +++ b/itests/org.openhab.core.tests/src/main/java/org/eclipse/smarthome/core/internal/items/ItemUpdaterOSGiTest.java @@ -45,7 +45,7 @@ public class ItemUpdaterOSGiTest extends JavaOSGiTest { private EventPublisher eventPublisher; private ItemRegistry itemRegistry; - private final ConcurrentLinkedQueue receivedEvents = new ConcurrentLinkedQueue(); + private final ConcurrentLinkedQueue receivedEvents = new ConcurrentLinkedQueue<>(); @Before public void setUp() { diff --git a/itests/org.openhab.core.tests/src/main/java/org/eclipse/smarthome/core/items/GroupItemOSGiTest.java b/itests/org.openhab.core.tests/src/main/java/org/eclipse/smarthome/core/items/GroupItemOSGiTest.java index 0200e79dc..706776881 100644 --- a/itests/org.openhab.core.tests/src/main/java/org/eclipse/smarthome/core/items/GroupItemOSGiTest.java +++ b/itests/org.openhab.core.tests/src/main/java/org/eclipse/smarthome/core/items/GroupItemOSGiTest.java @@ -73,10 +73,10 @@ public class GroupItemOSGiTest extends JavaOSGiTest { /** Time to sleep when a file is created/modified/deleted, so the event can be handled */ private static final int WAIT_EVENT_TO_BE_HANDLED = 1000; - List events = new LinkedList<>(); - EventPublisher publisher; + private List events = new LinkedList<>(); + private EventPublisher publisher; - ItemRegistry itemRegistry; + private ItemRegistry itemRegistry; @Mock private UnitProvider unitProvider; @@ -102,7 +102,7 @@ public class GroupItemOSGiTest extends JavaOSGiTest { @Override public Set getSubscribedEventTypes() { - HashSet hs = new HashSet<>(); + Set hs = new HashSet<>(); hs.add(ItemUpdatedEvent.TYPE); return hs; } @@ -685,11 +685,11 @@ public class GroupItemOSGiTest extends JavaOSGiTest { GroupItem groupItem = new GroupItem("number", baseItem, function); groupItem.setUnitProvider(unitProvider); - NumberItem celsius = createNumberItem("C", Temperature.class, new QuantityType("23 °C")); + NumberItem celsius = createNumberItem("C", Temperature.class, new QuantityType<>("23 °C")); groupItem.addMember(celsius); - NumberItem fahrenheit = createNumberItem("F", Temperature.class, new QuantityType("23 °F")); + NumberItem fahrenheit = createNumberItem("F", Temperature.class, new QuantityType<>("23 °F")); groupItem.addMember(fahrenheit); - NumberItem kelvin = createNumberItem("K", Temperature.class, new QuantityType("23 K")); + NumberItem kelvin = createNumberItem("K", Temperature.class, new QuantityType<>("23 K")); groupItem.addMember(kelvin); QuantityType state = groupItem.getStateAs(QuantityType.class); @@ -697,7 +697,7 @@ public class GroupItemOSGiTest extends JavaOSGiTest { assertThat(state.getUnit(), is(Units.CELSIUS)); assertThat(state.doubleValue(), is(-232.15d)); - celsius.setState(new QuantityType("265 °C")); + celsius.setState(new QuantityType<>("265 °C")); state = groupItem.getStateAs(QuantityType.class); @@ -716,19 +716,19 @@ public class GroupItemOSGiTest extends JavaOSGiTest { groupItem.setUnitProvider(unitProvider); groupItem.setItemStateConverter(itemStateConverter); - NumberItem celsius = createNumberItem("C", Temperature.class, new QuantityType("23 °C")); + NumberItem celsius = createNumberItem("C", Temperature.class, new QuantityType<>("23 °C")); groupItem.addMember(celsius); - NumberItem hectoPascal = createNumberItem("F", Pressure.class, new QuantityType("1010 hPa")); + NumberItem hectoPascal = createNumberItem("F", Pressure.class, new QuantityType<>("1010 hPa")); groupItem.addMember(hectoPascal); - NumberItem percent = createNumberItem("K", Dimensionless.class, new QuantityType("110 %")); + NumberItem percent = createNumberItem("K", Dimensionless.class, new QuantityType<>("110 %")); groupItem.addMember(percent); QuantityType state = groupItem.getStateAs(QuantityType.class); - assertThat(state, is(new QuantityType("23 °C"))); + assertThat(state, is(new QuantityType<>("23 °C"))); groupItem.stateUpdated(celsius, UnDefType.NULL); - assertThat(groupItem.getState(), is(new QuantityType("23 °C"))); + assertThat(groupItem.getState(), is(new QuantityType<>("23 °C"))); } private NumberItem createNumberItem(String name, Class> dimension, State state) { diff --git a/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/binding/ChangeThingTypeOSGiTest.java b/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/binding/ChangeThingTypeOSGiTest.java index aa2643e32..0d38343f3 100644 --- a/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/binding/ChangeThingTypeOSGiTest.java +++ b/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/binding/ChangeThingTypeOSGiTest.java @@ -428,8 +428,7 @@ public class ChangeThingTypeOSGiTest extends JavaOSGiTest { List channelDefinitions = new ArrayList<>(); ChannelTypeUID channelTypeUID = new ChannelTypeUID("test:" + thingTypeUID.getId()); ChannelType channelType = new ChannelType(channelTypeUID, false, "itemType", "channelLabel", "description", - "category", new HashSet(), null, - new URI("scheme", "channelType:" + thingTypeUID.getId(), null)); + "category", new HashSet<>(), null, new URI("scheme", "channelType:" + thingTypeUID.getId(), null)); channelTypes.put(channelTypeUID, channelType); diff --git a/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/internal/ThingRegistryOSGiTest.java b/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/internal/ThingRegistryOSGiTest.java index 5ac30eb41..acdaff653 100644 --- a/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/internal/ThingRegistryOSGiTest.java +++ b/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/internal/ThingRegistryOSGiTest.java @@ -201,7 +201,7 @@ public class ThingRegistryOSGiTest extends JavaOSGiTest { ThingUID expectedBridgeUID = new ThingUID(THING_TYPE_UID, THING2_ID); String expectedLabel = "Test Thing"; - AtomicReference thingResultWrapper = new AtomicReference(); + AtomicReference thingResultWrapper = new AtomicReference<>(); ThingRegistry thingRegistry = getService(ThingRegistry.class); diff --git a/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/internal/firmware/FirmwareUpdateServiceTest.java b/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/internal/firmware/FirmwareUpdateServiceTest.java index 48bd973d4..cfa3b6c0d 100644 --- a/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/internal/firmware/FirmwareUpdateServiceTest.java +++ b/itests/org.openhab.core.thing.tests/src/main/java/org/eclipse/smarthome/core/thing/internal/firmware/FirmwareUpdateServiceTest.java @@ -956,7 +956,7 @@ public class FirmwareUpdateServiceTest extends JavaOSGiTest { firmwareUpdateService.updateFirmware(THING4_UID, FW111_EN.getVersion(), locale); firmwareUpdateService.cancelFirmwareUpdate(THING4_UID); - AtomicReference resultEvent = new AtomicReference(); + AtomicReference resultEvent = new AtomicReference<>(); waitForAssert(() -> { ArgumentCaptor eventCaptor = ArgumentCaptor .forClass(FirmwareUpdateResultInfoEvent.class); diff --git a/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/internal/AudioSourceStub.java b/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/internal/AudioSourceStub.java index 64120a1ea..cbbaa6233 100644 --- a/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/internal/AudioSourceStub.java +++ b/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/internal/AudioSourceStub.java @@ -13,9 +13,10 @@ package org.eclipse.smarthome.core.voice.internal; import java.io.IOException; -import java.util.HashSet; import java.util.Locale; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.eclipse.smarthome.core.audio.AudioException; import org.eclipse.smarthome.core.audio.AudioFormat; @@ -30,7 +31,8 @@ import org.eclipse.smarthome.core.audio.AudioStream; */ public class AudioSourceStub implements AudioSource { - private Set supportedFormats = new HashSet(); + private static final Set SUPPORTED_FORMATS = Stream.of(AudioFormat.MP3, AudioFormat.WAV) + .collect(Collectors.toSet()); private static final String AUDIOSOURCE_STUB_ID = "audioSouceID"; private static final String AUDIOSOURCE_STUB_LABEL = "audioSouceLabel"; @@ -47,9 +49,7 @@ public class AudioSourceStub implements AudioSource { @Override public Set getSupportedFormats() { - supportedFormats.add(AudioFormat.MP3); - supportedFormats.add(AudioFormat.WAV); - return supportedFormats; + return SUPPORTED_FORMATS; } @Override diff --git a/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/internal/KSServiceStub.java b/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/internal/KSServiceStub.java index e3ce20a43..5e9e484ba 100644 --- a/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/internal/KSServiceStub.java +++ b/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/internal/KSServiceStub.java @@ -12,9 +12,10 @@ */ package org.eclipse.smarthome.core.voice.internal; -import java.util.HashSet; import java.util.Locale; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.eclipse.smarthome.core.audio.AudioFormat; import org.eclipse.smarthome.core.audio.AudioStream; @@ -31,14 +32,15 @@ import org.eclipse.smarthome.core.voice.KSServiceHandle; */ public class KSServiceStub implements KSService { - private Set supportedFormats = new HashSet(); - - private boolean isWordSpotted; - private boolean isKSExceptionExpected; + private static final Set SUPPORTED_FORMATS = Stream.of(AudioFormat.MP3, AudioFormat.WAV) + .collect(Collectors.toSet()); private static final String KSSERVICE_STUB_ID = "ksServiceStubID"; private static final String KSSERVICE_STUB_LABEL = "ksServiceStubLabel"; + private boolean isWordSpotted; + private boolean isKSExceptionExpected; + @Override public String getId() { return KSSERVICE_STUB_ID; @@ -60,9 +62,7 @@ public class KSServiceStub implements KSService { @Override public Set getSupportedFormats() { - supportedFormats.add(AudioFormat.MP3); - supportedFormats.add(AudioFormat.WAV); - return supportedFormats; + return SUPPORTED_FORMATS; } @Override diff --git a/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/internal/TTSServiceStub.java b/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/internal/TTSServiceStub.java index c7ebbe764..8786d965a 100644 --- a/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/internal/TTSServiceStub.java +++ b/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/internal/TTSServiceStub.java @@ -17,6 +17,8 @@ import java.util.Collection; import java.util.HashSet; import java.util.Locale; import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.eclipse.smarthome.core.audio.AudioFormat; import org.eclipse.smarthome.core.audio.AudioStream; @@ -35,14 +37,15 @@ import org.osgi.framework.ServiceReference; */ public class TTSServiceStub implements TTSService { - private BundleContext context; - - private Set availableVoices; - private Set supportedFormats; + private static final Set SUPPORTED_FORMATS = Stream.of(AudioFormat.MP3, AudioFormat.WAV) + .collect(Collectors.toSet()); private static final String TTS_SERVICE_STUB_ID = "ttsServiceStubID"; private static final String TTS_SERVICE_STUB_LABEL = "ttsServiceStubLabel"; + private Set availableVoices; + private BundleContext context; + public TTSServiceStub(BundleContext context) { this.context = context; } @@ -62,7 +65,7 @@ public class TTSServiceStub implements TTSService { @Override public Set getAvailableVoices() { - availableVoices = new HashSet(); + availableVoices = new HashSet<>(); Collection> refs; try { refs = context.getServiceReferences(Voice.class, null); @@ -83,10 +86,7 @@ public class TTSServiceStub implements TTSService { @Override public Set getSupportedFormats() { - supportedFormats = new HashSet(); - supportedFormats.add(AudioFormat.MP3); - supportedFormats.add(AudioFormat.WAV); - return supportedFormats; + return SUPPORTED_FORMATS; } @Override diff --git a/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/javavoicemanager/VoiceManagerTest.java b/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/javavoicemanager/VoiceManagerTest.java index 56f1a0c06..20b36cf45 100644 --- a/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/javavoicemanager/VoiceManagerTest.java +++ b/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/javavoicemanager/VoiceManagerTest.java @@ -89,7 +89,7 @@ public class VoiceManagerTest extends JavaOSGiTest { registerService(sink); registerService(voice); - Dictionary voiceConfig = new Hashtable(); + Dictionary voiceConfig = new Hashtable<>(); voiceConfig.put(CONFIG_DEFAULT_TTS, ttsService.getId()); ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class); Configuration configuration = configAdmin.getConfiguration(PID); @@ -161,7 +161,7 @@ public class VoiceManagerTest extends JavaOSGiTest { hliStub = new HumanLanguageInterpreterStub(); registerService(hliStub); - Dictionary voiceConfig = new Hashtable(); + Dictionary voiceConfig = new Hashtable<>(); voiceConfig.put("defaultHLI", hliStub.getId()); ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class); String pid = "org.eclipse.smarthome.voice"; @@ -241,7 +241,7 @@ public class VoiceManagerTest extends JavaOSGiTest { registerService(hliStub); registerService(source); - Dictionary config = new Hashtable(); + Dictionary config = new Hashtable<>(); config.put(CONFIG_KEYWORD, "word"); config.put(CONFIG_DEFAULT_STT, sttService.getId()); config.put(CONFIG_DEFAULT_KS, ksService.getId()); diff --git a/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/voiceconsolecommandextension/InterpretCommandTest.java b/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/voiceconsolecommandextension/InterpretCommandTest.java index 50ae2ef92..feed6dce7 100644 --- a/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/voiceconsolecommandextension/InterpretCommandTest.java +++ b/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/voiceconsolecommandextension/InterpretCommandTest.java @@ -56,7 +56,7 @@ public class InterpretCommandTest extends VoiceConsoleCommandExtensionTest { registerService(hliStub); registerService(ttsService); - Dictionary config = new Hashtable(); + Dictionary config = new Hashtable<>(); config.put(CONFIG_DEFAULT_TTS, ttsService.getId()); config.put(CONFIG_DEFAULT_HLI, hliStub.getId()); config.put(CONFIG_DEFAULT_VOICE, voice.getUID()); diff --git a/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/voiceconsolecommandextension/SayCommandTest.java b/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/voiceconsolecommandextension/SayCommandTest.java index 1b8e461a2..15f3b8372 100644 --- a/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/voiceconsolecommandextension/SayCommandTest.java +++ b/itests/org.openhab.core.voice.tests/src/main/java/org/eclipse/smarthome/core/voice/voiceconsolecommandextension/SayCommandTest.java @@ -109,7 +109,7 @@ public class SayCommandTest extends VoiceConsoleCommandExtensionTest { methodParameters[0] = SUBCMD_SAY; if (defaultTTSService != null) { - Dictionary config = new Hashtable(); + Dictionary config = new Hashtable<>(); config.put(CONFIG_DEFAULT_TTS, defaultTTSService); ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class); String pid = "org.eclipse.smarthome.voice";