Use diamond operator (#1114)

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born 2019-10-11 11:29:47 +02:00 committed by Kai Kreuzer
parent 4e10e0d116
commit 12e8edc039
195 changed files with 665 additions and 672 deletions

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.smarthome.config.core.ConfigDescriptionParameter; 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 RULE_REGISTRY = "ruleRegistry";
private static final String AUTOMATION_MANAGER = "automationManager"; private static final String AUTOMATION_MANAGER = "automationManager";
private static HashMap<String, Collection<String>> presets = new HashMap<>(); private static Map<String, Collection<String>> presets = new HashMap<>();
private static HashMap<String, Object> staticTypes = new HashMap<>(); private static Map<String, Object> staticTypes = new HashMap<>();
private static HashSet<String> types = new HashSet<String>(); private static Set<String> types = new HashSet<>();
private final ConcurrentHashMap<String, HashMap<String, Object>> objectCache = new ConcurrentHashMap<>(); private final Map<String, Map<String, Object>> objectCache = new ConcurrentHashMap<>();
private RuleRegistry ruleRegistry; private RuleRegistry ruleRegistry;
private ScriptedRuleProvider ruleProvider; private ScriptedRuleProvider ruleProvider;
@ -180,7 +181,7 @@ public class RuleSupportScriptExtension implements ScriptExtensionProvider {
return obj; return obj;
} }
HashMap<String, Object> objects = objectCache.get(scriptIdentifier); Map<String, Object> objects = objectCache.get(scriptIdentifier);
if (objects == null) { if (objects == null) {
objects = new HashMap<>(); objects = new HashMap<>();
@ -230,7 +231,7 @@ public class RuleSupportScriptExtension implements ScriptExtensionProvider {
@Override @Override
public void unload(String scriptIdentifier) { public void unload(String scriptIdentifier) {
HashMap<String, Object> objects = objectCache.remove(scriptIdentifier); Map<String, Object> objects = objectCache.remove(scriptIdentifier);
if (objects != null) { if (objects != null) {
Object hr = objects.get(AUTOMATION_MANAGER); Object hr = objects.get(AUTOMATION_MANAGER);

View File

@ -42,7 +42,7 @@ public class SimpleActionHandlerDelegate extends BaseActionModuleHandler {
@Override @Override
public Map<String, Object> execute(Map<String, Object> inputs) { public Map<String, Object> execute(Map<String, Object> inputs) {
Set<String> keys = new HashSet<String>(inputs.keySet()); Set<String> keys = new HashSet<>(inputs.keySet());
Map<String, Object> extendedInputs = new HashMap<>(inputs); Map<String, Object> extendedInputs = new HashMap<>(inputs);
for (String key : keys) { for (String key : keys) {
@ -57,7 +57,7 @@ public class SimpleActionHandlerDelegate extends BaseActionModuleHandler {
} }
Object result = actionHandler.execute(module, extendedInputs); Object result = actionHandler.execute(module, extendedInputs);
HashMap<String, Object> resultMap = new HashMap<String, Object>(); Map<String, Object> resultMap = new HashMap<>();
resultMap.put("result", result); resultMap.put("result", result);
return resultMap; return resultMap;
} }

View File

@ -58,7 +58,7 @@ public class ScriptFileWatcher extends AbstractWatchService {
private final long earliestStart = System.currentTimeMillis() + INITIAL_DELAY * 1000; private final long earliestStart = System.currentTimeMillis() + INITIAL_DELAY * 1000;
private ScriptEngineManager manager; private ScriptEngineManager manager;
ScheduledExecutorService scheduler; private ScheduledExecutorService scheduler;
private final Map<String, Set<URL>> urlsByScriptExtension = new ConcurrentHashMap<>(); private final Map<String, Set<URL>> urlsByScriptExtension = new ConcurrentHashMap<>();
private final Set<URL> loaded = new HashSet<>(); private final Set<URL> loaded = new HashSet<>();
@ -204,7 +204,7 @@ public class ScriptFileWatcher extends AbstractWatchService {
synchronized (urlsByScriptExtension) { synchronized (urlsByScriptExtension) {
Set<URL> set = urlsByScriptExtension.get(scriptType); Set<URL> set = urlsByScriptExtension.get(scriptType);
if (set == null) { if (set == null) {
set = new HashSet<URL>(); set = new HashSet<>();
urlsByScriptExtension.put(scriptType, set); urlsByScriptExtension.put(scriptType, set);
} }
set.add(url); set.add(url);
@ -267,7 +267,7 @@ public class ScriptFileWatcher extends AbstractWatchService {
}); });
synchronized (urlsByScriptExtension) { synchronized (urlsByScriptExtension) {
HashSet<String> newlySupported = new HashSet<>(); Set<String> newlySupported = new HashSet<>();
for (String key : urlsByScriptExtension.keySet()) { for (String key : urlsByScriptExtension.keySet()) {
if (manager.isSupported(key)) { if (manager.isSupported(key)) {
newlySupported.add(key); newlySupported.add(key);

View File

@ -14,6 +14,7 @@ package org.openhab.core.automation.module.script.rulesupport.shared;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.eclipse.smarthome.core.common.registry.RegistryChangeListener; import org.eclipse.smarthome.core.common.registry.RegistryChangeListener;
@ -30,7 +31,7 @@ import org.openhab.core.automation.RuleRegistry;
public class RuleSupportRuleRegistryDelegate implements RuleRegistry { public class RuleSupportRuleRegistryDelegate implements RuleRegistry {
private final RuleRegistry ruleRegistry; private final RuleRegistry ruleRegistry;
private final HashSet<String> rules = new HashSet<>(); private final Set<String> rules = new HashSet<>();
private final ScriptedRuleProvider ruleProvider; private final ScriptedRuleProvider ruleProvider;

View File

@ -14,6 +14,8 @@ package org.openhab.core.automation.module.script.rulesupport.shared;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.smarthome.config.core.Configuration; import org.eclipse.smarthome.config.core.Configuration;
import org.openhab.core.automation.Action; import org.openhab.core.automation.Action;
@ -48,9 +50,9 @@ public class ScriptedAutomationManager {
private final RuleSupportRuleRegistryDelegate ruleRegistryDelegate; private final RuleSupportRuleRegistryDelegate ruleRegistryDelegate;
private final HashSet<String> modules = new HashSet<>(); private final Set<String> modules = new HashSet<>();
private final HashSet<String> moduleHandlers = new HashSet<>(); private final Set<String> moduleHandlers = new HashSet<>();
private final HashSet<String> privateHandlers = new HashSet<>(); private final Set<String> privateHandlers = new HashSet<>();
private final ScriptedCustomModuleHandlerFactory scriptedCustomModuleHandlerFactory; private final ScriptedCustomModuleHandlerFactory scriptedCustomModuleHandlerFactory;
private final ScriptedCustomModuleTypeProvider scriptedCustomModuleTypeProvider; private final ScriptedCustomModuleTypeProvider scriptedCustomModuleTypeProvider;
@ -88,17 +90,17 @@ public class ScriptedAutomationManager {
public void removeAll() { public void removeAll() {
logger.info("removeAll added handlers"); logger.info("removeAll added handlers");
HashSet<String> types = new HashSet<>(modules); Set<String> types = new HashSet<>(modules);
for (String moduleType : types) { for (String moduleType : types) {
removeModuleType(moduleType); removeModuleType(moduleType);
} }
HashSet<String> moduleHandlers = new HashSet<>(this.moduleHandlers); Set<String> moduleHandlers = new HashSet<>(this.moduleHandlers);
for (String uid : moduleHandlers) { for (String uid : moduleHandlers) {
removeHandler(uid); removeHandler(uid);
} }
HashSet<String> privateHandlers = new HashSet<>(this.privateHandlers); Set<String> privateHandlers = new HashSet<>(this.privateHandlers);
for (String privId : privateHandlers) { for (String privId : privateHandlers) {
removePrivateHandler(privId); removePrivateHandler(privId);
} }
@ -123,7 +125,7 @@ public class ScriptedAutomationManager {
int moduleIndex = 1; int moduleIndex = 1;
try { try {
ArrayList<Condition> conditions = new ArrayList<>(); List<Condition> conditions = new ArrayList<>();
for (Condition cond : element.getConditions()) { for (Condition cond : element.getConditions()) {
Condition toAdd = cond; Condition toAdd = cond;
if (cond.getId().isEmpty()) { if (cond.getId().isEmpty()) {
@ -141,7 +143,7 @@ public class ScriptedAutomationManager {
} }
try { try {
ArrayList<Trigger> triggers = new ArrayList<>(); List<Trigger> triggers = new ArrayList<>();
for (Trigger trigger : element.getTriggers()) { for (Trigger trigger : element.getTriggers()) {
Trigger toAdd = trigger; Trigger toAdd = trigger;
if (trigger.getId().isEmpty()) { if (trigger.getId().isEmpty()) {
@ -157,7 +159,7 @@ public class ScriptedAutomationManager {
// triggers are optional // triggers are optional
} }
ArrayList<Action> actions = new ArrayList<>(); List<Action> actions = new ArrayList<>();
actions.addAll(element.getActions()); actions.addAll(element.getActions());
if (element instanceof SimpleRuleActionHandler) { if (element instanceof SimpleRuleActionHandler) {

View File

@ -15,6 +15,7 @@ package org.openhab.core.automation.module.script.rulesupport.shared;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import org.eclipse.smarthome.core.common.registry.ProviderChangeListener; import org.eclipse.smarthome.core.common.registry.ProviderChangeListener;
import org.openhab.core.automation.Rule; 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 }) @Component(immediate = true, service = { ScriptedRuleProvider.class, RuleProvider.class })
public class ScriptedRuleProvider implements RuleProvider { public class ScriptedRuleProvider implements RuleProvider {
private final Collection<ProviderChangeListener<Rule>> listeners = new ArrayList<ProviderChangeListener<Rule>>(); private final Collection<ProviderChangeListener<Rule>> listeners = new ArrayList<>();
HashMap<String, Rule> rules = new HashMap<>(); private final Map<String, Rule> rules = new HashMap<>();
@Override @Override
public void addProviderChangeListener(ProviderChangeListener<Rule> listener) { public void addProviderChangeListener(ProviderChangeListener<Rule> listener) {

View File

@ -208,13 +208,11 @@ public abstract class SimpleRule implements Rule, SimpleRuleActionHandler {
@Override @Override
public List<Module> getModules() { public List<Module> getModules() {
final List<Module> result; List<Module> modules = new ArrayList<>();
List<Module> modules = new ArrayList<Module>();
modules.addAll(triggers); modules.addAll(triggers);
modules.addAll(conditions); modules.addAll(conditions);
modules.addAll(actions); modules.addAll(actions);
result = Collections.unmodifiableList(modules); return Collections.unmodifiableList(modules);
return result;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@ -15,6 +15,7 @@ package org.openhab.core.automation.module.script.internal;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.script.Invocable; import javax.script.Invocable;
import javax.script.ScriptEngine; import javax.script.ScriptEngine;
@ -43,9 +44,9 @@ import org.slf4j.LoggerFactory;
public class ScriptEngineManagerImpl implements ScriptEngineManager { public class ScriptEngineManagerImpl implements ScriptEngineManager {
private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Logger logger = LoggerFactory.getLogger(this.getClass());
private HashMap<String, @Nullable ScriptEngineContainer> loadedScriptEngineInstances = new HashMap<>(); private Map<String, @Nullable ScriptEngineContainer> loadedScriptEngineInstances = new HashMap<>();
private HashMap<String, @Nullable ScriptEngineFactory> customSupport = new HashMap<>(); private Map<String, @Nullable ScriptEngineFactory> customSupport = new HashMap<>();
private HashMap<String, @Nullable ScriptEngineFactory> genericSupport = new HashMap<>(); private Map<String, @Nullable ScriptEngineFactory> genericSupport = new HashMap<>();
private @NonNullByDefault({}) ScriptExtensionManager scriptExtensionManager; private @NonNullByDefault({}) ScriptExtensionManager scriptExtensionManager;
@Reference @Reference
@ -113,7 +114,7 @@ public class ScriptEngineManagerImpl implements ScriptEngineManager {
try { try {
ScriptEngine engine = engineFactory.createScriptEngine(scriptType); ScriptEngine engine = engineFactory.createScriptEngine(scriptType);
if (engine != null) { if (engine != null) {
HashMap<String, Object> scriptExManager = new HashMap<>(); Map<String, Object> scriptExManager = new HashMap<>();
result = new ScriptEngineContainer(engine, engineFactory, engineIdentifier); result = new ScriptEngineContainer(engine, engineFactory, engineIdentifier);
ScriptExtensionManagerWrapper wrapper = new ScriptExtensionManagerWrapper(scriptExtensionManager, ScriptExtensionManagerWrapper wrapper = new ScriptExtensionManagerWrapper(scriptExtensionManager,
result); result);

View File

@ -34,7 +34,7 @@ import org.osgi.service.component.annotations.ReferencePolicy;
*/ */
@Component(service = ScriptExtensionManager.class) @Component(service = ScriptExtensionManager.class)
public class ScriptExtensionManager { public class ScriptExtensionManager {
private Set<ScriptExtensionProvider> scriptExtensionProviders = new CopyOnWriteArraySet<ScriptExtensionProvider>(); private Set<ScriptExtensionProvider> scriptExtensionProviders = new CopyOnWriteArraySet<>();
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
public void addScriptExtensionProvider(ScriptExtensionProvider provider) { public void addScriptExtensionProvider(ScriptExtensionProvider provider) {
@ -54,7 +54,7 @@ public class ScriptExtensionManager {
} }
public List<String> getTypes() { public List<String> getTypes() {
ArrayList<String> types = new ArrayList<>(); List<String> types = new ArrayList<>();
for (ScriptExtensionProvider provider : scriptExtensionProviders) { for (ScriptExtensionProvider provider : scriptExtensionProviders) {
types.addAll(provider.getTypes()); types.addAll(provider.getTypes());
@ -64,7 +64,7 @@ public class ScriptExtensionManager {
} }
public List<String> getPresets() { public List<String> getPresets() {
ArrayList<String> presets = new ArrayList<>(); List<String> presets = new ArrayList<>();
for (ScriptExtensionProvider provider : scriptExtensionProviders) { for (ScriptExtensionProvider provider : scriptExtensionProviders) {
presets.addAll(provider.getPresets()); presets.addAll(provider.getPresets());
@ -84,7 +84,7 @@ public class ScriptExtensionManager {
} }
public List<String> getDefaultPresets() { public List<String> getDefaultPresets() {
ArrayList<String> defaultPresets = new ArrayList<>(); List<String> defaultPresets = new ArrayList<>();
for (ScriptExtensionProvider provider : scriptExtensionProviders) { for (ScriptExtensionProvider provider : scriptExtensionProviders) {
defaultPresets.addAll(provider.getDefaultPresets()); defaultPresets.addAll(provider.getDefaultPresets());

View File

@ -113,7 +113,7 @@ public class ItemRegistryDelegate implements Map<String, State> {
@Override @Override
public Set<java.util.Map.Entry<String, State>> entrySet() { public Set<java.util.Map.Entry<String, State>> entrySet() {
Set<Map.Entry<String, State>> entries = new HashSet<Map.Entry<String, State>>(); Set<Map.Entry<String, State>> entries = new HashSet<>();
for (Item item : itemRegistry.getAll()) { for (Item item : itemRegistry.getAll()) {
entries.add(new AbstractMap.SimpleEntry<>(item.getName(), item.getState())); entries.add(new AbstractMap.SimpleEntry<>(item.getName(), item.getState()));
} }

View File

@ -54,7 +54,7 @@ public class ScriptActionHandler extends AbstractScriptModuleHandler<Action> imp
@Override @Override
public @Nullable Map<String, Object> execute(final Map<String, Object> context) { public @Nullable Map<String, Object> execute(final Map<String, Object> context) {
HashMap<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
getScriptEngine().ifPresent(scriptEngine -> { getScriptEngine().ifPresent(scriptEngine -> {
setExecutionContext(scriptEngine, context); setExecutionContext(scriptEngine, context);

View File

@ -71,7 +71,7 @@ public class ScriptModuleTypeProvider implements ModuleTypeProvider {
if (parameterOptions.isEmpty()) { if (parameterOptions.isEmpty()) {
return null; return null;
} else { } else {
List<Output> outputs = new ArrayList<Output>(); List<Output> outputs = new ArrayList<>();
Output result = new Output("result", "java.lang.Object", "result", "the script result", null, null, null); Output result = new Output("result", "java.lang.Object", "result", "the script result", null, null, null);
outputs.add(result); outputs.add(result);

View File

@ -99,7 +99,7 @@ public class ModuleTypeResource implements RESTResource {
@QueryParam("type") @ApiParam(value = "filtering by action, condition or trigger", required = false) String type) { @QueryParam("type") @ApiParam(value = "filtering by action, condition or trigger", required = false) String type) {
final Locale locale = localeService.getLocale(language); final Locale locale = localeService.getLocale(language);
final String[] tags = tagList != null ? tagList.split(",") : null; final String[] tags = tagList != null ? tagList.split(",") : null;
final List<ModuleTypeDTO> modules = new ArrayList<ModuleTypeDTO>(); final List<ModuleTypeDTO> modules = new ArrayList<>();
if (type == null || type.equals("trigger")) { if (type == null || type.equals("trigger")) {
modules.addAll(TriggerTypeDTOMapper.map(moduleTypeRegistry.getTriggers(locale, tags))); modules.addAll(TriggerTypeDTOMapper.map(moduleTypeRegistry.getTriggers(locale, tags)));

View File

@ -18,7 +18,6 @@ import java.util.List;
import org.eclipse.smarthome.config.core.Configuration; import org.eclipse.smarthome.config.core.Configuration;
import org.openhab.core.automation.Action; import org.openhab.core.automation.Action;
import org.openhab.core.automation.dto.ActionDTO;
import org.openhab.core.automation.util.ModuleBuilder; import org.openhab.core.automation.util.ModuleBuilder;
/** /**
@ -46,7 +45,7 @@ public class ActionDTOMapper extends ModuleDTOMapper {
if (actions == null) { if (actions == null) {
return null; return null;
} }
final List<ActionDTO> dtos = new ArrayList<ActionDTO>(actions.size()); final List<ActionDTO> dtos = new ArrayList<>(actions.size());
for (final Action action : actions) { for (final Action action : actions) {
dtos.add(map(action)); dtos.add(map(action));
} }
@ -57,7 +56,7 @@ public class ActionDTOMapper extends ModuleDTOMapper {
if (dtos == null) { if (dtos == null) {
return null; return null;
} }
final List<Action> actions = new ArrayList<Action>(dtos.size()); final List<Action> actions = new ArrayList<>(dtos.size());
for (final ActionDTO dto : dtos) { for (final ActionDTO dto : dtos) {
actions.add(mapDto(dto)); actions.add(mapDto(dto));
} }

View File

@ -17,8 +17,6 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import org.eclipse.smarthome.config.core.dto.ConfigDescriptionDTOMapper; 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.ActionType;
import org.openhab.core.automation.type.CompositeActionType; import org.openhab.core.automation.type.CompositeActionType;
@ -57,7 +55,7 @@ public class ActionTypeDTOMapper extends ModuleTypeDTOMapper {
if (types == null) { if (types == null) {
return null; return null;
} }
final List<ActionTypeDTO> dtos = new ArrayList<ActionTypeDTO>(types.size()); final List<ActionTypeDTO> dtos = new ArrayList<>(types.size());
for (final ActionType type : types) { for (final ActionType type : types) {
if (type instanceof CompositeActionType) { if (type instanceof CompositeActionType) {
dtos.add(map((CompositeActionType) type)); dtos.add(map((CompositeActionType) type));

View File

@ -17,7 +17,6 @@ import java.util.List;
import org.eclipse.smarthome.config.core.Configuration; import org.eclipse.smarthome.config.core.Configuration;
import org.openhab.core.automation.Condition; import org.openhab.core.automation.Condition;
import org.openhab.core.automation.dto.ConditionDTO;
import org.openhab.core.automation.util.ModuleBuilder; import org.openhab.core.automation.util.ModuleBuilder;
/** /**
@ -45,7 +44,7 @@ public class ConditionDTOMapper extends ModuleDTOMapper {
if (conditions == null) { if (conditions == null) {
return null; return null;
} }
final List<ConditionDTO> dtos = new ArrayList<ConditionDTO>(conditions.size()); final List<ConditionDTO> dtos = new ArrayList<>(conditions.size());
for (final Condition action : conditions) { for (final Condition action : conditions) {
dtos.add(map(action)); dtos.add(map(action));
} }
@ -56,7 +55,7 @@ public class ConditionDTOMapper extends ModuleDTOMapper {
if (dtos == null) { if (dtos == null) {
return null; return null;
} }
final List<Condition> conditions = new ArrayList<Condition>(dtos.size()); final List<Condition> conditions = new ArrayList<>(dtos.size());
for (final ConditionDTO dto : dtos) { for (final ConditionDTO dto : dtos) {
conditions.add(mapDto(dto)); conditions.add(mapDto(dto));
} }

View File

@ -17,8 +17,6 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import org.eclipse.smarthome.config.core.dto.ConfigDescriptionDTOMapper; 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.CompositeConditionType;
import org.openhab.core.automation.type.ConditionType; import org.openhab.core.automation.type.ConditionType;
@ -58,7 +56,7 @@ public class ConditionTypeDTOMapper extends ModuleTypeDTOMapper {
if (types == null) { if (types == null) {
return null; return null;
} }
final List<ConditionTypeDTO> dtos = new ArrayList<ConditionTypeDTO>(types.size()); final List<ConditionTypeDTO> dtos = new ArrayList<>(types.size());
for (final ConditionType type : types) { for (final ConditionType type : types) {
if (type instanceof CompositeConditionType) { if (type instanceof CompositeConditionType) {
dtos.add(map((CompositeConditionType) type)); dtos.add(map((CompositeConditionType) type));

View File

@ -18,7 +18,6 @@ import java.util.List;
import org.eclipse.smarthome.config.core.Configuration; import org.eclipse.smarthome.config.core.Configuration;
import org.openhab.core.automation.Trigger; import org.openhab.core.automation.Trigger;
import org.openhab.core.automation.dto.TriggerDTO;
import org.openhab.core.automation.util.ModuleBuilder; import org.openhab.core.automation.util.ModuleBuilder;
/** /**
@ -45,7 +44,7 @@ public class TriggerDTOMapper extends ModuleDTOMapper {
if (triggers == null) { if (triggers == null) {
return null; return null;
} }
final List<TriggerDTO> dtos = new ArrayList<TriggerDTO>(triggers.size()); final List<TriggerDTO> dtos = new ArrayList<>(triggers.size());
for (final Trigger trigger : triggers) { for (final Trigger trigger : triggers) {
dtos.add(map(trigger)); dtos.add(map(trigger));
} }
@ -56,7 +55,7 @@ public class TriggerDTOMapper extends ModuleDTOMapper {
if (dtos == null) { if (dtos == null) {
return null; return null;
} }
final List<Trigger> triggers = new ArrayList<Trigger>(dtos.size()); final List<Trigger> triggers = new ArrayList<>(dtos.size());
for (final TriggerDTO dto : dtos) { for (final TriggerDTO dto : dtos) {
triggers.add(mapDto(dto)); triggers.add(mapDto(dto));
} }

View File

@ -17,8 +17,6 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import org.eclipse.smarthome.config.core.dto.ConfigDescriptionDTOMapper; 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.CompositeTriggerType;
import org.openhab.core.automation.type.TriggerType; import org.openhab.core.automation.type.TriggerType;
@ -57,7 +55,7 @@ public class TriggerTypeDTOMapper extends ModuleTypeDTOMapper {
if (types == null) { if (types == null) {
return null; return null;
} }
final List<TriggerTypeDTO> dtos = new ArrayList<TriggerTypeDTO>(types.size()); final List<TriggerTypeDTO> dtos = new ArrayList<>(types.size());
for (final TriggerType type : types) { for (final TriggerType type : types) {
if (type instanceof CompositeTriggerType) { if (type instanceof CompositeTriggerType) {
dtos.add(map((CompositeTriggerType) type)); dtos.add(map((CompositeTriggerType) type));

View File

@ -131,13 +131,13 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
* There is only one {@link TriggerHandlerCallback} instance per {@link Rule}. The relation is * There is only one {@link TriggerHandlerCallback} instance per {@link Rule}. The relation is
* {@link Rule}'s UID to {@link TriggerHandlerCallback} instance. * {@link Rule}'s UID to {@link TriggerHandlerCallback} instance.
*/ */
private final @NonNullByDefault({}) Map<String, TriggerHandlerCallbackImpl> thCallbacks = new HashMap<String, TriggerHandlerCallbackImpl>(); private final @NonNullByDefault({}) Map<String, TriggerHandlerCallbackImpl> thCallbacks = new HashMap<>();
/** /**
* {@link Map} holding all {@link ModuleType} UIDs that are available in some rule's module definition. The relation * {@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. * is {@link ModuleType}'s UID to {@link Set} of {@link Rule} UIDs.
*/ */
private final @NonNullByDefault({}) Map<String, Set<String>> mapModuleTypeToRules = new HashMap<String, Set<String>>(); private final @NonNullByDefault({}) Map<String, Set<String>> mapModuleTypeToRules = new HashMap<>();
/** /**
* {@link Map} holding all available {@link ModuleHandlerFactory}s linked with {@link ModuleType}s that they * {@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<Modul
@Activate @Activate
public RuleEngineImpl(final Config config, final @Reference ModuleTypeRegistry moduleTypeRegistry, public RuleEngineImpl(final Config config, final @Reference ModuleTypeRegistry moduleTypeRegistry,
final @Reference RuleRegistry ruleRegistry, final @Reference StorageService storageService) { final @Reference RuleRegistry ruleRegistry, final @Reference StorageService storageService) {
this.contextMap = new HashMap<String, Map<String, Object>>(); this.contextMap = new HashMap<>();
this.moduleHandlerFactories = new HashMap<String, ModuleHandlerFactory>(20); this.moduleHandlerFactories = new HashMap<>(20);
this.disabledRulesStorage = storageService.<Boolean> getStorage(DISABLED_RULE_STORAGE, this.disabledRulesStorage = storageService.<Boolean> getStorage(DISABLED_RULE_STORAGE,
this.getClass().getClassLoader()); this.getClass().getClassLoader());
@ -334,7 +334,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
synchronized (this) { synchronized (this) {
Set<String> rulesPerModule = mapModuleTypeToRules.get(moduleTypeName); Set<String> rulesPerModule = mapModuleTypeToRules.get(moduleTypeName);
if (rulesPerModule != null) { if (rulesPerModule != null) {
rules = new HashSet<String>(); rules = new HashSet<>();
rules.addAll(rulesPerModule); rules.addAll(rulesPerModule);
} }
} }
@ -363,7 +363,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
synchronized (this) { synchronized (this) {
Set<String> rulesPerModule = mapModuleTypeToRules.get(moduleTypeName); Set<String> rulesPerModule = mapModuleTypeToRules.get(moduleTypeName);
if (rulesPerModule != null) { if (rulesPerModule != null) {
rules = new HashSet<String>(); rules = new HashSet<>();
rules.addAll(rulesPerModule); rules.addAll(rulesPerModule);
} }
} }
@ -400,7 +400,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
moduleHandlerFactories.put(moduleTypeName, moduleHandlerFactory); moduleHandlerFactories.put(moduleTypeName, moduleHandlerFactory);
Set<String> rulesPerModule = mapModuleTypeToRules.get(moduleTypeName); Set<String> rulesPerModule = mapModuleTypeToRules.get(moduleTypeName);
if (rulesPerModule != null) { if (rulesPerModule != null) {
rules = new HashSet<String>(); rules = new HashSet<>();
rules.addAll(rulesPerModule); rules.addAll(rulesPerModule);
} }
} }
@ -408,8 +408,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
for (String rUID : rules) { for (String rUID : rules) {
RuleStatus ruleStatus = getRuleStatus(rUID); RuleStatus ruleStatus = getRuleStatus(rUID);
if (ruleStatus == RuleStatus.UNINITIALIZED) { if (ruleStatus == RuleStatus.UNINITIALIZED) {
notInitializedRules = notInitializedRules != null ? notInitializedRules notInitializedRules = notInitializedRules != null ? notInitializedRules : new HashSet<>(20);
: new HashSet<String>(20);
notInitializedRules.add(rUID); notInitializedRules.add(rUID);
} }
} }
@ -743,7 +742,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
public synchronized void updateMapModuleTypeToRule(String rUID, String moduleTypeId) { public synchronized void updateMapModuleTypeToRule(String rUID, String moduleTypeId) {
Set<String> rules = mapModuleTypeToRules.get(moduleTypeId); Set<String> rules = mapModuleTypeToRules.get(moduleTypeId);
if (rules == null) { if (rules == null) {
rules = new HashSet<String>(11); rules = new HashSet<>(11);
} }
rules.add(rUID); rules.add(rUID);
mapModuleTypeToRules.put(moduleTypeId, rules); mapModuleTypeToRules.put(moduleTypeId, rules);
@ -933,11 +932,10 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
switch (ruleStatus) { switch (ruleStatus) {
case RUNNING: case RUNNING:
case IDLE: case IDLE:
mapMissingHandlers = mapMissingHandlers != null ? mapMissingHandlers mapMissingHandlers = mapMissingHandlers != null ? mapMissingHandlers : new HashMap<>(20);
: new HashMap<String, List<String>>(20);
List<String> list = mapMissingHandlers.get(rUID); List<String> list = mapMissingHandlers.get(rUID);
if (list == null) { if (list == null) {
list = new ArrayList<String>(5); list = new ArrayList<>(5);
} }
list.add(moduleTypeName); list.add(moduleTypeName);
mapMissingHandlers.put(rUID, list); mapMissingHandlers.put(rUID, list);
@ -1101,7 +1099,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
@NonNullByDefault({}) @NonNullByDefault({})
Map<String, Object> context = contextMap.get(ruleUID); Map<String, Object> context = contextMap.get(ruleUID);
if (context == null) { if (context == null) {
context = new HashMap<String, Object>(); context = new HashMap<>();
contextMap.put(ruleUID, context); contextMap.put(ruleUID, context);
} }
if (connections != null) { if (connections != null) {
@ -1264,7 +1262,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
* @param rule updated rule * @param rule updated rule
*/ */
private void autoMapConnections(WrappedRule rule) { private void autoMapConnections(WrappedRule rule) {
Map<Set<String>, OutputRef> triggerOutputTags = new HashMap<Set<String>, OutputRef>(11); Map<Set<String>, OutputRef> triggerOutputTags = new HashMap<>(11);
for (WrappedTrigger mt : rule.getTriggers()) { for (WrappedTrigger mt : rule.getTriggers()) {
final Trigger t = mt.unwrap(); final Trigger t = mt.unwrap();
TriggerType tt = (TriggerType) mtRegistry.get(t.getTypeUID()); TriggerType tt = (TriggerType) mtRegistry.get(t.getTypeUID());
@ -1272,7 +1270,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
initTagsMap(t.getId(), tt.getOutputs(), triggerOutputTags); initTagsMap(t.getId(), tt.getOutputs(), triggerOutputTags);
} }
} }
Map<Set<String>, OutputRef> actionOutputTags = new HashMap<Set<String>, OutputRef>(11); Map<Set<String>, OutputRef> actionOutputTags = new HashMap<>(11);
for (WrappedAction ma : rule.getActions()) { for (WrappedAction ma : rule.getActions()) {
final Action a = ma.unwrap(); final Action a = ma.unwrap();
ActionType at = (ActionType) mtRegistry.get(a.getTypeUID()); ActionType at = (ActionType) mtRegistry.get(a.getTypeUID());

View File

@ -258,13 +258,11 @@ public class RuleImpl implements Rule {
@Override @Override
public List<Module> getModules() { public List<Module> getModules() {
final List<Module> result; List<Module> modules = new ArrayList<>();
List<Module> modules = new ArrayList<Module>();
modules.addAll(triggers); modules.addAll(triggers);
modules.addAll(conditions); modules.addAll(conditions);
modules.addAll(actions); modules.addAll(actions);
result = Collections.unmodifiableList(modules); return Collections.unmodifiableList(modules);
return result;
} }
@Override @Override

View File

@ -113,7 +113,7 @@ public class RuleRegistryImpl extends AbstractRegistry<Rule, String, RuleProvide
/** /**
* {@link Map} of template UIDs to rules where these templates participated. * {@link Map} of template UIDs to rules where these templates participated.
*/ */
private final Map<String, Set<String>> mapTemplateToRules = new HashMap<String, Set<String>>(); private final Map<String, Set<String>> mapTemplateToRules = new HashMap<>();
/** /**
* Constructor that is responsible to invoke the super constructor with appropriate providerClazz * Constructor that is responsible to invoke the super constructor with appropriate providerClazz
@ -292,7 +292,7 @@ public class RuleRegistryImpl extends AbstractRegistry<Rule, String, RuleProvide
@Override @Override
public Collection<Rule> getByTag(String tag) { public Collection<Rule> getByTag(String tag) {
Collection<Rule> result = new LinkedList<Rule>(); Collection<Rule> result = new LinkedList<>();
if (tag == null) { if (tag == null) {
forEach(result::add); forEach(result::add);
} else { } else {
@ -307,8 +307,8 @@ public class RuleRegistryImpl extends AbstractRegistry<Rule, String, RuleProvide
@Override @Override
public Collection<Rule> getByTags(String... tags) { public Collection<Rule> getByTags(String... tags) {
Set<String> tagSet = tags != null ? new HashSet<String>(Arrays.asList(tags)) : null; Set<String> tagSet = tags != null ? new HashSet<>(Arrays.asList(tags)) : null;
Collection<Rule> result = new LinkedList<Rule>(); Collection<Rule> result = new LinkedList<>();
if (tagSet == null || tagSet.isEmpty()) { if (tagSet == null || tagSet.isEmpty()) {
forEach(result::add); forEach(result::add);
} else { } else {
@ -364,7 +364,7 @@ public class RuleRegistryImpl extends AbstractRegistry<Rule, String, RuleProvide
synchronized (this) { synchronized (this) {
Set<String> ruleUIDs = mapTemplateToRules.get(templateUID); Set<String> ruleUIDs = mapTemplateToRules.get(templateUID);
if (ruleUIDs == null) { if (ruleUIDs == null) {
ruleUIDs = new HashSet<String>(); ruleUIDs = new HashSet<>();
mapTemplateToRules.put(templateUID, ruleUIDs); mapTemplateToRules.put(templateUID, ruleUIDs);
} }
if (resolved) { if (resolved) {
@ -615,7 +615,7 @@ public class RuleRegistryImpl extends AbstractRegistry<Rule, String, RuleProvide
@Override @Override
public void added(RuleTemplate element) { public void added(RuleTemplate element) {
String templateUID = element.getUID(); String templateUID = element.getUID();
Set<String> rules = new HashSet<String>(); Set<String> rules = new HashSet<>();
synchronized (this) { synchronized (this) {
Set<String> rulesForResolving = mapTemplateToRules.get(templateUID); Set<String> rulesForResolving = mapTemplateToRules.get(templateUID);
if (rulesForResolving != null) { if (rulesForResolving != null) {

View File

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

View File

@ -145,7 +145,7 @@ public class AutomationCommandList extends AutomationCommand {
*/ */
private String listRules() { private String listRules() {
Collection<Rule> collection = autoCommands.getRules(); Collection<Rule> collection = autoCommands.getRules();
Map<String, Rule> rules = new Hashtable<String, Rule>(); Map<String, Rule> rules = new Hashtable<>();
Map<String, String> listRules = null; Map<String, String> listRules = null;
if (collection != null && !collection.isEmpty()) { if (collection != null && !collection.isEmpty()) {
addCollection(collection, rules); addCollection(collection, rules);
@ -187,7 +187,7 @@ public class AutomationCommandList extends AutomationCommand {
*/ */
private String listTemplates() { private String listTemplates() {
Collection<RuleTemplate> collection = autoCommands.getTemplates(locale); Collection<RuleTemplate> collection = autoCommands.getTemplates(locale);
Map<String, Template> templates = new Hashtable<String, Template>(); Map<String, Template> templates = new Hashtable<>();
Map<String, String> listTemplates = null; Map<String, String> listTemplates = null;
if (collection != null && !collection.isEmpty()) { if (collection != null && !collection.isEmpty()) {
addCollection(collection, templates); addCollection(collection, templates);
@ -229,7 +229,7 @@ public class AutomationCommandList extends AutomationCommand {
* command {@link AutomationCommands#LIST_MODULE_TYPES}. * command {@link AutomationCommands#LIST_MODULE_TYPES}.
*/ */
private String listModuleTypes() { private String listModuleTypes() {
Map<String, ModuleType> moduleTypes = new Hashtable<String, ModuleType>(); Map<String, ModuleType> moduleTypes = new Hashtable<>();
Collection<? extends ModuleType> collection = autoCommands.getTriggers(locale); Collection<? extends ModuleType> collection = autoCommands.getTriggers(locale);
addCollection(collection, moduleTypes); addCollection(collection, moduleTypes);
collection = autoCommands.getConditions(locale); collection = autoCommands.getConditions(locale);
@ -276,7 +276,7 @@ public class AutomationCommandList extends AutomationCommand {
* @return a collection of {@link Rule}s that match the filter. * @return a collection of {@link Rule}s that match the filter.
*/ */
private Collection<Rule> getRuleByFilter(Map<String, String> list) { private Collection<Rule> getRuleByFilter(Map<String, String> list) {
Collection<Rule> rules = new ArrayList<Rule>(); Collection<Rule> rules = new ArrayList<>();
if (!list.isEmpty()) { if (!list.isEmpty()) {
Rule r = null; Rule r = null;
String uid = list.get(id); 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. * @return a collection of {@link Template}s that match the filter.
*/ */
private Collection<RuleTemplate> getTemplateByFilter(Map<String, String> list) { private Collection<RuleTemplate> getTemplateByFilter(Map<String, String> list) {
Collection<RuleTemplate> templates = new ArrayList<RuleTemplate>(); Collection<RuleTemplate> templates = new ArrayList<>();
RuleTemplate t = null; RuleTemplate t = null;
String uid = list.get(id); String uid = list.get(id);
if (uid != null) { if (uid != null) {
@ -346,7 +346,7 @@ public class AutomationCommandList extends AutomationCommand {
* @return a collection of {@link ModuleType}s that match the filter. * @return a collection of {@link ModuleType}s that match the filter.
*/ */
private Collection<ModuleType> getModuleTypeByFilter(Map<String, String> list) { private Collection<ModuleType> getModuleTypeByFilter(Map<String, String> list) {
Collection<ModuleType> moduleTypes = new ArrayList<ModuleType>(); Collection<ModuleType> moduleTypes = new ArrayList<>();
if (!list.isEmpty()) { if (!list.isEmpty()) {
ModuleType mt = null; ModuleType mt = null;
String uid = list.get(id); String uid = list.get(id);

View File

@ -74,7 +74,7 @@ public class CommandlineModuleTypeProvider extends AbstractCommandProvider<Modul
*/ */
public CommandlineModuleTypeProvider(BundleContext context, ModuleTypeRegistry moduleTypeRegistry) { public CommandlineModuleTypeProvider(BundleContext context, ModuleTypeRegistry moduleTypeRegistry) {
super(context); super(context);
listeners = new LinkedList<ProviderChangeListener<ModuleType>>(); listeners = new LinkedList<>();
mtpReg = bc.registerService(ModuleTypeProvider.class.getName(), this, null); mtpReg = bc.registerService(ModuleTypeProvider.class.getName(), this, null);
this.moduleTypeRegistry = moduleTypeRegistry; this.moduleTypeRegistry = moduleTypeRegistry;
} }
@ -188,13 +188,13 @@ public class CommandlineModuleTypeProvider extends AbstractCommandProvider<Modul
Set<ModuleType> providedObjects = parser.parse(inputStreamReader); Set<ModuleType> providedObjects = parser.parse(inputStreamReader);
if (providedObjects != null && !providedObjects.isEmpty()) { if (providedObjects != null && !providedObjects.isEmpty()) {
String uid = null; String uid = null;
List<String> portfolio = new ArrayList<String>(); List<String> portfolio = new ArrayList<>();
synchronized (providerPortfolio) { synchronized (providerPortfolio) {
providerPortfolio.put(url, portfolio); providerPortfolio.put(url, portfolio);
} }
List<ParsingNestedException> importDataExceptions = new ArrayList<ParsingNestedException>(); List<ParsingNestedException> importDataExceptions = new ArrayList<>();
for (ModuleType providedObject : providedObjects) { for (ModuleType providedObject : providedObjects) {
List<ParsingNestedException> exceptions = new ArrayList<ParsingNestedException>(); List<ParsingNestedException> exceptions = new ArrayList<>();
uid = providedObject.getUID(); uid = providedObject.getUID();
checkExistence(uid, exceptions); checkExistence(uid, exceptions);
if (exceptions.isEmpty()) { if (exceptions.isEmpty()) {
@ -235,7 +235,7 @@ public class CommandlineModuleTypeProvider extends AbstractCommandProvider<Modul
@Override @Override
public Collection<ModuleType> getAll() { public Collection<ModuleType> getAll() {
return new LinkedList<ModuleType>(providedObjectsHolder.values()); return new LinkedList<>(providedObjectsHolder.values());
} }
@Override @Override

View File

@ -70,7 +70,7 @@ public class CommandlineTemplateProvider extends AbstractCommandProvider<RuleTem
*/ */
public CommandlineTemplateProvider(BundleContext context, TemplateRegistry<RuleTemplate> templateRegistry) { public CommandlineTemplateProvider(BundleContext context, TemplateRegistry<RuleTemplate> templateRegistry) {
super(context); super(context);
listeners = new LinkedList<ProviderChangeListener<RuleTemplate>>(); listeners = new LinkedList<>();
tpReg = bc.registerService(RuleTemplateProvider.class.getName(), this, null); tpReg = bc.registerService(RuleTemplateProvider.class.getName(), this, null);
this.templateRegistry = templateRegistry; this.templateRegistry = templateRegistry;
} }
@ -178,13 +178,13 @@ public class CommandlineTemplateProvider extends AbstractCommandProvider<RuleTem
throws ParsingException { throws ParsingException {
Set<RuleTemplate> providedObjects = parser.parse(inputStreamReader); Set<RuleTemplate> providedObjects = parser.parse(inputStreamReader);
if (providedObjects != null && !providedObjects.isEmpty()) { if (providedObjects != null && !providedObjects.isEmpty()) {
List<String> portfolio = new ArrayList<String>(); List<String> portfolio = new ArrayList<>();
synchronized (providerPortfolio) { synchronized (providerPortfolio) {
providerPortfolio.put(url, portfolio); providerPortfolio.put(url, portfolio);
} }
List<ParsingNestedException> importDataExceptions = new ArrayList<ParsingNestedException>(); List<ParsingNestedException> importDataExceptions = new ArrayList<>();
for (RuleTemplate ruleT : providedObjects) { for (RuleTemplate ruleT : providedObjects) {
List<ParsingNestedException> exceptions = new ArrayList<ParsingNestedException>(); List<ParsingNestedException> exceptions = new ArrayList<>();
String uid = ruleT.getUID(); String uid = ruleT.getUID();
checkExistence(uid, exceptions); checkExistence(uid, exceptions);
if (exceptions.isEmpty()) { if (exceptions.isEmpty()) {
@ -225,7 +225,7 @@ public class CommandlineTemplateProvider extends AbstractCommandProvider<RuleTem
@Override @Override
public Collection<RuleTemplate> getAll() { public Collection<RuleTemplate> getAll() {
return new LinkedList<RuleTemplate>(providedObjectsHolder.values()); return new LinkedList<>(providedObjectsHolder.values());
} }
@Override @Override

View File

@ -96,14 +96,14 @@ public class Printer {
*/ */
static String printRules(AutomationCommandsPluggable autoCommands, Map<String, String> ruleUIDs) { static String printRules(AutomationCommandsPluggable autoCommands, Map<String, String> ruleUIDs) {
int[] columnWidths = new int[] { COLUMN_ID, COLUMN_RULE_UID, COLUMN_RULE_NAME, COLUMN_RULE_STATUS }; int[] columnWidths = new int[] { COLUMN_ID, COLUMN_RULE_UID, COLUMN_RULE_NAME, COLUMN_RULE_STATUS };
List<String> columnValues = new ArrayList<String>(); List<String> columnValues = new ArrayList<>();
columnValues.add(ID); columnValues.add(ID);
columnValues.add(UID); columnValues.add(UID);
columnValues.add(NAME); columnValues.add(NAME);
columnValues.add(STATUS); columnValues.add(STATUS);
String titleRow = Utils.getRow(columnWidths, columnValues); String titleRow = Utils.getRow(columnWidths, columnValues);
List<String> rulesRows = new ArrayList<String>(); List<String> rulesRows = new ArrayList<>();
for (int i = 1; i <= ruleUIDs.size(); i++) { for (int i = 1; i <= ruleUIDs.size(); i++) {
String id = new Integer(i).toString(); String id = new Integer(i).toString();
String uid = ruleUIDs.get(id); String uid = ruleUIDs.get(id);
@ -125,12 +125,12 @@ public class Printer {
*/ */
static String printTemplates(Map<String, String> templateUIDs) { static String printTemplates(Map<String, String> templateUIDs) {
int[] columnWidths = new int[] { COLUMN_ID, COLUMN_UID }; int[] columnWidths = new int[] { COLUMN_ID, COLUMN_UID };
List<String> columnTitles = new ArrayList<String>(); List<String> columnTitles = new ArrayList<>();
columnTitles.add(ID); columnTitles.add(ID);
columnTitles.add(UID); columnTitles.add(UID);
String titleRow = Utils.getRow(columnWidths, columnTitles); String titleRow = Utils.getRow(columnWidths, columnTitles);
List<String> templates = new ArrayList<String>(); List<String> templates = new ArrayList<>();
collectListRecords(templateUIDs, templates, columnWidths); collectListRecords(templateUIDs, templates, columnWidths);
return Utils.getTableContent(TABLE_WIDTH, columnWidths, templates, titleRow); return Utils.getTableContent(TABLE_WIDTH, columnWidths, templates, titleRow);
} }
@ -143,12 +143,12 @@ public class Printer {
*/ */
static String printModuleTypes(Map<String, String> moduleTypeUIDs) { static String printModuleTypes(Map<String, String> moduleTypeUIDs) {
int[] columnWidths = new int[] { COLUMN_ID, COLUMN_UID }; int[] columnWidths = new int[] { COLUMN_ID, COLUMN_UID };
List<String> columnTitles = new ArrayList<String>(); List<String> columnTitles = new ArrayList<>();
columnTitles.add(ID); columnTitles.add(ID);
columnTitles.add(UID); columnTitles.add(UID);
String titleRow = Utils.getRow(columnWidths, columnTitles); String titleRow = Utils.getRow(columnWidths, columnTitles);
List<String> moduleTypes = new ArrayList<String>(); List<String> moduleTypes = new ArrayList<>();
collectListRecords(moduleTypeUIDs, moduleTypes, columnWidths); collectListRecords(moduleTypeUIDs, moduleTypes, columnWidths);
return Utils.getTableContent(TABLE_WIDTH, columnWidths, moduleTypes, titleRow); return Utils.getTableContent(TABLE_WIDTH, columnWidths, moduleTypes, titleRow);
} }
@ -161,11 +161,11 @@ public class Printer {
*/ */
static String printRule(Rule rule, RuleStatus status) { static String printRule(Rule rule, RuleStatus status) {
int[] columnWidths = new int[] { TABLE_WIDTH }; int[] columnWidths = new int[] { TABLE_WIDTH };
List<String> ruleProperty = new ArrayList<String>(); List<String> ruleProperty = new ArrayList<>();
ruleProperty.add(rule.getUID() + " [ " + status + " ]"); ruleProperty.add(rule.getUID() + " [ " + status + " ]");
String titleRow = Utils.getRow(columnWidths, ruleProperty); String titleRow = Utils.getRow(columnWidths, ruleProperty);
List<String> ruleContent = new ArrayList<String>(); List<String> ruleContent = new ArrayList<>();
columnWidths = new int[] { COLUMN_PROPERTY, COLUMN_PROPERTY_VALUE }; columnWidths = new int[] { COLUMN_PROPERTY, COLUMN_PROPERTY_VALUE };
ruleProperty.set(0, UID); ruleProperty.set(0, UID);
ruleProperty.add(rule.getUID()); ruleProperty.add(rule.getUID());
@ -203,11 +203,11 @@ public class Printer {
*/ */
static String printTemplate(Template template) { static String printTemplate(Template template) {
int[] columnWidths = new int[] { TABLE_WIDTH }; int[] columnWidths = new int[] { TABLE_WIDTH };
List<String> templateProperty = new ArrayList<String>(); List<String> templateProperty = new ArrayList<>();
templateProperty.add(template.getUID()); templateProperty.add(template.getUID());
String titleRow = Utils.getRow(columnWidths, templateProperty); String titleRow = Utils.getRow(columnWidths, templateProperty);
List<String> templateContent = new ArrayList<String>(); List<String> templateContent = new ArrayList<>();
columnWidths = new int[] { COLUMN_PROPERTY, COLUMN_PROPERTY_VALUE }; columnWidths = new int[] { COLUMN_PROPERTY, COLUMN_PROPERTY_VALUE };
templateProperty.set(0, UID); templateProperty.set(0, UID);
templateProperty.add(template.getUID()); templateProperty.add(template.getUID());
@ -247,11 +247,11 @@ public class Printer {
*/ */
static String printModuleType(ModuleType moduleType) { static String printModuleType(ModuleType moduleType) {
int[] columnWidths = new int[] { TABLE_WIDTH }; int[] columnWidths = new int[] { TABLE_WIDTH };
List<String> moduleTypeProperty = new ArrayList<String>(); List<String> moduleTypeProperty = new ArrayList<>();
moduleTypeProperty.add(moduleType.getUID()); moduleTypeProperty.add(moduleType.getUID());
String titleRow = Utils.getRow(columnWidths, moduleTypeProperty); String titleRow = Utils.getRow(columnWidths, moduleTypeProperty);
List<String> moduleTypeContent = new ArrayList<String>(); List<String> moduleTypeContent = new ArrayList<>();
columnWidths = new int[] { COLUMN_PROPERTY, COLUMN_PROPERTY_VALUE }; columnWidths = new int[] { COLUMN_PROPERTY, COLUMN_PROPERTY_VALUE };
moduleTypeProperty.set(0, UID); moduleTypeProperty.set(0, UID);
moduleTypeProperty.add(moduleType.getUID()); moduleTypeProperty.add(moduleType.getUID());
@ -309,7 +309,7 @@ public class Printer {
* @return a string representing the response of the command {@link AutomationCommands#ENABLE_RULE}. * @return a string representing the response of the command {@link AutomationCommands#ENABLE_RULE}.
*/ */
static String printRuleStatus(String ruleUID, RuleStatus status) { static String printRuleStatus(String ruleUID, RuleStatus status) {
List<String> title = new ArrayList<String>(); List<String> title = new ArrayList<>();
title.add(ruleUID + " [ " + status + " ]"); title.add(ruleUID + " [ " + status + " ]");
String titleRow = Utils.getRow(new int[] { TABLE_WIDTH }, title); String titleRow = Utils.getRow(new int[] { TABLE_WIDTH }, title);
List<String> res = Utils.getTableTitle(titleRow, TABLE_WIDTH); List<String> res = Utils.getTableTitle(titleRow, TABLE_WIDTH);
@ -332,10 +332,10 @@ public class Printer {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static List<String> collectRecords(int[] columnWidths, String prop, Collection<?> list) { private static List<String> collectRecords(int[] columnWidths, String prop, Collection<?> list) {
List<String> res = new ArrayList<String>(); List<String> res = new ArrayList<>();
boolean isFirst = true; boolean isFirst = true;
boolean isList = false; boolean isList = false;
List<String> values = new ArrayList<String>(); List<String> values = new ArrayList<>();
values.add(prop); values.add(prop);
values.add(""); values.add("");
if (list != null && !list.isEmpty()) { if (list != null && !list.isEmpty()) {
@ -395,9 +395,9 @@ public class Printer {
*/ */
private static List<String> getModuleRecords(Module module) { private static List<String> getModuleRecords(Module module) {
int[] columnWidths = new int[] { COLUMN_PROPERTY_VALUE }; int[] columnWidths = new int[] { COLUMN_PROPERTY_VALUE };
List<String> columnValues = new ArrayList<String>(); List<String> columnValues = new ArrayList<>();
columnValues.add(module.getId()); columnValues.add(module.getId());
List<String> moduleContent = new ArrayList<String>(); List<String> moduleContent = new ArrayList<>();
moduleContent.addAll(Utils.getTableTitle(Utils.getRow(columnWidths, columnValues), COLUMN_PROPERTY_VALUE)); moduleContent.addAll(Utils.getTableTitle(Utils.getRow(columnWidths, columnValues), COLUMN_PROPERTY_VALUE));
columnWidths = new int[] { COLUMN_CONFIG_PARAMETER, COLUMN_CONFIG_PARAMETER_VALUE }; columnWidths = new int[] { COLUMN_CONFIG_PARAMETER, COLUMN_CONFIG_PARAMETER_VALUE };
@ -430,8 +430,7 @@ public class Printer {
inputs = ((Action) module).getInputs(); inputs = ((Action) module).getInputs();
} }
if (inputs != null && !inputs.isEmpty()) { if (inputs != null && !inputs.isEmpty()) {
moduleContent.addAll( moduleContent.addAll(collectRecords(columnWidths, INPUTS, new ArrayList<>(inputs.entrySet())));
collectRecords(columnWidths, INPUTS, new ArrayList<Entry<String, String>>(inputs.entrySet())));
} }
return moduleContent; return moduleContent;
} }
@ -464,13 +463,13 @@ public class Printer {
*/ */
private static List<String> getConfigurationDescriptionRecords( private static List<String> getConfigurationDescriptionRecords(
List<ConfigDescriptionParameter> configDescriptions) { List<ConfigDescriptionParameter> configDescriptions) {
List<String> configParamContent = new ArrayList<String>(); List<String> configParamContent = new ArrayList<>();
if (configDescriptions != null && !configDescriptions.isEmpty()) { if (configDescriptions != null && !configDescriptions.isEmpty()) {
for (ConfigDescriptionParameter parameter : configDescriptions) { for (ConfigDescriptionParameter parameter : configDescriptions) {
int[] columnWidths = new int[] { COLUMN_CONFIG_PARAMETER, COLUMN_CONFIG_PARAMETER_PROP, int[] columnWidths = new int[] { COLUMN_CONFIG_PARAMETER, COLUMN_CONFIG_PARAMETER_PROP,
COLUMN_CONFIG_PARAMETER_PROP_VALUE }; COLUMN_CONFIG_PARAMETER_PROP_VALUE };
configParamContent.add(Utils.getColumn(COLUMN_PROPERTY_VALUE, parameter.getName() + " : ")); configParamContent.add(Utils.getColumn(COLUMN_PROPERTY_VALUE, parameter.getName() + " : "));
List<String> configParamProperty = new ArrayList<String>(); List<String> configParamProperty = new ArrayList<>();
configParamProperty.add(""); configParamProperty.add("");
configParamProperty.add(TYPE); configParamProperty.add(TYPE);
configParamProperty.add(parameter.getType().toString()); configParamProperty.add(parameter.getType().toString());
@ -566,7 +565,7 @@ public class Printer {
for (int i = 1; i <= list.size(); i++) { for (int i = 1; i <= list.size(); i++) {
String id = new Integer(i).toString(); String id = new Integer(i).toString();
String uid = list.get(id); String uid = list.get(id);
List<String> columnValues = new ArrayList<String>(); List<String> columnValues = new ArrayList<>();
columnValues.add(id); columnValues.add(id);
columnValues.add(uid); columnValues.add(uid);
rows.add(Utils.getRow(columnWidths, columnValues)); rows.add(Utils.getRow(columnWidths, columnValues));

View File

@ -40,7 +40,7 @@ public class Utils {
* @return an indexed UIDs of the automation objects. * @return an indexed UIDs of the automation objects.
*/ */
static Map<String, String> putInHastable(String[] strings) { static Map<String, String> putInHastable(String[] strings) {
Hashtable<String, String> sorted = new Hashtable<String, String>(); Hashtable<String, String> sorted = new Hashtable<>();
for (int i = 0; i < strings.length; i++) { for (int i = 0; i < strings.length; i++) {
sorted.put(new Integer(i + 1).toString(), strings[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. * @return filtered list with UIDs of the objects.
*/ */
static Map<String, String> filterList(Map<String, ?> listObjects, Map<String, String> listUIDs) { static Map<String, String> filterList(Map<String, ?> listObjects, Map<String, String> listUIDs) {
Hashtable<String, String> filtered = new Hashtable<String, String>(); Hashtable<String, String> filtered = new Hashtable<>();
for (final Entry<String, String> entry : listUIDs.entrySet()) { for (final Entry<String, String> entry : listUIDs.entrySet()) {
final String id = entry.getKey(); final String id = entry.getKey();
final String uid = entry.getValue(); final String uid = entry.getValue();
@ -133,7 +133,7 @@ public class Utils {
* @return a string representing the title of the table. * @return a string representing the title of the table.
*/ */
static List<String> getTableTitle(String titleRow, int width) { static List<String> getTableTitle(String titleRow, int width) {
List<String> res = new ArrayList<String>(); List<String> res = new ArrayList<>();
res.add(printChars(TABLE_DELIMITER, width)); res.add(printChars(TABLE_DELIMITER, width));
res.add(titleRow); res.add(titleRow);
res.add(printChars(TABLE_DELIMITER, width)); res.add(printChars(TABLE_DELIMITER, width));

View File

@ -77,7 +77,7 @@ public abstract class AbstractCompositeModuleHandler<M extends Module, MT extend
* @return context that will be passed to the child module * @return context that will be passed to the child module
*/ */
protected Map<String, Object> getCompositeContext(Map<String, ?> context) { protected Map<String, Object> getCompositeContext(Map<String, ?> context) {
Map<String, Object> result = new HashMap<String, Object>(context); Map<String, Object> result = new HashMap<>(context);
result.putAll(module.getConfiguration().getProperties()); result.putAll(module.getConfiguration().getProperties());
return result; return result;
} }

View File

@ -62,7 +62,7 @@ public class CompositeActionHandler extends AbstractCompositeModuleHandler<Actio
*/ */
@Override @Override
public Map<String, Object> execute(Map<String, Object> context) { public Map<String, Object> execute(Map<String, Object> context) {
final Map<String, Object> result = new HashMap<String, Object>(); final Map<String, Object> result = new HashMap<>();
final List<Action> children = getChildren(); final List<Action> children = getChildren();
final Map<String, Object> compositeContext = getCompositeContext(context); final Map<String, Object> compositeContext = getCompositeContext(context);
for (Action child : children) { for (Action child : children) {
@ -98,7 +98,7 @@ public class CompositeActionHandler extends AbstractCompositeModuleHandler<Actio
* @return map of links between child action outputs and parent output * @return map of links between child action outputs and parent output
*/ */
protected Map<String, Output> getCompositeOutputMap(List<Output> outputs) { protected Map<String, Output> getCompositeOutputMap(List<Output> outputs) {
Map<String, Output> result = new HashMap<String, Output>(11); Map<String, Output> result = new HashMap<>(11);
if (outputs != null) { if (outputs != null) {
for (Output output : outputs) { for (Output output : outputs) {
String refs = output.getReference(); String refs = output.getReference();

View File

@ -172,7 +172,7 @@ public class CompositeModuleHandlerFactory extends BaseModuleHandlerFactory impl
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private <T extends Module, MT extends ModuleHandler> LinkedHashMap<T, MT> getChildHandlers(String compositeModuleId, private <T extends Module, MT extends ModuleHandler> LinkedHashMap<T, MT> getChildHandlers(String compositeModuleId,
Configuration compositeConfig, List<T> childModules, String childModulePrefix) { Configuration compositeConfig, List<T> childModules, String childModulePrefix) {
LinkedHashMap<T, MT> mapModuleToHandler = new LinkedHashMap<T, MT>(); LinkedHashMap<T, MT> mapModuleToHandler = new LinkedHashMap<>();
for (T child : childModules) { for (T child : childModules) {
String ruleId = getRuleId(childModulePrefix); String ruleId = getRuleId(childModulePrefix);
ruleEngine.updateMapModuleTypeToRule(ruleId, child.getTypeUID()); ruleEngine.updateMapModuleTypeToRule(ruleId, child.getTypeUID());

View File

@ -70,7 +70,7 @@ public class CompositeTriggerHandler
public void triggered(Trigger trigger, Map<String, ?> context) { public void triggered(Trigger trigger, Map<String, ?> context) {
if (callback != null) { if (callback != null) {
List<Output> outputs = moduleType.getOutputs(); List<Output> outputs = moduleType.getOutputs();
Map<String, Object> result = new HashMap<String, Object>(11); Map<String, Object> result = new HashMap<>(11);
for (Output output : outputs) { for (Output output : outputs) {
String refs = output.getReference(); String refs = output.getReference();
if (refs != null) { if (refs != null) {

View File

@ -160,7 +160,7 @@ public class CompareConditionHandler extends BaseConditionModuleHandler {
return rightOperandString2; return rightOperandString2;
} }
if (toCompare instanceof State) { if (toCompare instanceof State) {
List<Class<? extends State>> stateTypeList = new ArrayList<Class<? extends State>>(); List<Class<? extends State>> stateTypeList = new ArrayList<>();
stateTypeList.add(((State) toCompare).getClass()); stateTypeList.add(((State) toCompare).getClass());
return TypeParser.parseState(stateTypeList, rightOperandString2); return TypeParser.parseState(stateTypeList, rightOperandString2);
} else if (toCompare instanceof Integer) { } else if (toCompare instanceof Integer) {

View File

@ -73,7 +73,7 @@ public class GenericEventTriggerHandler extends BaseTriggerModuleHandler impleme
this.types = Collections.emptySet(); this.types = Collections.emptySet();
} }
this.bundleContext = bundleContext; this.bundleContext = bundleContext;
Dictionary<String, Object> properties = new Hashtable<String, Object>(); Dictionary<String, Object> properties = new Hashtable<>();
properties.put("event.topics", topic); properties.put("event.topics", topic);
eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this, eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this,
properties); properties);

View File

@ -64,7 +64,7 @@ public class ItemCommandTriggerHandler extends BaseTriggerModuleHandler implemen
this.command = (String) module.getConfiguration().get(CFG_COMMAND); this.command = (String) module.getConfiguration().get(CFG_COMMAND);
this.types = Collections.singleton(ItemCommandEvent.TYPE); this.types = Collections.singleton(ItemCommandEvent.TYPE);
this.bundleContext = bundleContext; this.bundleContext = bundleContext;
Dictionary<String, Object> properties = new Hashtable<String, Object>(); Dictionary<String, Object> properties = new Hashtable<>();
this.topic = "smarthome/items/" + itemName + "/command"; this.topic = "smarthome/items/" + itemName + "/command";
properties.put("event.topics", topic); properties.put("event.topics", topic);
eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this, eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this,

View File

@ -70,13 +70,13 @@ public class ItemStateTriggerHandler extends BaseTriggerModuleHandler implements
if (UPDATE_MODULE_TYPE_ID.equals(module.getTypeUID())) { if (UPDATE_MODULE_TYPE_ID.equals(module.getTypeUID())) {
this.types = Collections.singleton(ItemStateEvent.TYPE); this.types = Collections.singleton(ItemStateEvent.TYPE);
} else { } else {
HashSet<String> set = new HashSet<>(); Set<String> set = new HashSet<>();
set.add(ItemStateChangedEvent.TYPE); set.add(ItemStateChangedEvent.TYPE);
set.add(GroupItemStateChangedEvent.TYPE); set.add(GroupItemStateChangedEvent.TYPE);
this.types = Collections.unmodifiableSet(set); this.types = Collections.unmodifiableSet(set);
} }
this.bundleContext = bundleContext; this.bundleContext = bundleContext;
Dictionary<String, Object> properties = new Hashtable<String, Object>(); Dictionary<String, Object> properties = new Hashtable<>();
properties.put("event.topics", "smarthome/items/" + itemName + "/*"); properties.put("event.topics", "smarthome/items/" + itemName + "/*");
eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this, eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this,
properties); properties);

View File

@ -83,11 +83,11 @@ public class ModuleTypeGSONParser extends AbstractGSONParser<ModuleType> {
} }
private Map<String, List<? extends ModuleType>> createMapByType(Set<ModuleType> dataObjects) { private Map<String, List<? extends ModuleType>> createMapByType(Set<ModuleType> dataObjects) {
Map<String, List<? extends ModuleType>> map = new HashMap<String, List<? extends ModuleType>>(); Map<String, List<? extends ModuleType>> map = new HashMap<>();
List<TriggerType> triggers = new ArrayList<TriggerType>(); List<TriggerType> triggers = new ArrayList<>();
List<ConditionType> conditions = new ArrayList<ConditionType>(); List<ConditionType> conditions = new ArrayList<>();
List<ActionType> actions = new ArrayList<ActionType>(); List<ActionType> actions = new ArrayList<>();
for (ModuleType moduleType : dataObjects) { for (ModuleType moduleType : dataObjects) {
if (moduleType instanceof TriggerType) { if (moduleType instanceof TriggerType) {
triggers.add((TriggerType) moduleType); triggers.add((TriggerType) moduleType);

View File

@ -71,11 +71,11 @@ public abstract class AbstractResourceBundleProvider<E> {
public AbstractResourceBundleProvider() { public AbstractResourceBundleProvider() {
logger = LoggerFactory.getLogger(this.getClass()); logger = LoggerFactory.getLogger(this.getClass());
providedObjectsHolder = new ConcurrentHashMap<String, E>(); providedObjectsHolder = new ConcurrentHashMap<>();
providerPortfolio = new ConcurrentHashMap<Vendor, List<String>>(); providerPortfolio = new ConcurrentHashMap<>();
queue = new AutomationResourceBundlesEventQueue<E>(this); queue = new AutomationResourceBundlesEventQueue<>(this);
parsers = new ConcurrentHashMap<String, Parser<E>>(); parsers = new ConcurrentHashMap<>();
waitingProviders = new ConcurrentHashMap<Bundle, List<URL>>(); waitingProviders = new ConcurrentHashMap<>();
} }
/** /**
@ -259,7 +259,7 @@ public abstract class AbstractResourceBundleProvider<E> {
} }
Vendor vendor = new Vendor(bundle.getSymbolicName(), bundle.getVersion().toString()); Vendor vendor = new Vendor(bundle.getSymbolicName(), bundle.getVersion().toString());
List<String> previousPortfolio = getPreviousPortfolio(vendor); List<String> previousPortfolio = getPreviousPortfolio(vendor);
List<String> newPortfolio = new LinkedList<String>(); List<String> newPortfolio = new LinkedList<>();
if (urlEnum != null) { if (urlEnum != null) {
while (urlEnum.hasMoreElements()) { while (urlEnum.hasMoreElements()) {
URL url = urlEnum.nextElement(); URL url = urlEnum.nextElement();
@ -290,7 +290,7 @@ public abstract class AbstractResourceBundleProvider<E> {
if (listeners != null) { if (listeners != null) {
List<ProviderChangeListener<E>> snapshot = null; List<ProviderChangeListener<E>> snapshot = null;
synchronized (listeners) { synchronized (listeners) {
snapshot = new LinkedList<ProviderChangeListener<E>>(listeners); snapshot = new LinkedList<>(listeners);
} }
for (ProviderChangeListener<E> listener : snapshot) { for (ProviderChangeListener<E> listener : snapshot) {
listener.removed((Provider<E>) this, removedObject); listener.removed((Provider<E>) this, removedObject);
@ -359,7 +359,7 @@ public abstract class AbstractResourceBundleProvider<E> {
if (listeners != null) { if (listeners != null) {
List<ProviderChangeListener<E>> snapshot = null; List<ProviderChangeListener<E>> snapshot = null;
synchronized (listeners) { synchronized (listeners) {
snapshot = new LinkedList<ProviderChangeListener<E>>(listeners); snapshot = new LinkedList<>(listeners);
} }
for (ProviderChangeListener<E> listener : snapshot) { for (ProviderChangeListener<E> listener : snapshot) {
listener.removed((Provider<E>) this, removedObject); listener.removed((Provider<E>) this, removedObject);
@ -397,7 +397,7 @@ public abstract class AbstractResourceBundleProvider<E> {
protected List<ConfigDescriptionParameter> getLocalizedConfigurationDescription(TranslationProvider i18nProvider, protected List<ConfigDescriptionParameter> getLocalizedConfigurationDescription(TranslationProvider i18nProvider,
List<ConfigDescriptionParameter> config, Bundle bundle, String uid, String prefix, Locale locale) { List<ConfigDescriptionParameter> config, Bundle bundle, String uid, String prefix, Locale locale) {
List<ConfigDescriptionParameter> configDescriptions = new ArrayList<ConfigDescriptionParameter>(); List<ConfigDescriptionParameter> configDescriptions = new ArrayList<>();
if (config != null) { if (config != null) {
ConfigDescriptionI18nUtil util = new ConfigDescriptionI18nUtil(i18nProvider); ConfigDescriptionI18nUtil util = new ConfigDescriptionI18nUtil(i18nProvider);
for (ConfigDescriptionParameter parameter : config) { for (ConfigDescriptionParameter parameter : config) {
@ -494,7 +494,7 @@ public abstract class AbstractResourceBundleProvider<E> {
Set<E> parsedObjects) { Set<E> parsedObjects) {
List<ProviderChangeListener<E>> snapshot = null; List<ProviderChangeListener<E>> snapshot = null;
synchronized (listeners) { synchronized (listeners) {
snapshot = new LinkedList<ProviderChangeListener<E>>(listeners); snapshot = new LinkedList<>(listeners);
} }
for (E parsedObject : parsedObjects) { for (E parsedObject : parsedObjects) {
String uid = getUID(parsedObject); String uid = getUID(parsedObject);
@ -521,7 +521,7 @@ public abstract class AbstractResourceBundleProvider<E> {
List<URL> urlList = waitingProviders.get(bundle); List<URL> urlList = waitingProviders.get(bundle);
if (parser == null) { if (parser == null) {
if (urlList == null) { if (urlList == null) {
urlList = new ArrayList<URL>(); urlList = new ArrayList<>();
} }
urlList.add(url); urlList.add(url);
waitingProviders.put(bundle, urlList); waitingProviders.put(bundle, urlList);

View File

@ -44,7 +44,7 @@ public class AutomationResourceBundlesEventQueue<E> implements Runnable {
* This field serves for saving the BundleEvents for the bundles providing automation resources until their * This field serves for saving the BundleEvents for the bundles providing automation resources until their
* processing completes. * processing completes.
*/ */
private List<BundleEvent> queue = new ArrayList<BundleEvent>(); private List<BundleEvent> queue = new ArrayList<>();
/** /**
* This field is for synchronization purposes * This field is for synchronization purposes
@ -173,7 +173,7 @@ public class AutomationResourceBundlesEventQueue<E> implements Runnable {
return; return;
} }
if (shared) { if (shared) {
queue = new LinkedList<BundleEvent>(); queue = new LinkedList<>();
shared = false; shared = false;
} }
if (queue.add(event)) { if (queue.add(event)) {
@ -231,7 +231,7 @@ public class AutomationResourceBundlesEventQueue<E> implements Runnable {
return; return;
} }
if (shared) { if (shared) {
this.queue = new LinkedList<BundleEvent>(); this.queue = new LinkedList<>();
shared = false; shared = false;
} }
if (this.queue.addAll(queue)) { if (this.queue.addAll(queue)) {

View File

@ -52,7 +52,7 @@ public class AutomationResourceBundlesTracker implements BundleTrackerCustomizer
* {@link AbstractResourceBundleProvider}s of {@link ModuleType}s, {@link Template}s and {@link Rule}s. * {@link AbstractResourceBundleProvider}s of {@link ModuleType}s, {@link Template}s and {@link Rule}s.
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
private final List<AutomationResourceBundlesEventQueue> providerEventsQueue = new ArrayList<AutomationResourceBundlesEventQueue>(); private final List<AutomationResourceBundlesEventQueue> providerEventsQueue = new ArrayList<>();
/** /**
* This field holds a reference to an importer of {@link Rule}s. * 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 * 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. * processing completes. The events have been for adding, modifying or removing a bundle.
*/ */
private final List<BundleEvent> queue = new LinkedList<BundleEvent>(); private final List<BundleEvent> queue = new LinkedList<>();
public AutomationResourceBundlesTracker() { public AutomationResourceBundlesTracker() {
rImporter = createImporter(); rImporter = createImporter();
@ -80,7 +80,7 @@ public class AutomationResourceBundlesTracker implements BundleTrackerCustomizer
@Activate @Activate
protected void activate(BundleContext bc) { protected void activate(BundleContext bc) {
bTracker = new BundleTracker<Bundle>(bc, ~Bundle.UNINSTALLED, this); bTracker = new BundleTracker<>(bc, ~Bundle.UNINSTALLED, this);
bTracker.open(); bTracker.open();
} }

View File

@ -29,7 +29,7 @@ import org.osgi.service.packageadmin.PackageAdmin;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class HostFragmentMappingUtil { public class HostFragmentMappingUtil {
private static Map<Bundle, List<Bundle>> hostFragmentMapping = new HashMap<Bundle, List<Bundle>>(); private static Map<Bundle, List<Bundle>> hostFragmentMapping = new HashMap<>();
static PackageAdmin pkgAdmin; static PackageAdmin pkgAdmin;
@ -49,7 +49,7 @@ public class HostFragmentMappingUtil {
* @return a list with the hosts of the <code>fragment</code> parameter. * @return a list with the hosts of the <code>fragment</code> parameter.
*/ */
static List<Bundle> returnHostBundles(Bundle fragment) { static List<Bundle> returnHostBundles(Bundle fragment) {
List<Bundle> hosts = new ArrayList<Bundle>(); List<Bundle> hosts = new ArrayList<>();
Bundle[] bundles = pkgAdmin.getHosts(fragment); Bundle[] bundles = pkgAdmin.getHosts(fragment);
if (bundles != null) { if (bundles != null) {
hosts = Arrays.asList(bundles); hosts = Arrays.asList(bundles);
@ -64,7 +64,7 @@ public class HostFragmentMappingUtil {
} }
static List<Bundle> fillHostFragmentMapping(Bundle host) { static List<Bundle> fillHostFragmentMapping(Bundle host) {
List<Bundle> fragments = new ArrayList<Bundle>(); List<Bundle> fragments = new ArrayList<>();
Bundle[] bundles = pkgAdmin.getFragments(host); Bundle[] bundles = pkgAdmin.getFragments(host);
if (bundles != null) { if (bundles != null) {
fragments = Arrays.asList(bundles); fragments = Arrays.asList(bundles);

View File

@ -64,7 +64,7 @@ public class ModuleTypeResourceBundleProvider extends AbstractResourceBundleProv
* @param context is the {@code BundleContext}, used for creating a tracker for {@link Parser} services. * @param context is the {@code BundleContext}, used for creating a tracker for {@link Parser} services.
*/ */
public ModuleTypeResourceBundleProvider() { public ModuleTypeResourceBundleProvider() {
listeners = new LinkedList<ProviderChangeListener<ModuleType>>(); listeners = new LinkedList<>();
path = ROOT_DIRECTORY + "/moduletypes/"; path = ROOT_DIRECTORY + "/moduletypes/";
} }
@ -135,7 +135,7 @@ public class ModuleTypeResourceBundleProvider extends AbstractResourceBundleProv
*/ */
@Override @Override
public Collection<ModuleType> getModuleTypes(Locale locale) { public Collection<ModuleType> getModuleTypes(Locale locale) {
List<ModuleType> moduleTypesList = new ArrayList<ModuleType>(); List<ModuleType> moduleTypesList = new ArrayList<>();
for (ModuleType mt : providedObjectsHolder.values()) { for (ModuleType mt : providedObjectsHolder.values()) {
moduleTypesList.add(getPerLocale(mt, locale)); moduleTypesList.add(getPerLocale(mt, locale));
} }

View File

@ -71,7 +71,7 @@ public class TemplateResourceBundleProvider extends AbstractResourceBundleProvid
* @param context is the {@code BundleContext}, used for creating a tracker for {@link Parser} services. * @param context is the {@code BundleContext}, used for creating a tracker for {@link Parser} services.
*/ */
public TemplateResourceBundleProvider() { public TemplateResourceBundleProvider() {
listeners = new LinkedList<ProviderChangeListener<RuleTemplate>>(); listeners = new LinkedList<>();
path = ROOT_DIRECTORY + "/templates/"; path = ROOT_DIRECTORY + "/templates/";
} }
@ -141,7 +141,7 @@ public class TemplateResourceBundleProvider extends AbstractResourceBundleProvid
*/ */
@Override @Override
public Collection<RuleTemplate> getTemplates(Locale locale) { public Collection<RuleTemplate> getTemplates(Locale locale) {
ArrayList<RuleTemplate> templatesList = new ArrayList<RuleTemplate>(); List<RuleTemplate> templatesList = new ArrayList<>();
for (RuleTemplate t : providedObjectsHolder.values()) { for (RuleTemplate t : providedObjectsHolder.values()) {
templatesList.add(getPerLocale(t, locale)); templatesList.add(getPerLocale(t, locale));
} }

View File

@ -62,25 +62,25 @@ public abstract class AbstractFileProvider<E> implements Provider<E> {
* <p> * <p>
* The Map has for keys URLs of the files containing automation objects and for values - parsed objects. * The Map has for keys URLs of the files containing automation objects and for values - parsed objects.
*/ */
protected Map<String, E> providedObjectsHolder = new ConcurrentHashMap<String, E>(); protected Map<String, E> providedObjectsHolder = new ConcurrentHashMap<>();
/** /**
* This Map provides structure for fast access to the {@link Parser}s. This provides opportunity for high * This Map provides structure for fast access to the {@link Parser}s. This provides opportunity for high
* performance at runtime of the system. * performance at runtime of the system.
*/ */
private final Map<String, Parser<E>> parsers = new ConcurrentHashMap<String, Parser<E>>(); private final Map<String, Parser<E>> parsers = new ConcurrentHashMap<>();
/** /**
* This map is used for mapping the imported automation objects to the file that contains them. This provides * 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. * opportunity when an event for deletion of the file is received, how to recognize which objects are removed.
*/ */
private final Map<URL, List<String>> providerPortfolio = new ConcurrentHashMap<URL, List<String>>(); private final Map<URL, List<String>> providerPortfolio = new ConcurrentHashMap<>();
/** /**
* This Map holds URL resources that waiting for a parser to be loaded. * This Map holds URL resources that waiting for a parser to be loaded.
*/ */
private final Map<String, List<URL>> urls = new ConcurrentHashMap<String, List<URL>>(); private final Map<String, List<URL>> urls = new ConcurrentHashMap<>();
private final List<ProviderChangeListener<E>> listeners = new ArrayList<ProviderChangeListener<E>>(); private final List<ProviderChangeListener<E>> listeners = new ArrayList<>();
public AbstractFileProvider(String root) { public AbstractFileProvider(String root) {
this.rootSubdirectory = root; this.rootSubdirectory = root;
@ -250,7 +250,7 @@ public abstract class AbstractFileProvider<E> implements Provider<E> {
synchronized (urls) { synchronized (urls) {
List<URL> value = urls.get(parserType); List<URL> value = urls.get(parserType);
if (value == null) { if (value == null) {
value = new ArrayList<URL>(); value = new ArrayList<>();
urls.put(parserType, value); urls.put(parserType, value);
} }
value.add(url); value.add(url);
@ -261,7 +261,7 @@ public abstract class AbstractFileProvider<E> implements Provider<E> {
protected void updateProvidedObjectsHolder(URL url, Set<E> providedObjects) { protected void updateProvidedObjectsHolder(URL url, Set<E> providedObjects) {
if (providedObjects != null && !providedObjects.isEmpty()) { if (providedObjects != null && !providedObjects.isEmpty()) {
List<String> uids = new ArrayList<String>(); List<String> uids = new ArrayList<>();
for (E providedObject : providedObjects) { for (E providedObject : providedObjects) {
String uid = getUID(providedObject); String uid = getUID(providedObject);
uids.add(uid); uids.add(uid);

View File

@ -53,8 +53,8 @@ public abstract class ModuleTypeFileProvider extends AbstractFileProvider<Module
public <T extends ModuleType> Collection<T> getModuleTypes(Locale locale) { public <T extends ModuleType> Collection<T> getModuleTypes(Locale locale) {
Collection<ModuleType> values = providedObjectsHolder.values(); Collection<ModuleType> values = providedObjectsHolder.values();
if (values.isEmpty()) { if (values.isEmpty()) {
return Collections.<T>emptyList(); return Collections.<T> emptyList();
} }
return (Collection<T>) new LinkedList<ModuleType>(values); return (Collection<T>) new LinkedList<>(values);
} }
} }

View File

@ -54,7 +54,7 @@ public abstract class TemplateFileProvider extends AbstractFileProvider<RuleTemp
if (values.isEmpty()) { if (values.isEmpty()) {
return Collections.<RuleTemplate> emptyList(); return Collections.<RuleTemplate> emptyList();
} }
return new LinkedList<RuleTemplate>(values); return new LinkedList<>(values);
} }
} }

View File

@ -24,14 +24,14 @@ import java.util.Map;
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public class WatchServiceUtil { public class WatchServiceUtil {
private static final Map<AbstractFileProvider, Map<String, AutomationWatchService>> WATCH_SERVICES = new HashMap<AbstractFileProvider, Map<String, AutomationWatchService>>(); private static final Map<AbstractFileProvider, Map<String, AutomationWatchService>> WATCH_SERVICES = new HashMap<>();
public static void initializeWatchService(String watchingDir, AbstractFileProvider provider) { public static void initializeWatchService(String watchingDir, AbstractFileProvider provider) {
AutomationWatchService aws = null; AutomationWatchService aws = null;
synchronized (WATCH_SERVICES) { synchronized (WATCH_SERVICES) {
Map<String, AutomationWatchService> watchers = WATCH_SERVICES.get(provider); Map<String, AutomationWatchService> watchers = WATCH_SERVICES.get(provider);
if (watchers == null) { if (watchers == null) {
watchers = new HashMap<String, AutomationWatchService>(); watchers = new HashMap<>();
WATCH_SERVICES.put(provider, watchers); WATCH_SERVICES.put(provider, watchers);
} }
if (watchers.get(watchingDir) == null) { if (watchers.get(watchingDir) == null) {

View File

@ -35,7 +35,7 @@ public class ModuleI18nUtil {
public static <T extends Module> List<T> getLocalizedModules(TranslationProvider i18nProvider, List<T> modules, public static <T extends Module> List<T> getLocalizedModules(TranslationProvider i18nProvider, List<T> modules,
Bundle bundle, String uid, String prefix, Locale locale) { Bundle bundle, String uid, String prefix, Locale locale) {
List<T> lmodules = new ArrayList<T>(); List<T> lmodules = new ArrayList<>();
for (T module : modules) { for (T module : modules) {
String label = getModuleLabel(i18nProvider, bundle, uid, module.getId(), module.getLabel(), prefix, locale); String label = getModuleLabel(i18nProvider, bundle, uid, module.getId(), module.getLabel(), prefix, locale);
String description = getModuleDescription(i18nProvider, bundle, uid, prefix, module.getId(), String description = getModuleDescription(i18nProvider, bundle, uid, prefix, module.getId(),

View File

@ -48,7 +48,7 @@ public class ModuleTypeI18nUtil {
public static List<Input> getLocalizedInputs(TranslationProvider i18nProvider, List<Input> inputs, Bundle bundle, public static List<Input> getLocalizedInputs(TranslationProvider i18nProvider, List<Input> inputs, Bundle bundle,
String uid, Locale locale) { String uid, Locale locale) {
List<Input> linputs = new ArrayList<Input>(); List<Input> linputs = new ArrayList<>();
if (inputs != null) { if (inputs != null) {
for (Input input : inputs) { for (Input input : inputs) {
String inputName = input.getName(); String inputName = input.getName();
@ -65,7 +65,7 @@ public class ModuleTypeI18nUtil {
public static List<Output> getLocalizedOutputs(TranslationProvider i18nProvider, List<Output> outputs, public static List<Output> getLocalizedOutputs(TranslationProvider i18nProvider, List<Output> outputs,
Bundle bundle, String uid, Locale locale) { Bundle bundle, String uid, Locale locale) {
List<Output> loutputs = new ArrayList<Output>(); List<Output> loutputs = new ArrayList<>();
if (outputs != null) { if (outputs != null) {
for (Output output : outputs) { for (Output output : outputs) {
String outputName = output.getName(); String outputName = output.getName();

View File

@ -21,7 +21,6 @@ import java.util.Locale;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; 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.AbstractRegistry;
import org.eclipse.smarthome.core.common.registry.Provider; import org.eclipse.smarthome.core.common.registry.Provider;
import org.openhab.core.automation.template.RuleTemplate; import org.openhab.core.automation.template.RuleTemplate;
@ -70,10 +69,9 @@ public class RuleTemplateRegistry extends AbstractRegistry<RuleTemplate, String,
private RuleTemplate createCopy(RuleTemplate template) { private RuleTemplate createCopy(RuleTemplate template) {
return new RuleTemplate(template.getUID(), template.getLabel(), template.getDescription(), return new RuleTemplate(template.getUID(), template.getLabel(), template.getDescription(),
new HashSet<String>(template.getTags()), new ArrayList<>(template.getTriggers()), new HashSet<>(template.getTags()), new ArrayList<>(template.getTriggers()),
new ArrayList<>(template.getConditions()), new ArrayList<>(template.getActions()), new ArrayList<>(template.getConditions()), new ArrayList<>(template.getActions()),
new LinkedList<ConfigDescriptionParameter>(template.getConfigurationDescriptions()), new LinkedList<>(template.getConfigurationDescriptions()), template.getVisibility());
template.getVisibility());
} }
@Override @Override

View File

@ -80,7 +80,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends ModuleType> Collection<T> getByTag(String moduleTypeTag, Locale locale) { public <T extends ModuleType> Collection<T> getByTag(String moduleTypeTag, Locale locale) {
Collection<T> result = new ArrayList<T>(20); Collection<T> result = new ArrayList<>(20);
forEach((provider, mType) -> { forEach((provider, mType) -> {
ModuleType mt = locale == null ? mType ModuleType mt = locale == null ? mType
: ((ModuleTypeProvider) provider).getModuleType(mType.getUID(), locale); : ((ModuleTypeProvider) provider).getModuleType(mType.getUID(), locale);
@ -102,8 +102,8 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends ModuleType> Collection<T> getByTags(Locale locale, String... tags) { public <T extends ModuleType> Collection<T> getByTags(Locale locale, String... tags) {
Set<String> tagSet = tags != null ? new HashSet<String>(Arrays.asList(tags)) : null; Set<String> tagSet = tags != null ? new HashSet<>(Arrays.asList(tags)) : null;
Collection<T> result = new ArrayList<T>(20); Collection<T> result = new ArrayList<>(20);
forEach((provider, mType) -> { forEach((provider, mType) -> {
ModuleType mt = locale == null ? mType ModuleType mt = locale == null ? mType
: ((ModuleTypeProvider) provider).getModuleType(mType.getUID(), locale); : ((ModuleTypeProvider) provider).getModuleType(mType.getUID(), locale);
@ -119,7 +119,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override @Override
public Collection<TriggerType> getTriggers(Locale locale, String... tags) { public Collection<TriggerType> getTriggers(Locale locale, String... tags) {
Collection<ModuleType> moduleTypes = getByTags(locale, tags); Collection<ModuleType> moduleTypes = getByTags(locale, tags);
Collection<TriggerType> triggerTypes = new ArrayList<TriggerType>(); Collection<TriggerType> triggerTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) { for (ModuleType mt : moduleTypes) {
if (mt instanceof TriggerType) { if (mt instanceof TriggerType) {
triggerTypes.add((TriggerType) mt); triggerTypes.add((TriggerType) mt);
@ -131,7 +131,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override @Override
public Collection<TriggerType> getTriggers(String... tags) { public Collection<TriggerType> getTriggers(String... tags) {
Collection<ModuleType> moduleTypes = getByTags(tags); Collection<ModuleType> moduleTypes = getByTags(tags);
Collection<TriggerType> triggerTypes = new ArrayList<TriggerType>(); Collection<TriggerType> triggerTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) { for (ModuleType mt : moduleTypes) {
if (mt instanceof TriggerType) { if (mt instanceof TriggerType) {
triggerTypes.add((TriggerType) mt); triggerTypes.add((TriggerType) mt);
@ -143,7 +143,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override @Override
public Collection<ConditionType> getConditions(String... tags) { public Collection<ConditionType> getConditions(String... tags) {
Collection<ModuleType> moduleTypes = getByTags(tags); Collection<ModuleType> moduleTypes = getByTags(tags);
Collection<ConditionType> conditionTypes = new ArrayList<ConditionType>(); Collection<ConditionType> conditionTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) { for (ModuleType mt : moduleTypes) {
if (mt instanceof ConditionType) { if (mt instanceof ConditionType) {
conditionTypes.add((ConditionType) mt); conditionTypes.add((ConditionType) mt);
@ -155,7 +155,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override @Override
public Collection<ConditionType> getConditions(Locale locale, String... tags) { public Collection<ConditionType> getConditions(Locale locale, String... tags) {
Collection<ModuleType> moduleTypes = getByTags(locale, tags); Collection<ModuleType> moduleTypes = getByTags(locale, tags);
Collection<ConditionType> conditionTypes = new ArrayList<ConditionType>(); Collection<ConditionType> conditionTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) { for (ModuleType mt : moduleTypes) {
if (mt instanceof ConditionType) { if (mt instanceof ConditionType) {
conditionTypes.add((ConditionType) mt); conditionTypes.add((ConditionType) mt);
@ -167,7 +167,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override @Override
public Collection<ActionType> getActions(String... tags) { public Collection<ActionType> getActions(String... tags) {
Collection<ModuleType> moduleTypes = getByTags(tags); Collection<ModuleType> moduleTypes = getByTags(tags);
Collection<ActionType> actionTypes = new ArrayList<ActionType>(); Collection<ActionType> actionTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) { for (ModuleType mt : moduleTypes) {
if (mt instanceof ActionType) { if (mt instanceof ActionType) {
actionTypes.add((ActionType) mt); actionTypes.add((ActionType) mt);
@ -179,7 +179,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override @Override
public Collection<ActionType> getActions(Locale locale, String... tags) { public Collection<ActionType> getActions(Locale locale, String... tags) {
Collection<ModuleType> moduleTypes = getByTags(locale, tags); Collection<ModuleType> moduleTypes = getByTags(locale, tags);
Collection<ActionType> actionTypes = new ArrayList<ActionType>(); Collection<ActionType> actionTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) { for (ModuleType mt : moduleTypes) {
if (mt instanceof ActionType) { if (mt instanceof ActionType) {
actionTypes.add((ActionType) mt); actionTypes.add((ActionType) mt);

View File

@ -22,6 +22,8 @@ import org.eclipse.smarthome.config.core.ConfigUtil;
import org.eclipse.smarthome.config.core.Configuration; import org.eclipse.smarthome.config.core.Configuration;
import org.openhab.core.automation.Module; import org.openhab.core.automation.Module;
import org.openhab.core.automation.RuleRegistry; 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.ModuleType;
import org.openhab.core.automation.type.ModuleTypeRegistry; import org.openhab.core.automation.type.ModuleTypeRegistry;
@ -60,7 +62,7 @@ public class ConfigurationNormalizer {
*/ */
public static Map<String, ConfigDescriptionParameter> getConfigDescriptionMap( public static Map<String, ConfigDescriptionParameter> getConfigDescriptionMap(
List<ConfigDescriptionParameter> configDesc) { List<ConfigDescriptionParameter> configDesc) {
Map<String, ConfigDescriptionParameter> mapConfigDescs = new HashMap<String, ConfigDescriptionParameter>(); Map<String, ConfigDescriptionParameter> mapConfigDescs = new HashMap<>();
for (ConfigDescriptionParameter configDescriptionParameter : configDesc) { for (ConfigDescriptionParameter configDescriptionParameter : configDesc) {
mapConfigDescs.put(configDescriptionParameter.getName(), configDescriptionParameter); mapConfigDescs.put(configDescriptionParameter.getName(), configDescriptionParameter);
} }

View File

@ -84,7 +84,7 @@ public class ReferenceResolver {
Object result = resolveProperty(config, context, logger, configKey, (String) o); Object result = resolveProperty(config, context, logger, configKey, (String) o);
config.put(configKey, result); config.put(configKey, result);
} else if (o instanceof List) { } else if (o instanceof List) {
ArrayList<Object> resultList = new ArrayList<>(); List<Object> resultList = new ArrayList<>();
List<?> list = (List<?>) o; List<?> list = (List<?>) o;
for (Object obj : list) { for (Object obj : list) {
if (obj instanceof String) { if (obj instanceof String) {

View File

@ -112,7 +112,7 @@ public class RuleBuilder {
public RuleBuilder withTriggers(@Nullable List<? extends Trigger> triggers) { public RuleBuilder withTriggers(@Nullable List<? extends Trigger> triggers) {
if (triggers != null) { if (triggers != null) {
ArrayList<Trigger> triggerList = new ArrayList<>(triggers.size()); List<Trigger> triggerList = new ArrayList<>(triggers.size());
triggers.forEach(t -> triggerList.add(TriggerBuilder.create(t).build())); triggers.forEach(t -> triggerList.add(TriggerBuilder.create(t).build()));
this.triggers = triggerList; this.triggers = triggerList;
} }
@ -125,7 +125,7 @@ public class RuleBuilder {
public RuleBuilder withConditions(@Nullable List<? extends Condition> conditions) { public RuleBuilder withConditions(@Nullable List<? extends Condition> conditions) {
if (conditions != null) { if (conditions != null) {
ArrayList<Condition> conditionList = new ArrayList<>(conditions.size()); List<Condition> conditionList = new ArrayList<>(conditions.size());
conditions.forEach(c -> conditionList.add(ConditionBuilder.create(c).build())); conditions.forEach(c -> conditionList.add(ConditionBuilder.create(c).build()));
this.conditions = conditionList; this.conditions = conditionList;
} }
@ -138,7 +138,7 @@ public class RuleBuilder {
public RuleBuilder withActions(@Nullable List<? extends Action> actions) { public RuleBuilder withActions(@Nullable List<? extends Action> actions) {
if (actions != null) { if (actions != null) {
ArrayList<Action> actionList = new ArrayList<>(actions.size()); List<Action> actionList = new ArrayList<>(actions.size());
actions.forEach(a -> actionList.add(ActionBuilder.create(a).build())); actions.forEach(a -> actionList.add(ActionBuilder.create(a).build()));
this.actions = actionList; this.actions = actionList;
} }

View File

@ -87,7 +87,7 @@ public class AnnotationActionModuleTypeProviderTest extends JavaTest {
AnnotatedActionModuleTypeProvider prov = new AnnotatedActionModuleTypeProvider(); AnnotatedActionModuleTypeProvider prov = new AnnotatedActionModuleTypeProvider();
prov.setModuleTypeI18nService(moduleTypeI18nService); prov.setModuleTypeI18nService(moduleTypeI18nService);
HashMap<String, Object> properties1 = new HashMap<String, Object>(); Map<String, Object> properties1 = new HashMap<>();
properties1.put(ConfigConstants.SERVICE_CONTEXT, "conf1"); properties1.put(ConfigConstants.SERVICE_CONTEXT, "conf1");
prov.addActionProvider(actionProviderConf1, properties1); prov.addActionProvider(actionProviderConf1, properties1);
@ -95,7 +95,7 @@ public class AnnotationActionModuleTypeProviderTest extends JavaTest {
assertEquals(1, types.size()); assertEquals(1, types.size());
assertTrue(types.contains(TEST_ACTION_TYPE_ID)); assertTrue(types.contains(TEST_ACTION_TYPE_ID));
HashMap<String, Object> properties2 = new HashMap<String, Object>(); Map<String, Object> properties2 = new HashMap<>();
properties2.put(ConfigConstants.SERVICE_CONTEXT, "conf2"); properties2.put(ConfigConstants.SERVICE_CONTEXT, "conf2");
prov.addActionProvider(actionProviderConf2, properties2); prov.addActionProvider(actionProviderConf2, properties2);

View File

@ -36,7 +36,7 @@ public abstract class GenericItem implements Item {
protected EventPublisher eventPublisher; protected EventPublisher eventPublisher;
protected Set<StateChangeListener> listeners = new CopyOnWriteArraySet<>( protected Set<StateChangeListener> listeners = new CopyOnWriteArraySet<>(
Collections.newSetFromMap(new WeakHashMap<StateChangeListener, Boolean>())); Collections.newSetFromMap(new WeakHashMap<>()));
protected List<String> groupNames = new ArrayList<>(); protected List<String> groupNames = new ArrayList<>();

View File

@ -58,7 +58,7 @@ public class StringItem extends GenericItem {
@Override @Override
public State getStateAs(Class<? extends State> typeClass) { public State getStateAs(Class<? extends State> typeClass) {
ArrayList<Class<? extends State>> list = new ArrayList<>(); List<Class<? extends State>> list = new ArrayList<>();
list.add(typeClass); list.add(typeClass);
State convertedState = TypeParser.parseState(list, state.toString()); State convertedState = TypeParser.parseState(list, state.toString());
if (convertedState != null) { if (convertedState != null) {

View File

@ -15,6 +15,7 @@ package org.openhab.core.persistence.internal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.eclipse.smarthome.core.persistence.FilterCriteria; import org.eclipse.smarthome.core.persistence.FilterCriteria;
@ -49,7 +50,7 @@ public class QueryablePersistenceServiceDelegate extends PersistenceServiceDeleg
.setState(mapState(filter.getState())); .setState(mapState(filter.getState()));
org.openhab.core.persistence.QueryablePersistenceService pService = (org.openhab.core.persistence.QueryablePersistenceService) service; org.openhab.core.persistence.QueryablePersistenceService pService = (org.openhab.core.persistence.QueryablePersistenceService) service;
Iterable<org.openhab.core.persistence.HistoricItem> historicItems = pService.query(mappedFilter); Iterable<org.openhab.core.persistence.HistoricItem> historicItems = pService.query(mappedFilter);
ArrayList<HistoricItem> result = new ArrayList<>(); List<HistoricItem> result = new ArrayList<>();
if (historicItems != null) { if (historicItems != null) {
for (final org.openhab.core.persistence.HistoricItem item : historicItems) { for (final org.openhab.core.persistence.HistoricItem item : historicItems) {
result.add(new HistoricItem() { result.add(new HistoricItem() {

View File

@ -99,13 +99,13 @@ public class ConfigDescription implements Identifiable<URI> {
if (parameters != null) { if (parameters != null) {
this.parameters = Collections.unmodifiableList(parameters); this.parameters = Collections.unmodifiableList(parameters);
} else { } else {
this.parameters = Collections.unmodifiableList(new ArrayList<ConfigDescriptionParameter>(0)); this.parameters = Collections.unmodifiableList(new ArrayList<>(0));
} }
if (groups != null) { if (groups != null) {
this.parameterGroups = Collections.unmodifiableList(groups); this.parameterGroups = Collections.unmodifiableList(groups);
} else { } else {
this.parameterGroups = Collections.unmodifiableList(new ArrayList<ConfigDescriptionParameterGroup>(0)); this.parameterGroups = Collections.unmodifiableList(new ArrayList<>(0));
} }
} }

View File

@ -97,17 +97,17 @@ public class ConfigDescriptionParameter {
private String label; private String label;
private String description; private String description;
private List<ParameterOption> options = new ArrayList<ParameterOption>(); private List<ParameterOption> options = new ArrayList<>();
private List<FilterCriteria> filterCriteria = new ArrayList<FilterCriteria>(); private List<FilterCriteria> filterCriteria = new ArrayList<>();
private boolean limitToOptions = true; private boolean limitToOptions = true;
private boolean advanced = false; private boolean advanced = false;
private boolean verify = false; private boolean verify = false;
private static final Set<String> UNITS = Collections private static final Set<String> UNITS = Collections
.unmodifiableSet(new HashSet<String>(Arrays.asList("A", "cd", "K", "kg", "m", "mol", "s", "g", "rad", "sr", .unmodifiableSet(new HashSet<>(Arrays.asList("A", "cd", "K", "kg", "m", "mol", "s", "g", "rad", "sr", "Hz",
"Hz", "N", "Pa", "J", "W", "C", "V", "F", "Ω", "S", "Wb", "T", "H", "Cel", "lm", "lx", "Bq", "Gy", "N", "Pa", "J", "W", "C", "V", "F", "Ω", "S", "Wb", "T", "H", "Cel", "lm", "lx", "Bq", "Gy", "Sv",
"Sv", "kat", "m/s2", "m2v", "m3", "kph", "%", "l", "ms", "min", "h", "d", "week", "y"))); "kat", "m/s2", "m2v", "m3", "kph", "%", "l", "ms", "min", "h", "d", "week", "y")));
/** /**
* Default constructor. * Default constructor.
@ -239,12 +239,12 @@ public class ConfigDescriptionParameter {
if (options != null) { if (options != null) {
this.options = Collections.unmodifiableList(options); this.options = Collections.unmodifiableList(options);
} else { } else {
this.options = Collections.unmodifiableList(new LinkedList<ParameterOption>()); this.options = Collections.unmodifiableList(new LinkedList<>());
} }
if (filterCriteria != null) { if (filterCriteria != null) {
this.filterCriteria = Collections.unmodifiableList(filterCriteria); this.filterCriteria = Collections.unmodifiableList(filterCriteria);
} else { } else {
this.filterCriteria = Collections.unmodifiableList(new LinkedList<FilterCriteria>()); this.filterCriteria = Collections.unmodifiableList(new LinkedList<>());
} }
} }
@ -320,23 +320,29 @@ public class ConfigDescriptionParameter {
/** /**
* Returns the context of the configuration parameter. * Returns the context of the configuration parameter.
* <p>A context is a hint for user interfaces and input validators.<p> * <p>
* <p>Any string can be used, but the following have a special meaning:</p> * A context is a hint for user interfaces and input validators.
* * <p>
* <p>
* Any string can be used, but the following have a special meaning:
* </p>
*
* - network-address: The configuration value represents an IPv4 or IPv6 address. * - network-address: The configuration value represents an IPv4 or IPv6 address.
* - password: A password value (a user-interface might obscure the visible value) * - password: A password value (a user-interface might obscure the visible value)
* - password-create: A passwort generator widget might be shown * - password-create: A passwort generator widget might be shown
* - color: This value represents an RGB color value like #ffffff or 12,12,12. * - color: This value represents an RGB color value like #ffffff or 12,12,12.
* - date: A date string * - date: A date string
* - time: A time 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 * - datetime: A date and time string
* - email: The configuration value represents an email address * - email: The configuration value represents an email address
* - month: A number [1-12] * - month: A number [1-12]
* - week: A week [0-52] * - week: A week [0-52]
* - tel: A tel no * - tel: A tel no
* - url: A web address * - 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. * - 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. * - tag: One tag or multiple tags separated by comma.
* - item: A valid item "name". A user-interface would probably show an item selection widget. * - item: A valid item "name". A user-interface would probably show an item selection widget.

View File

@ -51,8 +51,8 @@ public class ConfigDescriptionParameterBuilder {
private Boolean advanced; private Boolean advanced;
private Boolean verify; private Boolean verify;
private List<ParameterOption> options = new ArrayList<ParameterOption>(); private List<ParameterOption> options = new ArrayList<>();
private List<FilterCriteria> filterCriteria = new ArrayList<FilterCriteria>(); private List<FilterCriteria> filterCriteria = new ArrayList<>();
private ConfigDescriptionParameterBuilder(String name, Type type) { private ConfigDescriptionParameterBuilder(String name, Type type) {
this.name = name; this.name = name;

View File

@ -106,7 +106,7 @@ public class ConfigDescriptionRegistry {
* description exists * description exists
*/ */
public Collection<ConfigDescription> getConfigDescriptions(Locale locale) { public Collection<ConfigDescription> getConfigDescriptions(Locale locale) {
Map<URI, ConfigDescription> configMap = new HashMap<URI, ConfigDescription>(); Map<URI, ConfigDescription> configMap = new HashMap<>();
// Loop over all providers // Loop over all providers
for (ConfigDescriptionProvider configDescriptionProvider : this.configDescriptionProviders) { for (ConfigDescriptionProvider configDescriptionProvider : this.configDescriptionProviders) {
@ -116,11 +116,11 @@ public class ConfigDescriptionRegistry {
ConfigDescription configFromMap = configMap.get(configDescription.getUID()); ConfigDescription configFromMap = configMap.get(configDescription.getUID());
if (configFromMap != null) { if (configFromMap != null) {
// Yes - Merge the groups and parameters // Yes - Merge the groups and parameters
List<ConfigDescriptionParameter> parameters = new ArrayList<ConfigDescriptionParameter>(); List<ConfigDescriptionParameter> parameters = new ArrayList<>();
parameters.addAll(configFromMap.getParameters()); parameters.addAll(configFromMap.getParameters());
parameters.addAll(configDescription.getParameters()); parameters.addAll(configDescription.getParameters());
List<ConfigDescriptionParameterGroup> parameterGroups = new ArrayList<ConfigDescriptionParameterGroup>(); List<ConfigDescriptionParameterGroup> parameterGroups = new ArrayList<>();
parameterGroups.addAll(configFromMap.getParameterGroups()); parameterGroups.addAll(configFromMap.getParameterGroups());
parameterGroups.addAll(configDescription.getParameterGroups()); parameterGroups.addAll(configDescription.getParameterGroups());
@ -135,7 +135,7 @@ public class ConfigDescriptionRegistry {
} }
// Now convert the map into the collection // Now convert the map into the collection
Collection<ConfigDescription> configDescriptions = new ArrayList<ConfigDescription>(configMap.size()); Collection<ConfigDescription> configDescriptions = new ArrayList<>(configMap.size());
for (ConfigDescription configDescription : configMap.values()) { for (ConfigDescription configDescription : configMap.values()) {
configDescriptions.add(configDescription); configDescriptions.add(configDescription);
} }
@ -170,8 +170,8 @@ public class ConfigDescriptionRegistry {
* the given name * the given name
*/ */
public @Nullable ConfigDescription getConfigDescription(URI uri, Locale locale) { public @Nullable ConfigDescription getConfigDescription(URI uri, Locale locale) {
List<ConfigDescriptionParameter> parameters = new ArrayList<ConfigDescriptionParameter>(); List<ConfigDescriptionParameter> parameters = new ArrayList<>();
List<ConfigDescriptionParameterGroup> parameterGroups = new ArrayList<ConfigDescriptionParameterGroup>(); List<ConfigDescriptionParameterGroup> parameterGroups = new ArrayList<>();
boolean found = false; boolean found = false;
Set<URI> aliases = getAliases(uri); Set<URI> aliases = getAliases(uri);
@ -183,8 +183,7 @@ public class ConfigDescriptionRegistry {
found |= fillFromProviders(uri, locale, parameters, parameterGroups); found |= fillFromProviders(uri, locale, parameters, parameterGroups);
if (found) { if (found) {
List<ConfigDescriptionParameter> parametersWithOptions = new ArrayList<ConfigDescriptionParameter>( List<ConfigDescriptionParameter> parametersWithOptions = new ArrayList<>(parameters.size());
parameters.size());
for (ConfigDescriptionParameter parameter : parameters) { for (ConfigDescriptionParameter parameter : parameters) {
parametersWithOptions.add(getConfigOptions(uri, aliases, parameter, locale)); parametersWithOptions.add(getConfigOptions(uri, aliases, parameter, locale));
} }
@ -254,7 +253,7 @@ public class ConfigDescriptionRegistry {
*/ */
private ConfigDescriptionParameter getConfigOptions(URI uri, Set<URI> aliases, ConfigDescriptionParameter parameter, private ConfigDescriptionParameter getConfigOptions(URI uri, Set<URI> aliases, ConfigDescriptionParameter parameter,
Locale locale) { Locale locale) {
List<ParameterOption> options = new ArrayList<ParameterOption>(); List<ParameterOption> options = new ArrayList<>();
// Add all the existing options that may be provided by the initial config description provider // Add all the existing options that may be provided by the initial config description provider
options.addAll(parameter.getOptions()); options.addAll(parameter.getOptions());

View File

@ -75,7 +75,7 @@ public class ConfigDescriptionDTOMapper {
if (filterCriteria == null) { if (filterCriteria == null) {
return null; return null;
} }
List<FilterCriteria> result = new LinkedList<FilterCriteria>(); List<FilterCriteria> result = new LinkedList<>();
for (FilterCriteriaDTO criteria : filterCriteria) { for (FilterCriteriaDTO criteria : filterCriteria) {
result.add(new FilterCriteria(criteria.name, criteria.value)); result.add(new FilterCriteria(criteria.name, criteria.value));
} }
@ -86,7 +86,7 @@ public class ConfigDescriptionDTOMapper {
if (options == null) { if (options == null) {
return null; return null;
} }
List<ParameterOption> result = new LinkedList<ParameterOption>(); List<ParameterOption> result = new LinkedList<>();
for (ParameterOptionDTO option : options) { for (ParameterOptionDTO option : options) {
result.add(new ParameterOption(option.value, option.label)); result.add(new ParameterOption(option.value, option.label));
} }
@ -143,7 +143,7 @@ public class ConfigDescriptionDTOMapper {
if (filterCriteria == null) { if (filterCriteria == null) {
return null; return null;
} }
List<FilterCriteriaDTO> result = new LinkedList<FilterCriteriaDTO>(); List<FilterCriteriaDTO> result = new LinkedList<>();
for (FilterCriteria criteria : filterCriteria) { for (FilterCriteria criteria : filterCriteria) {
result.add(new FilterCriteriaDTO(criteria.getName(), criteria.getValue())); result.add(new FilterCriteriaDTO(criteria.getName(), criteria.getValue()));
} }
@ -154,7 +154,7 @@ public class ConfigDescriptionDTOMapper {
if (options == null) { if (options == null) {
return null; return null;
} }
List<ParameterOptionDTO> result = new LinkedList<ParameterOptionDTO>(); List<ParameterOptionDTO> result = new LinkedList<>();
for (ParameterOption option : options) { for (ParameterOption option : options) {
result.add(new ParameterOptionDTO(option.getValue(), option.getLabel())); result.add(new ParameterOptionDTO(option.getValue(), option.getLabel()));
} }

View File

@ -115,7 +115,7 @@ public class ConfigMapper {
* @return A list of Field objects * @return A list of Field objects
*/ */
private static List<Field> getAllFields(Class<?> clazz) { private static List<Field> getAllFields(Class<?> clazz) {
List<Field> fields = new ArrayList<Field>(); List<Field> fields = new ArrayList<>();
Class<?> currentClass = clazz; Class<?> currentClass = clazz;
while (currentClass != null) { while (currentClass != null) {

View File

@ -16,6 +16,7 @@ import java.net.Inet4Address;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -50,7 +51,7 @@ public class NetworkConfigOptionProvider implements ConfigOptionProvider {
} }
if (param.equals(PARAM_BROADCAST_ADDRESS)) { if (param.equals(PARAM_BROADCAST_ADDRESS)) {
ArrayList<String> broadcastAddrList = new ArrayList<>(NetUtil.getAllBroadcastAddresses()); List<String> broadcastAddrList = new ArrayList<>(NetUtil.getAllBroadcastAddresses());
broadcastAddrList.add("255.255.255.255"); broadcastAddrList.add("255.255.255.255");
return broadcastAddrList.stream().map(a -> new ParameterOption(a, a)).collect(Collectors.toList()); return broadcastAddrList.stream().map(a -> new ParameterOption(a, a)).collect(Collectors.toList());
} }

View File

@ -31,7 +31,7 @@ public final class NormalizerFactory {
private static final Map<Type, Normalizer> NORMALIZERS; private static final Map<Type, Normalizer> NORMALIZERS;
static { static {
Map<Type, Normalizer> map = new HashMap<Type, Normalizer>(11); Map<Type, Normalizer> map = new HashMap<>(11);
map.put(Type.BOOLEAN, new BooleanNormalizer()); map.put(Type.BOOLEAN, new BooleanNormalizer());
map.put(Type.TEXT, new TextNormalizer()); map.put(Type.TEXT, new TextNormalizer());
map.put(Type.INTEGER, new IntNormalizer()); map.put(Type.INTEGER, new IntNormalizer());

View File

@ -62,7 +62,7 @@ public class ConfigDescriptionRegistryTest extends JavaTest {
configDescriptionRegistry = new ConfigDescriptionRegistry(); configDescriptionRegistry = new ConfigDescriptionRegistry();
ConfigDescriptionParameter param1 = new ConfigDescriptionParameter("param1", ConfigDescriptionParameter param1 = new ConfigDescriptionParameter("param1",
ConfigDescriptionParameter.Type.INTEGER); ConfigDescriptionParameter.Type.INTEGER);
List<ConfigDescriptionParameter> pList1 = new ArrayList<ConfigDescriptionParameter>(); List<ConfigDescriptionParameter> pList1 = new ArrayList<>();
pList1.add(param1); pList1.add(param1);
configDescription = new ConfigDescription(URI_DUMMY, pList1); configDescription = new ConfigDescription(URI_DUMMY, pList1);
@ -84,7 +84,7 @@ public class ConfigDescriptionRegistryTest extends JavaTest {
ConfigDescriptionParameter param2 = new ConfigDescriptionParameter("param2", ConfigDescriptionParameter param2 = new ConfigDescriptionParameter("param2",
ConfigDescriptionParameter.Type.INTEGER); ConfigDescriptionParameter.Type.INTEGER);
List<ConfigDescriptionParameter> pList2 = new ArrayList<ConfigDescriptionParameter>(); List<ConfigDescriptionParameter> pList2 = new ArrayList<>();
pList2.add(param2); pList2.add(param2);
configDescription2 = new ConfigDescription(URI_DUMMY, pList2); configDescription2 = new ConfigDescription(URI_DUMMY, pList2);
when(configDescriptionProviderMock2.getConfigDescriptions(any())) when(configDescriptionProviderMock2.getConfigDescriptions(any()))

View File

@ -100,7 +100,7 @@ public class DiscoveryResultImpl implements DiscoveryResult {
this.thingTypeUID = thingTypeUID; this.thingTypeUID = thingTypeUID;
this.bridgeUID = bridgeUID; this.bridgeUID = bridgeUID;
this.properties = Collections this.properties = Collections
.unmodifiableMap((properties != null) ? new HashMap<>(properties) : new HashMap<String, Object>()); .unmodifiableMap((properties != null) ? new HashMap<>(properties) : new HashMap<>());
this.representationProperty = representationProperty; this.representationProperty = representationProperty;
this.label = label == null ? "" : label; this.label = label == null ? "" : label;

View File

@ -302,7 +302,7 @@ public final class DiscoveryServiceRegistryImpl implements DiscoveryServiceRegis
@Override @Override
public @Nullable Collection<ThingUID> removeOlderResults(final DiscoveryService source, final long timestamp, public @Nullable Collection<ThingUID> removeOlderResults(final DiscoveryService source, final long timestamp,
final @Nullable Collection<ThingTypeUID> thingTypeUIDs, @Nullable ThingUID bridgeUID) { final @Nullable Collection<ThingTypeUID> thingTypeUIDs, @Nullable ThingUID bridgeUID) {
HashSet<ThingUID> removedResults = new HashSet<>(); Set<ThingUID> removedResults = new HashSet<>();
for (final DiscoveryListener listener : this.listeners) { for (final DiscoveryListener listener : this.listeners) {
try { try {
Collection<ThingUID> olderResults = AccessController Collection<ThingUID> olderResults = AccessController

View File

@ -386,7 +386,7 @@ public final class PersistentInbox implements Inbox, DiscoveryListener, ThingReg
@Override @Override
public @Nullable Collection<ThingUID> removeOlderResults(DiscoveryService source, long timestamp, public @Nullable Collection<ThingUID> removeOlderResults(DiscoveryService source, long timestamp,
@Nullable Collection<ThingTypeUID> thingTypeUIDs, @Nullable ThingUID bridgeUID) { @Nullable Collection<ThingTypeUID> thingTypeUIDs, @Nullable ThingUID bridgeUID) {
HashSet<ThingUID> removedThings = new HashSet<>(); Set<ThingUID> removedThings = new HashSet<>();
for (DiscoveryResult discoveryResult : getAll()) { for (DiscoveryResult discoveryResult : getAll()) {
Class<?> discoverer = resultDiscovererMap.get(discoveryResult); Class<?> discoverer = resultDiscovererMap.get(discoveryResult);
if (thingTypeUIDs != null && thingTypeUIDs.contains(discoveryResult.getThingTypeUID()) if (thingTypeUIDs != null && thingTypeUIDs.contains(discoveryResult.getThingTypeUID())

View File

@ -300,10 +300,10 @@ public class ConfigDispatcher {
// we need to remember which configuration needs to be updated // we need to remember which configuration needs to be updated
// because values have changed. // because values have changed.
Map<Configuration, Dictionary> configsToUpdate = new HashMap<Configuration, Dictionary>(); Map<Configuration, Dictionary> configsToUpdate = new HashMap<>();
// also cache the already retrieved configurations for each pid // also cache the already retrieved configurations for each pid
Map<Configuration, Dictionary> configMap = new HashMap<Configuration, Dictionary>(); Map<Configuration, Dictionary> configMap = new HashMap<>();
String pid = pidFromFilename(configFile); String pid = pidFromFilename(configFile);
String context = null; String context = null;

View File

@ -91,7 +91,7 @@ public abstract class AbstractXmlBasedProvider<T_ID, T_OBJECT extends Identifiab
} }
List<T_OBJECT> objects = bundleObjectMap.get(bundle); List<T_OBJECT> objects = bundleObjectMap.get(bundle);
if (objects == null) { if (objects == null) {
objects = new CopyOnWriteArrayList<T_OBJECT>(); objects = new CopyOnWriteArrayList<>();
bundleObjectMap.put(bundle, objects); bundleObjectMap.put(bundle, objects);
} }
return objects; return objects;

View File

@ -66,8 +66,7 @@ public class ConfigDescriptionConverter extends GenericUnmarshaller<ConfigDescri
URI uri = null; URI uri = null;
if (uriText == null) { if (uriText == null) {
throw new ConversionException( throw new ConversionException("No URI provided");
"No URI provided");
} }
try { try {
@ -78,8 +77,8 @@ public class ConfigDescriptionConverter extends GenericUnmarshaller<ConfigDescri
} }
// create the lists to hold parameters and groups // create the lists to hold parameters and groups
List<ConfigDescriptionParameter> configDescriptionParams = new ArrayList<ConfigDescriptionParameter>(); List<ConfigDescriptionParameter> configDescriptionParams = new ArrayList<>();
List<ConfigDescriptionParameterGroup> configDescriptionGroups = new ArrayList<ConfigDescriptionParameterGroup>(); List<ConfigDescriptionParameterGroup> configDescriptionGroups = new ArrayList<>();
// read values // read values
List<?> nodes = (List<?>) context.convertAnother(context, List.class); List<?> nodes = (List<?>) context.convertAnother(context, List.class);

View File

@ -298,8 +298,8 @@ public class XmlDocumentBundleTracker<T> extends BundleTracker<Bundle> {
* @return the URLs of the resources, never {@code null} * @return the URLs of the resources, never {@code null}
*/ */
private Collection<URL> filterPatches(Enumeration<URL> xmlDocumentPaths, Bundle bundle) { private Collection<URL> filterPatches(Enumeration<URL> xmlDocumentPaths, Bundle bundle) {
List<URL> hostResources = new ArrayList<URL>(); List<URL> hostResources = new ArrayList<>();
List<URL> fragmentResources = new ArrayList<URL>(); List<URL> fragmentResources = new ArrayList<>();
while (xmlDocumentPaths.hasMoreElements()) { while (xmlDocumentPaths.hasMoreElements()) {
URL path = xmlDocumentPaths.nextElement(); URL path = xmlDocumentPaths.nextElement();
@ -310,7 +310,7 @@ public class XmlDocumentBundleTracker<T> extends BundleTracker<Bundle> {
} }
} }
if (!fragmentResources.isEmpty()) { if (!fragmentResources.isEmpty()) {
Map<String, URL> helper = new HashMap<String, URL>(); Map<String, URL> helper = new HashMap<>();
for (URL url : hostResources) { for (URL url : hostResources) {
helper.put(url.getPath(), url); helper.put(url.getPath(), url);
} }

View File

@ -46,7 +46,7 @@ public class ConsoleSupportEclipse implements CommandProvider {
private static final String BASE = "smarthome"; private static final String BASE = "smarthome";
private final SortedMap<String, ConsoleCommandExtension> consoleCommandExtensions = Collections private final SortedMap<String, ConsoleCommandExtension> consoleCommandExtensions = Collections
.synchronizedSortedMap(new TreeMap<String, ConsoleCommandExtension>()); .synchronizedSortedMap(new TreeMap<>());
public ConsoleSupportEclipse() { public ConsoleSupportEclipse() {
} }
@ -90,7 +90,7 @@ public class ConsoleSupportEclipse implements CommandProvider {
console.println(String.format("No handler for command '%s' was found.", cmd)); console.println(String.format("No handler for command '%s' was found.", cmd));
} else { } else {
// Build argument list // Build argument list
final List<String> argsList = new ArrayList<String>(); final List<String> argsList = new ArrayList<>();
while (true) { while (true) {
final String narg = interpreter.nextArgument(); final String narg = interpreter.nextArgument();
if (!StringUtils.isEmpty(narg)) { if (!StringUtils.isEmpty(narg)) {

View File

@ -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. * known). Otherwise it stores the registered service reference, so we could unregister the command extension later.
*/ */
private final Map<ConsoleCommandExtension, ServiceRegistration<?>> commands = Collections private final Map<ConsoleCommandExtension, ServiceRegistration<?>> commands = Collections
.synchronizedMap(new HashMap<ConsoleCommandExtension, ServiceRegistration<?>>()); .synchronizedMap(new HashMap<>());
public ConsoleSupportRfc147() { public ConsoleSupportRfc147() {
// Add our custom help console command extensions. // Add our custom help console command extensions.

View File

@ -71,7 +71,7 @@ public class ConsoleInterpreter {
/** returns an array of the usage texts for all available commands */ /** returns an array of the usage texts for all available commands */
public static List<String> getUsages(Collection<ConsoleCommandExtension> consoleCommandExtensions) { public static List<String> getUsages(Collection<ConsoleCommandExtension> consoleCommandExtensions) {
List<String> usages = new ArrayList<String>(); List<String> usages = new ArrayList<>();
for (ConsoleCommandExtension consoleCommandExtension : consoleCommandExtensions) { for (ConsoleCommandExtension consoleCommandExtension : consoleCommandExtensions) {
usages.addAll(consoleCommandExtension.getUsages()); usages.addAll(consoleCommandExtension.getUsages());
} }

View File

@ -54,7 +54,7 @@ public abstract class BaseSmartHomeServlet extends HttpServlet {
try { try {
logger.debug("Starting up {} at {}", getClass().getSimpleName(), alias); logger.debug("Starting up {} at {}", getClass().getSimpleName(), alias);
Hashtable<String, String> props = new Hashtable<String, String>(); Hashtable<String, String> props = new Hashtable<>();
httpService.registerServlet(alias, this, props, httpContext); httpService.registerServlet(alias, this, props, httpContext);
} catch (NamespaceException e) { } catch (NamespaceException e) {
logger.error("Error during servlet registration - alias {} already in use", alias, e); logger.error("Error during servlet registration - alias {} already in use", alias, e);

View File

@ -178,7 +178,7 @@ public class ConfigurationService {
private Dictionary<String, Object> getProperties(org.osgi.service.cm.Configuration configuration) { private Dictionary<String, Object> getProperties(org.osgi.service.cm.Configuration configuration) {
Dictionary<String, Object> properties = configuration.getProperties(); Dictionary<String, Object> properties = configuration.getProperties();
return properties != null ? properties : new Hashtable<String, Object>(); return properties != null ? properties : new Hashtable<>();
} }
@Reference @Reference

View File

@ -369,7 +369,7 @@ public class PersistenceResource implements RESTResource {
* @return list of persistence services as {@link ServiceBean} * @return list of persistence services as {@link ServiceBean}
*/ */
private List<PersistenceServiceDTO> getPersistenceServiceList(Locale locale) { private List<PersistenceServiceDTO> getPersistenceServiceList(Locale locale) {
List<PersistenceServiceDTO> dtoList = new ArrayList<PersistenceServiceDTO>(); List<PersistenceServiceDTO> dtoList = new ArrayList<>();
for (PersistenceService service : persistenceServiceRegistry.getAll()) { for (PersistenceService service : persistenceServiceRegistry.getAll()) {
PersistenceServiceDTO serviceDTO = new PersistenceServiceDTO(); PersistenceServiceDTO serviceDTO = new PersistenceServiceDTO();

View File

@ -24,7 +24,7 @@ import org.eclipse.smarthome.core.persistence.dto.ItemHistoryDTO;
* @author Chris Jackson - Initial contribution * @author Chris Jackson - Initial contribution
*/ */
public class ItemHistoryListDTO { public class ItemHistoryListDTO {
public final List<ItemHistoryDTO> item = new ArrayList<ItemHistoryDTO>(); public final List<ItemHistoryDTO> item = new ArrayList<>();
public ItemHistoryListDTO() { public ItemHistoryListDTO() {
} }

View File

@ -14,6 +14,7 @@ package org.eclipse.smarthome.io.rest.core.thing;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.eclipse.smarthome.core.thing.dto.ChannelDTO; import org.eclipse.smarthome.core.thing.dto.ChannelDTO;
/** /**
@ -36,6 +37,6 @@ public class EnrichedChannelDTO extends ChannelDTO {
this.properties = channelDTO.properties; this.properties = channelDTO.properties;
this.configuration = channelDTO.configuration; this.configuration = channelDTO.configuration;
this.defaultTags = channelDTO.defaultTags; this.defaultTags = channelDTO.defaultTags;
this.linkedItems = linkedItems != null ? new HashSet<>(linkedItems) : new HashSet<String>(); this.linkedItems = linkedItems != null ? new HashSet<>(linkedItems) : new HashSet<>();
} }
} }

View File

@ -91,7 +91,7 @@ public class MDNSAnnouncer {
} }
private ServiceDescription getDefaultServiceDescription() { private ServiceDescription getDefaultServiceDescription() {
Hashtable<String, String> serviceProperties = new Hashtable<String, String>(); Hashtable<String, String> serviceProperties = new Hashtable<>();
serviceProperties.put("uri", RESTConstants.REST_URI); serviceProperties.put("uri", RESTConstants.REST_URI);
return new ServiceDescription("_" + mdnsName + "-server._tcp.local.", mdnsName, httpPort, serviceProperties); return new ServiceDescription("_" + mdnsName + "-server._tcp.local.", mdnsName, httpPort, serviceProperties);
} }

View File

@ -268,7 +268,7 @@ public class SitemapSubscriptionService implements ModelRepositoryChangeListener
} }
private EList<Widget> collectWidgets(String sitemapName, String pageId) { private EList<Widget> collectWidgets(String sitemapName, String pageId) {
EList<Widget> widgets = new BasicEList<Widget>(); EList<Widget> widgets = new BasicEList<>();
Sitemap sitemap = getSitemap(sitemapName); Sitemap sitemap = getSitemap(sitemapName);
if (sitemap != null) { if (sitemap != null) {

View File

@ -54,8 +54,7 @@ public class PageChangeListener implements StateChangeListener {
private final ItemUIRegistry itemUIRegistry; private final ItemUIRegistry itemUIRegistry;
private EList<Widget> widgets; private EList<Widget> widgets;
private Set<Item> items; private Set<Item> items;
private final List<SitemapSubscriptionCallback> callbacks = Collections private final List<SitemapSubscriptionCallback> callbacks = Collections.synchronizedList(new ArrayList<>());
.synchronizedList(new ArrayList<SitemapSubscriptionCallback>());
private Set<SitemapSubscriptionCallback> distinctCallbacks = Collections.emptySet(); private Set<SitemapSubscriptionCallback> distinctCallbacks = Collections.emptySet();
/** /**
@ -134,7 +133,7 @@ public class PageChangeListener implements StateChangeListener {
* @return all items that are represented by the list of widgets * @return all items that are represented by the list of widgets
*/ */
private Set<Item> getAllItems(EList<Widget> widgets) { private Set<Item> getAllItems(EList<Widget> widgets) {
Set<Item> items = new HashSet<Item>(); Set<Item> items = new HashSet<>();
if (itemUIRegistry != null) { if (itemUIRegistry != null) {
for (Widget widget : widgets) { for (Widget widget : widgets) {
addItemWithName(items, widget.getItem()); addItemWithName(items, widget.getItem());
@ -235,8 +234,8 @@ public class PageChangeListener implements StateChangeListener {
// the widget including its state (in event.item.state) // the widget including its state (in event.item.state)
final Item itemToBeSent = itemBelongsToWidget ? item : getItemForWidget(w); final Item itemToBeSent = itemBelongsToWidget ? item : getItemForWidget(w);
if (itemToBeSent != null) { if (itemToBeSent != null) {
String widgetTypeName = w.eClass().getInstanceTypeName().substring( String widgetTypeName = w.eClass().getInstanceTypeName()
w.eClass().getInstanceTypeName().lastIndexOf(".") + 1); .substring(w.eClass().getInstanceTypeName().lastIndexOf(".") + 1);
boolean drillDown = "mapview".equalsIgnoreCase(widgetTypeName); boolean drillDown = "mapview".equalsIgnoreCase(widgetTypeName);
Predicate<Item> itemFilter = (i -> i.getType().equals(CoreItemFactory.LOCATION)); Predicate<Item> itemFilter = (i -> i.getType().equals(CoreItemFactory.LOCATION));
event.item = EnrichedItemDTOMapper.map(itemToBeSent, drillDown, itemFilter, null, null); event.item = EnrichedItemDTOMapper.map(itemToBeSent, drillDown, itemFilter, null, null);

View File

@ -31,7 +31,7 @@ public class PageDTO {
public boolean leaf; public boolean leaf;
public boolean timeout; public boolean timeout;
public List<WidgetDTO> widgets = new ArrayList<WidgetDTO>(); public List<WidgetDTO> widgets = new ArrayList<>();
public PageDTO() { public PageDTO() {
} }

View File

@ -400,7 +400,7 @@ public class SitemapResource implements RESTResource, SitemapSubscriptionCallbac
} }
public Collection<SitemapDTO> getSitemapBeans(URI uri) { public Collection<SitemapDTO> getSitemapBeans(URI uri) {
Collection<SitemapDTO> beans = new LinkedList<SitemapDTO>(); Collection<SitemapDTO> beans = new LinkedList<>();
Set<String> names = new HashSet<>(); Set<String> names = new HashSet<>();
logger.debug("Received HTTP GET request at '{}'.", UriBuilder.fromUri(uri).build().toASCIIString()); logger.debug("Received HTTP GET request at '{}'.", UriBuilder.fromUri(uri).build().toASCIIString());
for (SitemapProvider provider : sitemapProviders) { 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 * @return all items that are represented by the list of widgets
*/ */
private Set<GenericItem> getAllItems(EList<Widget> widgets) { private Set<GenericItem> getAllItems(EList<Widget> widgets) {
Set<GenericItem> items = new HashSet<GenericItem>(); Set<GenericItem> items = new HashSet<>();
if (itemUIRegistry != null) { if (itemUIRegistry != null) {
for (Widget widget : widgets) { for (Widget widget : widgets) {
// We skip the chart widgets having a refresh argument // We skip the chart widgets having a refresh argument
@ -733,7 +733,7 @@ public class SitemapResource implements RESTResource, SitemapSubscriptionCallbac
} }
private Set<GenericItem> getItemsInVisibilityCond(EList<VisibilityRule> ruleList) { private Set<GenericItem> getItemsInVisibilityCond(EList<VisibilityRule> ruleList) {
Set<GenericItem> items = new HashSet<GenericItem>(); Set<GenericItem> items = new HashSet<>();
for (VisibilityRule rule : ruleList) { for (VisibilityRule rule : ruleList) {
String itemName = rule.getItem(); String itemName = rule.getItem();
if (itemName != null) { if (itemName != null) {
@ -751,7 +751,7 @@ public class SitemapResource implements RESTResource, SitemapSubscriptionCallbac
} }
private Set<GenericItem> getItemsInColorCond(EList<ColorArray> colorList) { private Set<GenericItem> getItemsInColorCond(EList<ColorArray> colorList) {
Set<GenericItem> items = new HashSet<GenericItem>(); Set<GenericItem> items = new HashSet<>();
for (ColorArray color : colorList) { for (ColorArray color : colorList) {
String itemName = color.getItem(); String itemName = color.getItem();
if (itemName != null) { if (itemName != null) {

View File

@ -37,7 +37,7 @@ public class WidgetDTO {
public String valuecolor; public String valuecolor;
// widget-specific attributes // widget-specific attributes
public List<MappingDTO> mappings = new ArrayList<MappingDTO>(); public final List<MappingDTO> mappings = new ArrayList<>();
public Boolean switchSupport; public Boolean switchSupport;
public Integer sendFrequency; public Integer sendFrequency;
public String separator; public String separator;
@ -57,7 +57,7 @@ public class WidgetDTO {
public PageDTO linkedPage; public PageDTO linkedPage;
// only for frames, other linkable widgets link to a page // only for frames, other linkable widgets link to a page
public final List<WidgetDTO> widgets = new ArrayList<WidgetDTO>(); public final List<WidgetDTO> widgets = new ArrayList<>();
public WidgetDTO() { public WidgetDTO() {
} }

View File

@ -72,7 +72,7 @@ public class SseUtil {
* @return * @return
*/ */
public static List<String> convertToRegex(String topicFilter) { public static List<String> convertToRegex(String topicFilter) {
List<String> filters = new ArrayList<String>(); List<String> filters = new ArrayList<>();
if (StringUtils.isEmpty(topicFilter)) { if (StringUtils.isEmpty(topicFilter)) {
filters.add(".*"); filters.add(".*");

View File

@ -39,7 +39,7 @@ public class HLIMapper {
dto.label = hli.getLabel(locale); dto.label = hli.getLabel(locale);
final Set<Locale> supportedLocales = hli.getSupportedLocales(); final Set<Locale> supportedLocales = hli.getSupportedLocales();
if (supportedLocales != null) { if (supportedLocales != null) {
dto.locales = new HashSet<String>(supportedLocales.size()); dto.locales = new HashSet<>(supportedLocales.size());
for (final Locale supportedLocale : supportedLocales) { for (final Locale supportedLocale : supportedLocales) {
dto.locales.add(supportedLocale.toString()); dto.locales.add(supportedLocale.toString());
} }

View File

@ -59,7 +59,7 @@ public class RootResource {
private final transient Logger logger = LoggerFactory.getLogger(RootResource.class); private final transient Logger logger = LoggerFactory.getLogger(RootResource.class);
private List<RESTResource> restResources = new ArrayList<RESTResource>(); private final List<RESTResource> restResources = new ArrayList<>();
private ConfigurationAdmin configurationAdmin; private ConfigurationAdmin configurationAdmin;

View File

@ -25,7 +25,7 @@ public class RootBean {
public final String version = "3"; public final String version = "3";
public final List<Links> links = new ArrayList<Links>(); public final List<Links> links = new ArrayList<>();
public static class Links { public static class Links {
public Links(String type, String url) { public Links(String type, String url) {

View File

@ -115,7 +115,7 @@ public class MqttBrokerConnection {
public class ConnectionCallback implements IMqttActionListener { public class ConnectionCallback implements IMqttActionListener {
private final MqttBrokerConnection connection; private final MqttBrokerConnection connection;
private final Runnable cancelTimeoutFuture; private final Runnable cancelTimeoutFuture;
private CompletableFuture<Boolean> future = new CompletableFuture<Boolean>(); private CompletableFuture<Boolean> future = new CompletableFuture<>();
public ConnectionCallback(MqttBrokerConnection mqttBrokerConnectionImpl) { public ConnectionCallback(MqttBrokerConnection mqttBrokerConnectionImpl) {
this.connection = mqttBrokerConnectionImpl; this.connection = mqttBrokerConnectionImpl;
@ -163,7 +163,7 @@ public class MqttBrokerConnection {
} }
public CompletableFuture<Boolean> createFuture() { public CompletableFuture<Boolean> createFuture() {
future = new CompletableFuture<Boolean>(); future = new CompletableFuture<>();
return future; return future;
} }
} }
@ -481,7 +481,7 @@ public class MqttBrokerConnection {
* @return Completes with true if successful. Completes with false if not connected yet. Exceptionally otherwise. * @return Completes with true if successful. Completes with false if not connected yet. Exceptionally otherwise.
*/ */
public CompletableFuture<Boolean> subscribe(String topic, MqttMessageSubscriber subscriber) { public CompletableFuture<Boolean> subscribe(String topic, MqttMessageSubscriber subscriber) {
CompletableFuture<Boolean> future = new CompletableFuture<Boolean>(); CompletableFuture<Boolean> future = new CompletableFuture<>();
synchronized (subscribers) { synchronized (subscribers) {
TopicSubscribers subscriberList = subscribers.getOrDefault(topic, new TopicSubscribers(topic)); TopicSubscribers subscriberList = subscribers.getOrDefault(topic, new TopicSubscribers(topic));
subscribers.put(topic, subscriberList); subscribers.put(topic, subscriberList);
@ -513,7 +513,7 @@ public class MqttBrokerConnection {
*/ */
protected CompletableFuture<Boolean> subscribeRaw(String topic) { protected CompletableFuture<Boolean> subscribeRaw(String topic) {
logger.trace("subscribeRaw message consumer for topic '{}' from broker '{}'", topic, host); logger.trace("subscribeRaw message consumer for topic '{}' from broker '{}'", topic, host);
CompletableFuture<Boolean> future = new CompletableFuture<Boolean>(); CompletableFuture<Boolean> future = new CompletableFuture<>();
try { try {
MqttAsyncClient client = this.client; MqttAsyncClient client = this.client;
if (client != null && client.isConnected()) { if (client != null && client.isConnected()) {
@ -569,7 +569,7 @@ public class MqttBrokerConnection {
*/ */
protected CompletableFuture<Boolean> unsubscribeRaw(MqttAsyncClient client, String topic) { protected CompletableFuture<Boolean> unsubscribeRaw(MqttAsyncClient client, String topic) {
logger.trace("Unsubscribing message consumer for topic '{}' from broker '{}'", topic, host); logger.trace("Unsubscribing message consumer for topic '{}' from broker '{}'", topic, host);
CompletableFuture<Boolean> future = new CompletableFuture<Boolean>(); CompletableFuture<Boolean> future = new CompletableFuture<>();
try { try {
if (client.isConnected()) { if (client.isConnected()) {
client.unsubscribe(topic, future, actionCallback); client.unsubscribe(topic, future, actionCallback);
@ -823,7 +823,7 @@ public class MqttBrokerConnection {
reconnectStrategy.stop(); reconnectStrategy.stop();
} }
CompletableFuture<Boolean> future = new CompletableFuture<Boolean>(); CompletableFuture<Boolean> future = new CompletableFuture<>();
// Close connection // Close connection
if (client.isConnected()) { if (client.isConnected()) {
// We need to thread change here. Because paho does not allow to disconnect within a callback method // 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); return CompletableFuture.completedFuture(false);
} }
// publish message asynchronously // publish message asynchronously
CompletableFuture<Boolean> f = new CompletableFuture<Boolean>(); CompletableFuture<Boolean> f = new CompletableFuture<>();
try { try {
client.publish(topic, payload, qos, retain, f, actionCallback); client.publish(topic, payload, qos, retain, f, actionCallback);
} catch (org.eclipse.paho.client.mqttv3.MqttException e) { } catch (org.eclipse.paho.client.mqttv3.MqttException e) {

View File

@ -46,7 +46,7 @@ import org.slf4j.LoggerFactory;
@NonNullByDefault @NonNullByDefault
public class MqttServiceImpl implements MqttService { public class MqttServiceImpl implements MqttService {
private final Logger logger = LoggerFactory.getLogger(MqttServiceImpl.class); private final Logger logger = LoggerFactory.getLogger(MqttServiceImpl.class);
private final Map<String, MqttBrokerConnection> brokerConnections = new ConcurrentHashMap<String, MqttBrokerConnection>(); private final Map<String, MqttBrokerConnection> brokerConnections = new ConcurrentHashMap<>();
private final List<MqttServiceObserver> brokersObservers = new CopyOnWriteArrayList<>(); private final List<MqttServiceObserver> brokersObservers = new CopyOnWriteArrayList<>();
@Override @Override

View File

@ -109,7 +109,7 @@ public class SerialPortUtil {
if (serialPortsProperty != null) { if (serialPortsProperty != null) {
serialPorts = Stream.of(serialPortsProperty.split(pathSeparator)).collect(Collectors.toSet()); serialPorts = Stream.of(serialPortsProperty.split(pathSeparator)).collect(Collectors.toSet());
} else { } else {
serialPorts = new HashSet<String>(); serialPorts = new HashSet<>();
} }
if (serialPorts.add(port)) { if (serialPorts.add(port)) {
return serialPorts.stream().collect(Collectors.joining(pathSeparator)); // see return serialPorts.stream().collect(Collectors.joining(pathSeparator)); // see

View File

@ -78,9 +78,9 @@ public class UpnpIOServiceImpl implements UpnpIOService, RegistryListener {
private UpnpService upnpService; private UpnpService upnpService;
final Set<UpnpIOParticipant> participants = new CopyOnWriteArraySet<>(); final Set<UpnpIOParticipant> participants = new CopyOnWriteArraySet<>();
final Map<UpnpIOParticipant, ScheduledFuture> pollingJobs = new ConcurrentHashMap<UpnpIOParticipant, ScheduledFuture>(); final Map<UpnpIOParticipant, ScheduledFuture> pollingJobs = new ConcurrentHashMap<>();
final Map<UpnpIOParticipant, Boolean> currentStates = new ConcurrentHashMap<UpnpIOParticipant, Boolean>(); final Map<UpnpIOParticipant, Boolean> currentStates = new ConcurrentHashMap<>();
final Map<Service, UpnpSubscriptionCallback> subscriptionCallbacks = new ConcurrentHashMap<Service, UpnpSubscriptionCallback>(); final Map<Service, UpnpSubscriptionCallback> subscriptionCallbacks = new ConcurrentHashMap<>();
public class UpnpSubscriptionCallback extends SubscriptionCallback { public class UpnpSubscriptionCallback extends SubscriptionCallback {
@ -288,7 +288,7 @@ public class UpnpIOServiceImpl implements UpnpIOService, RegistryListener {
@Override @Override
public Map<String, String> invokeAction(UpnpIOParticipant participant, String serviceID, String actionID, public Map<String, String> invokeAction(UpnpIOParticipant participant, String serviceID, String actionID,
Map<String, String> inputs) { Map<String, String> inputs) {
HashMap<String, String> resultMap = new HashMap<>(); Map<String, String> resultMap = new HashMap<>();
if (serviceID != null && actionID != null && participant != null) { if (serviceID != null && actionID != null && participant != null) {
registerParticipant(participant); registerParticipant(participant);

View File

@ -121,7 +121,7 @@ public class ModelRepositoryImpl implements ModelRepository {
resource = resourceSet.createResource(URI.createURI(name)); resource = resourceSet.createResource(URI.createURI(name));
if (resource != null) { if (resource != null) {
logger.info("Loading model '{}'", name); logger.info("Loading model '{}'", name);
Map<String, String> options = new HashMap<String, String>(); Map<String, String> options = new HashMap<>();
options.put(XtextResource.OPTION_ENCODING, "UTF-8"); options.put(XtextResource.OPTION_ENCODING, "UTF-8");
if (inputStream == null) { if (inputStream == null) {
logger.warn( logger.warn(
@ -178,7 +178,7 @@ public class ModelRepositoryImpl implements ModelRepository {
public Iterable<String> getAllModelNamesOfType(final String modelType) { public Iterable<String> getAllModelNamesOfType(final String modelType) {
synchronized (resourceSet) { synchronized (resourceSet) {
// Make a copy to avoid ConcurrentModificationException // Make a copy to avoid ConcurrentModificationException
List<Resource> resourceListCopy = new ArrayList<Resource>(resourceSet.getResources()); List<Resource> resourceListCopy = new ArrayList<>(resourceSet.getResources());
return resourceListCopy.stream().filter(input -> { return resourceListCopy.stream().filter(input -> {
return input != null && input.getURI().lastSegment().contains(".") && input.isLoaded() return input != null && input.getURI().lastSegment().contains(".") && input.isLoaded()
@ -193,7 +193,7 @@ public class ModelRepositoryImpl implements ModelRepository {
public void reloadAllModelsOfType(final String modelType) { public void reloadAllModelsOfType(final String modelType) {
synchronized (resourceSet) { synchronized (resourceSet) {
// Make a copy to avoid ConcurrentModificationException // Make a copy to avoid ConcurrentModificationException
List<Resource> resourceListCopy = new ArrayList<Resource>(resourceSet.getResources()); List<Resource> resourceListCopy = new ArrayList<>(resourceSet.getResources());
for (Resource resource : resourceListCopy) { for (Resource resource : resourceListCopy) {
if (resource != null && resource.getURI().lastSegment().contains(".") && resource.isLoaded()) { if (resource != null && resource.getURI().lastSegment().contains(".") && resource.isLoaded()) {
if (modelType.equalsIgnoreCase(resource.getURI().fileExtension())) { if (modelType.equalsIgnoreCase(resource.getURI().fileExtension())) {
@ -215,7 +215,7 @@ public class ModelRepositoryImpl implements ModelRepository {
Set<String> ret = new HashSet<>(); Set<String> ret = new HashSet<>();
synchronized (resourceSet) { synchronized (resourceSet) {
// Make a copy to avoid ConcurrentModificationException // Make a copy to avoid ConcurrentModificationException
List<Resource> resourceListCopy = new ArrayList<Resource>(resourceSet.getResources()); List<Resource> resourceListCopy = new ArrayList<>(resourceSet.getResources());
for (Resource resource : resourceListCopy) { for (Resource resource : resourceListCopy) {
if (resource != null && resource.getURI().lastSegment().contains(".") && resource.isLoaded()) { if (resource != null && resource.getURI().lastSegment().contains(".") && resource.isLoaded()) {
if (modelType.equalsIgnoreCase(resource.getURI().fileExtension())) { if (modelType.equalsIgnoreCase(resource.getURI().fileExtension())) {

View File

@ -68,7 +68,7 @@ public class FolderObserver extends AbstractWatchService {
private ModelRepository modelRepo = null; private ModelRepository modelRepo = null;
/* map that stores a list of valid file extensions for each folder */ /* map that stores a list of valid file extensions for each folder */
private final Map<String, String[]> folderFileExtMap = new ConcurrentHashMap<String, String[]>(); private final Map<String, String[]> folderFileExtMap = new ConcurrentHashMap<>();
/* set of file extensions for which we have parsers already registered */ /* set of file extensions for which we have parsers already registered */
private final Set<String> parsers = new HashSet<>(); private final Set<String> parsers = new HashSet<>();
@ -144,7 +144,7 @@ public class FolderObserver extends AbstractWatchService {
} }
private void processIgnoredFiles(String extension) { private void processIgnoredFiles(String extension) {
HashSet<File> clonedSet = new HashSet<>(this.ignoredFiles); Set<File> clonedSet = new HashSet<>(this.ignoredFiles);
for (File file : clonedSet) { for (File file : clonedSet) {
if (extension.equals(getExtension(file.getPath()))) { if (extension.equals(getExtension(file.getPath()))) {
checkFile(modelRepo, file, ENTRY_CREATE); checkFile(modelRepo, file, ENTRY_CREATE);

View File

@ -75,7 +75,7 @@ public class GenericItemProvider extends AbstractProvider<Item>
private final Logger logger = LoggerFactory.getLogger(GenericItemProvider.class); private final Logger logger = LoggerFactory.getLogger(GenericItemProvider.class);
/** to keep track of all binding config readers */ /** to keep track of all binding config readers */
private final Map<String, BindingConfigReader> bindingConfigReaders = new HashMap<String, BindingConfigReader>(); private final Map<String, BindingConfigReader> bindingConfigReaders = new HashMap<>();
private final ModelRepository modelRepository; private final ModelRepository modelRepository;
@ -83,7 +83,7 @@ public class GenericItemProvider extends AbstractProvider<Item>
private final Map<String, Collection<Item>> itemsMap = new ConcurrentHashMap<>(); private final Map<String, Collection<Item>> itemsMap = new ConcurrentHashMap<>();
private final Collection<ItemFactory> itemFactorys = new ArrayList<ItemFactory>(); private final Collection<ItemFactory> itemFactorys = new ArrayList<>();
private final Map<String, StateDescriptionFragment> stateDescriptionFragments = new ConcurrentHashMap<>(); private final Map<String, StateDescriptionFragment> stateDescriptionFragments = new ConcurrentHashMap<>();
@ -160,7 +160,7 @@ public class GenericItemProvider extends AbstractProvider<Item>
@Override @Override
public Collection<Item> getAll() { public Collection<Item> getAll() {
List<Item> items = new ArrayList<Item>(); List<Item> items = new ArrayList<>();
stateDescriptionFragments.clear(); stateDescriptionFragments.clear();
for (String name : modelRepository.getAllModelNamesOfType("items")) { for (String name : modelRepository.getAllModelNamesOfType("items")) {
items.addAll(getItemsFromModel(name)); items.addAll(getItemsFromModel(name));
@ -171,7 +171,7 @@ public class GenericItemProvider extends AbstractProvider<Item>
private Collection<Item> getItemsFromModel(String modelName) { private Collection<Item> getItemsFromModel(String modelName) {
logger.debug("Read items from model '{}'", modelName); logger.debug("Read items from model '{}'", modelName);
List<Item> items = new ArrayList<Item>(); List<Item> items = new ArrayList<>();
ItemModel model = (ItemModel) modelRepository.getModel(modelName); ItemModel model = (ItemModel) modelRepository.getModel(modelName);
if (model != null) { if (model != null) {
for (ModelItem modelItem : model.getItems()) { for (ModelItem modelItem : model.getItems()) {

View File

@ -374,7 +374,7 @@ public class RuleTriggerManager {
if ((!isGroup) && (t instanceof CommandEventTrigger)) { if ((!isGroup) && (t instanceof CommandEventTrigger)) {
final CommandEventTrigger ct = (CommandEventTrigger) t; final CommandEventTrigger ct = (CommandEventTrigger) t;
if (ct.getItem().equals(name)) { if (ct.getItem().equals(name)) {
triggerCommandString = ct.getCommand()!=null?ct.getCommand().getValue() : null; triggerCommandString = ct.getCommand() != null ? ct.getCommand().getValue() : null;
} else { } else {
continue; continue;
} }
@ -574,7 +574,7 @@ public class RuleTriggerManager {
CommandEventTrigger ceTrigger = (CommandEventTrigger) t; CommandEventTrigger ceTrigger = (CommandEventTrigger) t;
Set<Rule> rules = commandEventTriggeredRules.get(ceTrigger.getItem()); Set<Rule> rules = commandEventTriggeredRules.get(ceTrigger.getItem());
if (rules == null) { if (rules == null) {
rules = new HashSet<Rule>(); rules = new HashSet<>();
commandEventTriggeredRules.put(ceTrigger.getItem(), rules); commandEventTriggeredRules.put(ceTrigger.getItem(), rules);
} }
rules.add(rule); rules.add(rule);
@ -582,7 +582,7 @@ public class RuleTriggerManager {
GroupMemberCommandEventTrigger gmceTrigger = (GroupMemberCommandEventTrigger) t; GroupMemberCommandEventTrigger gmceTrigger = (GroupMemberCommandEventTrigger) t;
Set<Rule> rules = commandEventTriggeredRules.get(GROUP_NAME_PREFIX + gmceTrigger.getGroup()); Set<Rule> rules = commandEventTriggeredRules.get(GROUP_NAME_PREFIX + gmceTrigger.getGroup());
if (rules == null) { if (rules == null) {
rules = new HashSet<Rule>(); rules = new HashSet<>();
commandEventTriggeredRules.put(GROUP_NAME_PREFIX + gmceTrigger.getGroup(), rules); commandEventTriggeredRules.put(GROUP_NAME_PREFIX + gmceTrigger.getGroup(), rules);
} }
rules.add(rule); rules.add(rule);
@ -590,7 +590,7 @@ public class RuleTriggerManager {
UpdateEventTrigger ueTrigger = (UpdateEventTrigger) t; UpdateEventTrigger ueTrigger = (UpdateEventTrigger) t;
Set<Rule> rules = updateEventTriggeredRules.get(ueTrigger.getItem()); Set<Rule> rules = updateEventTriggeredRules.get(ueTrigger.getItem());
if (rules == null) { if (rules == null) {
rules = new HashSet<Rule>(); rules = new HashSet<>();
updateEventTriggeredRules.put(ueTrigger.getItem(), rules); updateEventTriggeredRules.put(ueTrigger.getItem(), rules);
} }
rules.add(rule); rules.add(rule);
@ -598,7 +598,7 @@ public class RuleTriggerManager {
GroupMemberUpdateEventTrigger gmueTrigger = (GroupMemberUpdateEventTrigger) t; GroupMemberUpdateEventTrigger gmueTrigger = (GroupMemberUpdateEventTrigger) t;
Set<Rule> rules = updateEventTriggeredRules.get(GROUP_NAME_PREFIX + gmueTrigger.getGroup()); Set<Rule> rules = updateEventTriggeredRules.get(GROUP_NAME_PREFIX + gmueTrigger.getGroup());
if (rules == null) { if (rules == null) {
rules = new HashSet<Rule>(); rules = new HashSet<>();
updateEventTriggeredRules.put(GROUP_NAME_PREFIX + gmueTrigger.getGroup(), rules); updateEventTriggeredRules.put(GROUP_NAME_PREFIX + gmueTrigger.getGroup(), rules);
} }
rules.add(rule); rules.add(rule);
@ -606,7 +606,7 @@ public class RuleTriggerManager {
ChangedEventTrigger ceTrigger = (ChangedEventTrigger) t; ChangedEventTrigger ceTrigger = (ChangedEventTrigger) t;
Set<Rule> rules = changedEventTriggeredRules.get(ceTrigger.getItem()); Set<Rule> rules = changedEventTriggeredRules.get(ceTrigger.getItem());
if (rules == null) { if (rules == null) {
rules = new HashSet<Rule>(); rules = new HashSet<>();
changedEventTriggeredRules.put(ceTrigger.getItem(), rules); changedEventTriggeredRules.put(ceTrigger.getItem(), rules);
} }
rules.add(rule); rules.add(rule);
@ -614,7 +614,7 @@ public class RuleTriggerManager {
GroupMemberChangedEventTrigger gmceTrigger = (GroupMemberChangedEventTrigger) t; GroupMemberChangedEventTrigger gmceTrigger = (GroupMemberChangedEventTrigger) t;
Set<Rule> rules = changedEventTriggeredRules.get(GROUP_NAME_PREFIX + gmceTrigger.getGroup()); Set<Rule> rules = changedEventTriggeredRules.get(GROUP_NAME_PREFIX + gmceTrigger.getGroup());
if (rules == null) { if (rules == null) {
rules = new HashSet<Rule>(); rules = new HashSet<>();
changedEventTriggeredRules.put(GROUP_NAME_PREFIX + gmceTrigger.getGroup(), rules); changedEventTriggeredRules.put(GROUP_NAME_PREFIX + gmceTrigger.getGroup(), rules);
} }
rules.add(rule); rules.add(rule);
@ -629,7 +629,7 @@ public class RuleTriggerManager {
EventEmittedTrigger eeTrigger = (EventEmittedTrigger) t; EventEmittedTrigger eeTrigger = (EventEmittedTrigger) t;
Set<Rule> rules = triggerEventTriggeredRules.get(eeTrigger.getChannel()); Set<Rule> rules = triggerEventTriggeredRules.get(eeTrigger.getChannel());
if (rules == null) { if (rules == null) {
rules = new HashSet<Rule>(); rules = new HashSet<>();
triggerEventTriggeredRules.put(eeTrigger.getChannel(), rules); triggerEventTriggeredRules.put(eeTrigger.getChannel(), rules);
} }
rules.add(rule); rules.add(rule);
@ -637,7 +637,7 @@ public class RuleTriggerManager {
ThingStateUpdateEventTrigger tsuTrigger = (ThingStateUpdateEventTrigger) t; ThingStateUpdateEventTrigger tsuTrigger = (ThingStateUpdateEventTrigger) t;
Set<Rule> rules = thingUpdateEventTriggeredRules.get(tsuTrigger.getThing()); Set<Rule> rules = thingUpdateEventTriggeredRules.get(tsuTrigger.getThing());
if (rules == null) { if (rules == null) {
rules = new HashSet<Rule>(); rules = new HashSet<>();
thingUpdateEventTriggeredRules.put(tsuTrigger.getThing(), rules); thingUpdateEventTriggeredRules.put(tsuTrigger.getThing(), rules);
} }
rules.add(rule); rules.add(rule);
@ -645,7 +645,7 @@ public class RuleTriggerManager {
ThingStateChangedEventTrigger tscTrigger = (ThingStateChangedEventTrigger) t; ThingStateChangedEventTrigger tscTrigger = (ThingStateChangedEventTrigger) t;
Set<Rule> rules = thingChangedEventTriggeredRules.get(tscTrigger.getThing()); Set<Rule> rules = thingChangedEventTriggeredRules.get(tscTrigger.getThing());
if (rules == null) { if (rules == null) {
rules = new HashSet<Rule>(); rules = new HashSet<>();
thingChangedEventTriggeredRules.put(tscTrigger.getThing(), rules); thingChangedEventTriggeredRules.put(tscTrigger.getThing(), rules);
} }
rules.add(rule); rules.add(rule);
@ -734,7 +734,7 @@ public class RuleTriggerManager {
private void removeRules(TriggerTypes type, Collection<? extends Collection<Rule>> ruleSets, RuleModel model) { private void removeRules(TriggerTypes type, Collection<? extends Collection<Rule>> ruleSets, RuleModel model) {
for (Collection<Rule> ruleSet : ruleSets) { for (Collection<Rule> ruleSet : ruleSets) {
Set<Rule> clonedSet = new HashSet<Rule>(ruleSet); Set<Rule> clonedSet = new HashSet<>(ruleSet);
// first remove all rules of the model, if not null (=non-existent) // first remove all rules of the model, if not null (=non-existent)
if (model != null) { if (model != null) {
for (Rule newRule : model.getRules()) { for (Rule newRule : model.getRules()) {
@ -750,7 +750,7 @@ public class RuleTriggerManager {
} }
// now also remove all proxified rules from the set // now also remove all proxified rules from the set
clonedSet = new HashSet<Rule>(ruleSet); clonedSet = new HashSet<>(ruleSet);
for (Rule rule : clonedSet) { for (Rule rule : clonedSet) {
if (rule.eResource() == null) { if (rule.eResource() == null) {
ruleSet.remove(rule); ruleSet.remove(rule);

Some files were not shown because too many files have changed in this diff Show More