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

View File

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

View File

@ -58,7 +58,7 @@ public class ScriptFileWatcher extends AbstractWatchService {
private final long earliestStart = System.currentTimeMillis() + INITIAL_DELAY * 1000;
private ScriptEngineManager manager;
ScheduledExecutorService scheduler;
private ScheduledExecutorService scheduler;
private final Map<String, Set<URL>> urlsByScriptExtension = new ConcurrentHashMap<>();
private final Set<URL> loaded = new HashSet<>();
@ -204,7 +204,7 @@ public class ScriptFileWatcher extends AbstractWatchService {
synchronized (urlsByScriptExtension) {
Set<URL> set = urlsByScriptExtension.get(scriptType);
if (set == null) {
set = new HashSet<URL>();
set = new HashSet<>();
urlsByScriptExtension.put(scriptType, set);
}
set.add(url);
@ -267,7 +267,7 @@ public class ScriptFileWatcher extends AbstractWatchService {
});
synchronized (urlsByScriptExtension) {
HashSet<String> newlySupported = new HashSet<>();
Set<String> newlySupported = new HashSet<>();
for (String key : urlsByScriptExtension.keySet()) {
if (manager.isSupported(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.HashSet;
import java.util.Set;
import java.util.stream.Stream;
import org.eclipse.smarthome.core.common.registry.RegistryChangeListener;
@ -30,7 +31,7 @@ import org.openhab.core.automation.RuleRegistry;
public class RuleSupportRuleRegistryDelegate implements RuleRegistry {
private final RuleRegistry ruleRegistry;
private final HashSet<String> rules = new HashSet<>();
private final Set<String> rules = new HashSet<>();
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.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.smarthome.config.core.Configuration;
import org.openhab.core.automation.Action;
@ -48,9 +50,9 @@ public class ScriptedAutomationManager {
private final RuleSupportRuleRegistryDelegate ruleRegistryDelegate;
private final HashSet<String> modules = new HashSet<>();
private final HashSet<String> moduleHandlers = new HashSet<>();
private final HashSet<String> privateHandlers = new HashSet<>();
private final Set<String> modules = new HashSet<>();
private final Set<String> moduleHandlers = new HashSet<>();
private final Set<String> privateHandlers = new HashSet<>();
private final ScriptedCustomModuleHandlerFactory scriptedCustomModuleHandlerFactory;
private final ScriptedCustomModuleTypeProvider scriptedCustomModuleTypeProvider;
@ -88,17 +90,17 @@ public class ScriptedAutomationManager {
public void removeAll() {
logger.info("removeAll added handlers");
HashSet<String> types = new HashSet<>(modules);
Set<String> types = new HashSet<>(modules);
for (String moduleType : types) {
removeModuleType(moduleType);
}
HashSet<String> moduleHandlers = new HashSet<>(this.moduleHandlers);
Set<String> moduleHandlers = new HashSet<>(this.moduleHandlers);
for (String uid : moduleHandlers) {
removeHandler(uid);
}
HashSet<String> privateHandlers = new HashSet<>(this.privateHandlers);
Set<String> privateHandlers = new HashSet<>(this.privateHandlers);
for (String privId : privateHandlers) {
removePrivateHandler(privId);
}
@ -123,7 +125,7 @@ public class ScriptedAutomationManager {
int moduleIndex = 1;
try {
ArrayList<Condition> conditions = new ArrayList<>();
List<Condition> conditions = new ArrayList<>();
for (Condition cond : element.getConditions()) {
Condition toAdd = cond;
if (cond.getId().isEmpty()) {
@ -141,7 +143,7 @@ public class ScriptedAutomationManager {
}
try {
ArrayList<Trigger> triggers = new ArrayList<>();
List<Trigger> triggers = new ArrayList<>();
for (Trigger trigger : element.getTriggers()) {
Trigger toAdd = trigger;
if (trigger.getId().isEmpty()) {
@ -157,7 +159,7 @@ public class ScriptedAutomationManager {
// triggers are optional
}
ArrayList<Action> actions = new ArrayList<>();
List<Action> actions = new ArrayList<>();
actions.addAll(element.getActions());
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.Collection;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.smarthome.core.common.registry.ProviderChangeListener;
import org.openhab.core.automation.Rule;
@ -29,9 +30,9 @@ import org.osgi.service.component.annotations.Component;
*/
@Component(immediate = true, service = { ScriptedRuleProvider.class, RuleProvider.class })
public class ScriptedRuleProvider implements RuleProvider {
private final Collection<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
public void addProviderChangeListener(ProviderChangeListener<Rule> listener) {

View File

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

View File

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

View File

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

View File

@ -113,7 +113,7 @@ public class ItemRegistryDelegate implements Map<String, State> {
@Override
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()) {
entries.add(new AbstractMap.SimpleEntry<>(item.getName(), item.getState()));
}

View File

@ -54,7 +54,7 @@ public class ScriptActionHandler extends AbstractScriptModuleHandler<Action> imp
@Override
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 -> {
setExecutionContext(scriptEngine, context);

View File

@ -71,7 +71,7 @@ public class ScriptModuleTypeProvider implements ModuleTypeProvider {
if (parameterOptions.isEmpty()) {
return null;
} 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);
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) {
final Locale locale = localeService.getLocale(language);
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")) {
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.openhab.core.automation.Action;
import org.openhab.core.automation.dto.ActionDTO;
import org.openhab.core.automation.util.ModuleBuilder;
/**
@ -46,7 +45,7 @@ public class ActionDTOMapper extends ModuleDTOMapper {
if (actions == null) {
return null;
}
final List<ActionDTO> dtos = new ArrayList<ActionDTO>(actions.size());
final List<ActionDTO> dtos = new ArrayList<>(actions.size());
for (final Action action : actions) {
dtos.add(map(action));
}
@ -57,7 +56,7 @@ public class ActionDTOMapper extends ModuleDTOMapper {
if (dtos == null) {
return null;
}
final List<Action> actions = new ArrayList<Action>(dtos.size());
final List<Action> actions = new ArrayList<>(dtos.size());
for (final ActionDTO dto : dtos) {
actions.add(mapDto(dto));
}

View File

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

View File

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

View File

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

View File

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

View File

@ -17,8 +17,6 @@ import java.util.Collection;
import java.util.List;
import org.eclipse.smarthome.config.core.dto.ConfigDescriptionDTOMapper;
import org.openhab.core.automation.dto.CompositeTriggerTypeDTO;
import org.openhab.core.automation.dto.TriggerTypeDTO;
import org.openhab.core.automation.type.CompositeTriggerType;
import org.openhab.core.automation.type.TriggerType;
@ -57,7 +55,7 @@ public class TriggerTypeDTOMapper extends ModuleTypeDTOMapper {
if (types == null) {
return null;
}
final List<TriggerTypeDTO> dtos = new ArrayList<TriggerTypeDTO>(types.size());
final List<TriggerTypeDTO> dtos = new ArrayList<>(types.size());
for (final TriggerType type : types) {
if (type instanceof CompositeTriggerType) {
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
* {@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
* 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
@ -251,8 +251,8 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
@Activate
public RuleEngineImpl(final Config config, final @Reference ModuleTypeRegistry moduleTypeRegistry,
final @Reference RuleRegistry ruleRegistry, final @Reference StorageService storageService) {
this.contextMap = new HashMap<String, Map<String, Object>>();
this.moduleHandlerFactories = new HashMap<String, ModuleHandlerFactory>(20);
this.contextMap = new HashMap<>();
this.moduleHandlerFactories = new HashMap<>(20);
this.disabledRulesStorage = storageService.<Boolean> getStorage(DISABLED_RULE_STORAGE,
this.getClass().getClassLoader());
@ -334,7 +334,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
synchronized (this) {
Set<String> rulesPerModule = mapModuleTypeToRules.get(moduleTypeName);
if (rulesPerModule != null) {
rules = new HashSet<String>();
rules = new HashSet<>();
rules.addAll(rulesPerModule);
}
}
@ -363,7 +363,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
synchronized (this) {
Set<String> rulesPerModule = mapModuleTypeToRules.get(moduleTypeName);
if (rulesPerModule != null) {
rules = new HashSet<String>();
rules = new HashSet<>();
rules.addAll(rulesPerModule);
}
}
@ -400,7 +400,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
moduleHandlerFactories.put(moduleTypeName, moduleHandlerFactory);
Set<String> rulesPerModule = mapModuleTypeToRules.get(moduleTypeName);
if (rulesPerModule != null) {
rules = new HashSet<String>();
rules = new HashSet<>();
rules.addAll(rulesPerModule);
}
}
@ -408,8 +408,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
for (String rUID : rules) {
RuleStatus ruleStatus = getRuleStatus(rUID);
if (ruleStatus == RuleStatus.UNINITIALIZED) {
notInitializedRules = notInitializedRules != null ? notInitializedRules
: new HashSet<String>(20);
notInitializedRules = notInitializedRules != null ? notInitializedRules : new HashSet<>(20);
notInitializedRules.add(rUID);
}
}
@ -743,7 +742,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
public synchronized void updateMapModuleTypeToRule(String rUID, String moduleTypeId) {
Set<String> rules = mapModuleTypeToRules.get(moduleTypeId);
if (rules == null) {
rules = new HashSet<String>(11);
rules = new HashSet<>(11);
}
rules.add(rUID);
mapModuleTypeToRules.put(moduleTypeId, rules);
@ -933,11 +932,10 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
switch (ruleStatus) {
case RUNNING:
case IDLE:
mapMissingHandlers = mapMissingHandlers != null ? mapMissingHandlers
: new HashMap<String, List<String>>(20);
mapMissingHandlers = mapMissingHandlers != null ? mapMissingHandlers : new HashMap<>(20);
List<String> list = mapMissingHandlers.get(rUID);
if (list == null) {
list = new ArrayList<String>(5);
list = new ArrayList<>(5);
}
list.add(moduleTypeName);
mapMissingHandlers.put(rUID, list);
@ -1101,7 +1099,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
@NonNullByDefault({})
Map<String, Object> context = contextMap.get(ruleUID);
if (context == null) {
context = new HashMap<String, Object>();
context = new HashMap<>();
contextMap.put(ruleUID, context);
}
if (connections != null) {
@ -1264,7 +1262,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
* @param rule updated 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()) {
final Trigger t = mt.unwrap();
TriggerType tt = (TriggerType) mtRegistry.get(t.getTypeUID());
@ -1272,7 +1270,7 @@ public class RuleEngineImpl implements RuleManager, RegistryChangeListener<Modul
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()) {
final Action a = ma.unwrap();
ActionType at = (ActionType) mtRegistry.get(a.getTypeUID());

View File

@ -258,13 +258,11 @@ public class RuleImpl implements Rule {
@Override
public List<Module> getModules() {
final List<Module> result;
List<Module> modules = new ArrayList<Module>();
List<Module> modules = new ArrayList<>();
modules.addAll(triggers);
modules.addAll(conditions);
modules.addAll(actions);
result = Collections.unmodifiableList(modules);
return result;
return Collections.unmodifiableList(modules);
}
@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.
*/
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
@ -292,7 +292,7 @@ public class RuleRegistryImpl extends AbstractRegistry<Rule, String, RuleProvide
@Override
public Collection<Rule> getByTag(String tag) {
Collection<Rule> result = new LinkedList<Rule>();
Collection<Rule> result = new LinkedList<>();
if (tag == null) {
forEach(result::add);
} else {
@ -307,8 +307,8 @@ public class RuleRegistryImpl extends AbstractRegistry<Rule, String, RuleProvide
@Override
public Collection<Rule> getByTags(String... tags) {
Set<String> tagSet = tags != null ? new HashSet<String>(Arrays.asList(tags)) : null;
Collection<Rule> result = new LinkedList<Rule>();
Set<String> tagSet = tags != null ? new HashSet<>(Arrays.asList(tags)) : null;
Collection<Rule> result = new LinkedList<>();
if (tagSet == null || tagSet.isEmpty()) {
forEach(result::add);
} else {
@ -364,7 +364,7 @@ public class RuleRegistryImpl extends AbstractRegistry<Rule, String, RuleProvide
synchronized (this) {
Set<String> ruleUIDs = mapTemplateToRules.get(templateUID);
if (ruleUIDs == null) {
ruleUIDs = new HashSet<String>();
ruleUIDs = new HashSet<>();
mapTemplateToRules.put(templateUID, ruleUIDs);
}
if (resolved) {
@ -615,7 +615,7 @@ public class RuleRegistryImpl extends AbstractRegistry<Rule, String, RuleProvide
@Override
public void added(RuleTemplate element) {
String templateUID = element.getUID();
Set<String> rules = new HashSet<String>();
Set<String> rules = new HashSet<>();
synchronized (this) {
Set<String> rulesForResolving = mapTemplateToRules.get(templateUID);
if (rulesForResolving != null) {

View File

@ -59,7 +59,7 @@ public abstract class AbstractCommandProvider<E> implements ServiceTrackerCustom
* <p>
* 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.
@ -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
* 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
@ -79,7 +79,7 @@ public abstract class AbstractCommandProvider<E> implements ServiceTrackerCustom
* <p>
* 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;

View File

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

View File

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

View File

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

View File

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

View File

@ -40,7 +40,7 @@ public class Utils {
* @return an indexed UIDs of the automation objects.
*/
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++) {
sorted.put(new Integer(i + 1).toString(), strings[i]);
}
@ -57,7 +57,7 @@ public class Utils {
* @return filtered list with UIDs of the objects.
*/
static Map<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()) {
final String id = entry.getKey();
final String uid = entry.getValue();
@ -133,7 +133,7 @@ public class Utils {
* @return a string representing the title of the table.
*/
static List<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(titleRow);
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
*/
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());
return result;
}

View File

@ -62,7 +62,7 @@ public class CompositeActionHandler extends AbstractCompositeModuleHandler<Actio
*/
@Override
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 Map<String, Object> compositeContext = getCompositeContext(context);
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
*/
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) {
for (Output output : outputs) {
String refs = output.getReference();

View File

@ -172,7 +172,7 @@ public class CompositeModuleHandlerFactory extends BaseModuleHandlerFactory impl
@SuppressWarnings("unchecked")
private <T extends Module, MT extends ModuleHandler> LinkedHashMap<T, MT> getChildHandlers(String compositeModuleId,
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) {
String ruleId = getRuleId(childModulePrefix);
ruleEngine.updateMapModuleTypeToRule(ruleId, child.getTypeUID());

View File

@ -70,7 +70,7 @@ public class CompositeTriggerHandler
public void triggered(Trigger trigger, Map<String, ?> context) {
if (callback != null) {
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) {
String refs = output.getReference();
if (refs != null) {

View File

@ -160,7 +160,7 @@ public class CompareConditionHandler extends BaseConditionModuleHandler {
return rightOperandString2;
}
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());
return TypeParser.parseState(stateTypeList, rightOperandString2);
} else if (toCompare instanceof Integer) {

View File

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

View File

@ -64,7 +64,7 @@ public class ItemCommandTriggerHandler extends BaseTriggerModuleHandler implemen
this.command = (String) module.getConfiguration().get(CFG_COMMAND);
this.types = Collections.singleton(ItemCommandEvent.TYPE);
this.bundleContext = bundleContext;
Dictionary<String, Object> properties = new Hashtable<String, Object>();
Dictionary<String, Object> properties = new Hashtable<>();
this.topic = "smarthome/items/" + itemName + "/command";
properties.put("event.topics", topic);
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())) {
this.types = Collections.singleton(ItemStateEvent.TYPE);
} else {
HashSet<String> set = new HashSet<>();
Set<String> set = new HashSet<>();
set.add(ItemStateChangedEvent.TYPE);
set.add(GroupItemStateChangedEvent.TYPE);
this.types = Collections.unmodifiableSet(set);
}
this.bundleContext = bundleContext;
Dictionary<String, Object> properties = new Hashtable<String, Object>();
Dictionary<String, Object> properties = new Hashtable<>();
properties.put("event.topics", "smarthome/items/" + itemName + "/*");
eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this,
properties);

View File

@ -83,11 +83,11 @@ public class ModuleTypeGSONParser extends AbstractGSONParser<ModuleType> {
}
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<ConditionType> conditions = new ArrayList<ConditionType>();
List<ActionType> actions = new ArrayList<ActionType>();
List<TriggerType> triggers = new ArrayList<>();
List<ConditionType> conditions = new ArrayList<>();
List<ActionType> actions = new ArrayList<>();
for (ModuleType moduleType : dataObjects) {
if (moduleType instanceof TriggerType) {
triggers.add((TriggerType) moduleType);

View File

@ -71,11 +71,11 @@ public abstract class AbstractResourceBundleProvider<E> {
public AbstractResourceBundleProvider() {
logger = LoggerFactory.getLogger(this.getClass());
providedObjectsHolder = new ConcurrentHashMap<String, E>();
providerPortfolio = new ConcurrentHashMap<Vendor, List<String>>();
queue = new AutomationResourceBundlesEventQueue<E>(this);
parsers = new ConcurrentHashMap<String, Parser<E>>();
waitingProviders = new ConcurrentHashMap<Bundle, List<URL>>();
providedObjectsHolder = new ConcurrentHashMap<>();
providerPortfolio = new ConcurrentHashMap<>();
queue = new AutomationResourceBundlesEventQueue<>(this);
parsers = new ConcurrentHashMap<>();
waitingProviders = new ConcurrentHashMap<>();
}
/**
@ -259,7 +259,7 @@ public abstract class AbstractResourceBundleProvider<E> {
}
Vendor vendor = new Vendor(bundle.getSymbolicName(), bundle.getVersion().toString());
List<String> previousPortfolio = getPreviousPortfolio(vendor);
List<String> newPortfolio = new LinkedList<String>();
List<String> newPortfolio = new LinkedList<>();
if (urlEnum != null) {
while (urlEnum.hasMoreElements()) {
URL url = urlEnum.nextElement();
@ -290,7 +290,7 @@ public abstract class AbstractResourceBundleProvider<E> {
if (listeners != null) {
List<ProviderChangeListener<E>> snapshot = null;
synchronized (listeners) {
snapshot = new LinkedList<ProviderChangeListener<E>>(listeners);
snapshot = new LinkedList<>(listeners);
}
for (ProviderChangeListener<E> listener : snapshot) {
listener.removed((Provider<E>) this, removedObject);
@ -359,7 +359,7 @@ public abstract class AbstractResourceBundleProvider<E> {
if (listeners != null) {
List<ProviderChangeListener<E>> snapshot = null;
synchronized (listeners) {
snapshot = new LinkedList<ProviderChangeListener<E>>(listeners);
snapshot = new LinkedList<>(listeners);
}
for (ProviderChangeListener<E> listener : snapshot) {
listener.removed((Provider<E>) this, removedObject);
@ -397,7 +397,7 @@ public abstract class AbstractResourceBundleProvider<E> {
protected List<ConfigDescriptionParameter> getLocalizedConfigurationDescription(TranslationProvider i18nProvider,
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) {
ConfigDescriptionI18nUtil util = new ConfigDescriptionI18nUtil(i18nProvider);
for (ConfigDescriptionParameter parameter : config) {
@ -494,7 +494,7 @@ public abstract class AbstractResourceBundleProvider<E> {
Set<E> parsedObjects) {
List<ProviderChangeListener<E>> snapshot = null;
synchronized (listeners) {
snapshot = new LinkedList<ProviderChangeListener<E>>(listeners);
snapshot = new LinkedList<>(listeners);
}
for (E parsedObject : parsedObjects) {
String uid = getUID(parsedObject);
@ -521,7 +521,7 @@ public abstract class AbstractResourceBundleProvider<E> {
List<URL> urlList = waitingProviders.get(bundle);
if (parser == null) {
if (urlList == null) {
urlList = new ArrayList<URL>();
urlList = new ArrayList<>();
}
urlList.add(url);
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
* processing completes.
*/
private List<BundleEvent> queue = new ArrayList<BundleEvent>();
private List<BundleEvent> queue = new ArrayList<>();
/**
* This field is for synchronization purposes
@ -173,7 +173,7 @@ public class AutomationResourceBundlesEventQueue<E> implements Runnable {
return;
}
if (shared) {
queue = new LinkedList<BundleEvent>();
queue = new LinkedList<>();
shared = false;
}
if (queue.add(event)) {
@ -231,7 +231,7 @@ public class AutomationResourceBundlesEventQueue<E> implements Runnable {
return;
}
if (shared) {
this.queue = new LinkedList<BundleEvent>();
this.queue = new LinkedList<>();
shared = false;
}
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.
*/
@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.
@ -68,7 +68,7 @@ public class AutomationResourceBundlesTracker implements BundleTrackerCustomizer
* This field serves for saving the BundleEvents for the bundles providing automation resources until their
* processing completes. The events have been for adding, modifying or removing a bundle.
*/
private final List<BundleEvent> queue = new LinkedList<BundleEvent>();
private final List<BundleEvent> queue = new LinkedList<>();
public AutomationResourceBundlesTracker() {
rImporter = createImporter();
@ -80,7 +80,7 @@ public class AutomationResourceBundlesTracker implements BundleTrackerCustomizer
@Activate
protected void activate(BundleContext bc) {
bTracker = new BundleTracker<Bundle>(bc, ~Bundle.UNINSTALLED, this);
bTracker = new BundleTracker<>(bc, ~Bundle.UNINSTALLED, this);
bTracker.open();
}

View File

@ -29,7 +29,7 @@ import org.osgi.service.packageadmin.PackageAdmin;
@SuppressWarnings("deprecation")
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;
@ -49,7 +49,7 @@ public class HostFragmentMappingUtil {
* @return a list with the hosts of the <code>fragment</code> parameter.
*/
static List<Bundle> returnHostBundles(Bundle fragment) {
List<Bundle> hosts = new ArrayList<Bundle>();
List<Bundle> hosts = new ArrayList<>();
Bundle[] bundles = pkgAdmin.getHosts(fragment);
if (bundles != null) {
hosts = Arrays.asList(bundles);
@ -64,7 +64,7 @@ public class HostFragmentMappingUtil {
}
static List<Bundle> fillHostFragmentMapping(Bundle host) {
List<Bundle> fragments = new ArrayList<Bundle>();
List<Bundle> fragments = new ArrayList<>();
Bundle[] bundles = pkgAdmin.getFragments(host);
if (bundles != null) {
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.
*/
public ModuleTypeResourceBundleProvider() {
listeners = new LinkedList<ProviderChangeListener<ModuleType>>();
listeners = new LinkedList<>();
path = ROOT_DIRECTORY + "/moduletypes/";
}
@ -135,7 +135,7 @@ public class ModuleTypeResourceBundleProvider extends AbstractResourceBundleProv
*/
@Override
public Collection<ModuleType> getModuleTypes(Locale locale) {
List<ModuleType> moduleTypesList = new ArrayList<ModuleType>();
List<ModuleType> moduleTypesList = new ArrayList<>();
for (ModuleType mt : providedObjectsHolder.values()) {
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.
*/
public TemplateResourceBundleProvider() {
listeners = new LinkedList<ProviderChangeListener<RuleTemplate>>();
listeners = new LinkedList<>();
path = ROOT_DIRECTORY + "/templates/";
}
@ -141,7 +141,7 @@ public class TemplateResourceBundleProvider extends AbstractResourceBundleProvid
*/
@Override
public Collection<RuleTemplate> getTemplates(Locale locale) {
ArrayList<RuleTemplate> templatesList = new ArrayList<RuleTemplate>();
List<RuleTemplate> templatesList = new ArrayList<>();
for (RuleTemplate t : providedObjectsHolder.values()) {
templatesList.add(getPerLocale(t, locale));
}

View File

@ -62,25 +62,25 @@ public abstract class AbstractFileProvider<E> implements Provider<E> {
* <p>
* 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
* 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
* 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.
*/
private final Map<String, List<URL>> urls = new ConcurrentHashMap<String, List<URL>>();
private final List<ProviderChangeListener<E>> listeners = new ArrayList<ProviderChangeListener<E>>();
private final Map<String, List<URL>> urls = new ConcurrentHashMap<>();
private final List<ProviderChangeListener<E>> listeners = new ArrayList<>();
public AbstractFileProvider(String root) {
this.rootSubdirectory = root;
@ -250,7 +250,7 @@ public abstract class AbstractFileProvider<E> implements Provider<E> {
synchronized (urls) {
List<URL> value = urls.get(parserType);
if (value == null) {
value = new ArrayList<URL>();
value = new ArrayList<>();
urls.put(parserType, value);
}
value.add(url);
@ -261,7 +261,7 @@ public abstract class AbstractFileProvider<E> implements Provider<E> {
protected void updateProvidedObjectsHolder(URL url, Set<E> providedObjects) {
if (providedObjects != null && !providedObjects.isEmpty()) {
List<String> uids = new ArrayList<String>();
List<String> uids = new ArrayList<>();
for (E providedObject : providedObjects) {
String uid = getUID(providedObject);
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) {
Collection<ModuleType> values = providedObjectsHolder.values();
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()) {
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")
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) {
AutomationWatchService aws = null;
synchronized (WATCH_SERVICES) {
Map<String, AutomationWatchService> watchers = WATCH_SERVICES.get(provider);
if (watchers == null) {
watchers = new HashMap<String, AutomationWatchService>();
watchers = new HashMap<>();
WATCH_SERVICES.put(provider, watchers);
}
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,
Bundle bundle, String uid, String prefix, Locale locale) {
List<T> lmodules = new ArrayList<T>();
List<T> lmodules = new ArrayList<>();
for (T module : modules) {
String label = getModuleLabel(i18nProvider, bundle, uid, module.getId(), module.getLabel(), prefix, locale);
String description = getModuleDescription(i18nProvider, bundle, uid, prefix, module.getId(),

View File

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

View File

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

View File

@ -80,7 +80,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override
@SuppressWarnings("unchecked")
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) -> {
ModuleType mt = locale == null ? mType
: ((ModuleTypeProvider) provider).getModuleType(mType.getUID(), locale);
@ -102,8 +102,8 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override
@SuppressWarnings("unchecked")
public <T extends ModuleType> Collection<T> getByTags(Locale locale, String... tags) {
Set<String> tagSet = tags != null ? new HashSet<String>(Arrays.asList(tags)) : null;
Collection<T> result = new ArrayList<T>(20);
Set<String> tagSet = tags != null ? new HashSet<>(Arrays.asList(tags)) : null;
Collection<T> result = new ArrayList<>(20);
forEach((provider, mType) -> {
ModuleType mt = locale == null ? mType
: ((ModuleTypeProvider) provider).getModuleType(mType.getUID(), locale);
@ -119,7 +119,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override
public Collection<TriggerType> getTriggers(Locale locale, String... tags) {
Collection<ModuleType> moduleTypes = getByTags(locale, tags);
Collection<TriggerType> triggerTypes = new ArrayList<TriggerType>();
Collection<TriggerType> triggerTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) {
if (mt instanceof TriggerType) {
triggerTypes.add((TriggerType) mt);
@ -131,7 +131,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override
public Collection<TriggerType> getTriggers(String... tags) {
Collection<ModuleType> moduleTypes = getByTags(tags);
Collection<TriggerType> triggerTypes = new ArrayList<TriggerType>();
Collection<TriggerType> triggerTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) {
if (mt instanceof TriggerType) {
triggerTypes.add((TriggerType) mt);
@ -143,7 +143,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override
public Collection<ConditionType> getConditions(String... tags) {
Collection<ModuleType> moduleTypes = getByTags(tags);
Collection<ConditionType> conditionTypes = new ArrayList<ConditionType>();
Collection<ConditionType> conditionTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) {
if (mt instanceof ConditionType) {
conditionTypes.add((ConditionType) mt);
@ -155,7 +155,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override
public Collection<ConditionType> getConditions(Locale locale, String... tags) {
Collection<ModuleType> moduleTypes = getByTags(locale, tags);
Collection<ConditionType> conditionTypes = new ArrayList<ConditionType>();
Collection<ConditionType> conditionTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) {
if (mt instanceof ConditionType) {
conditionTypes.add((ConditionType) mt);
@ -167,7 +167,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override
public Collection<ActionType> getActions(String... tags) {
Collection<ModuleType> moduleTypes = getByTags(tags);
Collection<ActionType> actionTypes = new ArrayList<ActionType>();
Collection<ActionType> actionTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) {
if (mt instanceof ActionType) {
actionTypes.add((ActionType) mt);
@ -179,7 +179,7 @@ public class ModuleTypeRegistryImpl extends AbstractRegistry<ModuleType, String,
@Override
public Collection<ActionType> getActions(Locale locale, String... tags) {
Collection<ModuleType> moduleTypes = getByTags(locale, tags);
Collection<ActionType> actionTypes = new ArrayList<ActionType>();
Collection<ActionType> actionTypes = new ArrayList<>();
for (ModuleType mt : moduleTypes) {
if (mt instanceof ActionType) {
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.openhab.core.automation.Module;
import org.openhab.core.automation.RuleRegistry;
import org.openhab.core.automation.internal.ModuleImpl;
import org.openhab.core.automation.internal.RuleImpl;
import org.openhab.core.automation.type.ModuleType;
import org.openhab.core.automation.type.ModuleTypeRegistry;
@ -60,7 +62,7 @@ public class ConfigurationNormalizer {
*/
public static Map<String, ConfigDescriptionParameter> getConfigDescriptionMap(
List<ConfigDescriptionParameter> configDesc) {
Map<String, ConfigDescriptionParameter> mapConfigDescs = new HashMap<String, ConfigDescriptionParameter>();
Map<String, ConfigDescriptionParameter> mapConfigDescs = new HashMap<>();
for (ConfigDescriptionParameter configDescriptionParameter : configDesc) {
mapConfigDescs.put(configDescriptionParameter.getName(), configDescriptionParameter);
}

View File

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

View File

@ -112,7 +112,7 @@ public class RuleBuilder {
public RuleBuilder withTriggers(@Nullable List<? extends Trigger> triggers) {
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()));
this.triggers = triggerList;
}
@ -125,7 +125,7 @@ public class RuleBuilder {
public RuleBuilder withConditions(@Nullable List<? extends Condition> conditions) {
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()));
this.conditions = conditionList;
}
@ -138,7 +138,7 @@ public class RuleBuilder {
public RuleBuilder withActions(@Nullable List<? extends Action> actions) {
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()));
this.actions = actionList;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -99,13 +99,13 @@ public class ConfigDescription implements Identifiable<URI> {
if (parameters != null) {
this.parameters = Collections.unmodifiableList(parameters);
} else {
this.parameters = Collections.unmodifiableList(new ArrayList<ConfigDescriptionParameter>(0));
this.parameters = Collections.unmodifiableList(new ArrayList<>(0));
}
if (groups != null) {
this.parameterGroups = Collections.unmodifiableList(groups);
} 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 description;
private List<ParameterOption> options = new ArrayList<ParameterOption>();
private List<FilterCriteria> filterCriteria = new ArrayList<FilterCriteria>();
private List<ParameterOption> options = new ArrayList<>();
private List<FilterCriteria> filterCriteria = new ArrayList<>();
private boolean limitToOptions = true;
private boolean advanced = false;
private boolean verify = false;
private static final Set<String> UNITS = Collections
.unmodifiableSet(new HashSet<String>(Arrays.asList("A", "cd", "K", "kg", "m", "mol", "s", "g", "rad", "sr",
"Hz", "N", "Pa", "J", "W", "C", "V", "F", "Ω", "S", "Wb", "T", "H", "Cel", "lm", "lx", "Bq", "Gy",
"Sv", "kat", "m/s2", "m2v", "m3", "kph", "%", "l", "ms", "min", "h", "d", "week", "y")));
.unmodifiableSet(new HashSet<>(Arrays.asList("A", "cd", "K", "kg", "m", "mol", "s", "g", "rad", "sr", "Hz",
"N", "Pa", "J", "W", "C", "V", "F", "Ω", "S", "Wb", "T", "H", "Cel", "lm", "lx", "Bq", "Gy", "Sv",
"kat", "m/s2", "m2v", "m3", "kph", "%", "l", "ms", "min", "h", "d", "week", "y")));
/**
* Default constructor.
@ -239,12 +239,12 @@ public class ConfigDescriptionParameter {
if (options != null) {
this.options = Collections.unmodifiableList(options);
} else {
this.options = Collections.unmodifiableList(new LinkedList<ParameterOption>());
this.options = Collections.unmodifiableList(new LinkedList<>());
}
if (filterCriteria != null) {
this.filterCriteria = Collections.unmodifiableList(filterCriteria);
} else {
this.filterCriteria = Collections.unmodifiableList(new LinkedList<FilterCriteria>());
this.filterCriteria = Collections.unmodifiableList(new LinkedList<>());
}
}
@ -320,8 +320,12 @@ public class ConfigDescriptionParameter {
/**
* Returns the context of the configuration parameter.
* <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>
* <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.
* - password: A password value (a user-interface might obscure the visible value)
@ -329,14 +333,16 @@ public class ConfigDescriptionParameter {
* - color: This value represents an RGB color value like #ffffff or 12,12,12.
* - date: A date string
* - time: A time string
* - cronexpression: A cron expression like "* * * * *". A user interface would probably show a cron expression generator.
* - cronexpression: A cron expression like "* * * * *". A user interface would probably show a cron expression
* generator.
* - datetime: A date and time string
* - email: The configuration value represents an email address
* - month: A number [1-12]
* - week: A week [0-52]
* - tel: A tel no
* - url: A web address
* - script: The configuration value represents a script (javascript, python etc). A user-interface would probably render a multi line editor.
* - script: The configuration value represents a script (javascript, python etc). A user-interface would probably
* render a multi line editor.
* - location: A lat,long,alt GPS location. A user-interface would probably render a world map for selection.
* - tag: One tag or multiple tags separated by comma.
* - item: A valid item "name". A user-interface would probably show an item selection widget.

View File

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

View File

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

View File

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

View File

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

View File

@ -16,6 +16,7 @@ import java.net.Inet4Address;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -50,7 +51,7 @@ public class NetworkConfigOptionProvider implements ConfigOptionProvider {
}
if (param.equals(PARAM_BROADCAST_ADDRESS)) {
ArrayList<String> broadcastAddrList = new ArrayList<>(NetUtil.getAllBroadcastAddresses());
List<String> broadcastAddrList = new ArrayList<>(NetUtil.getAllBroadcastAddresses());
broadcastAddrList.add("255.255.255.255");
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;
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.TEXT, new TextNormalizer());
map.put(Type.INTEGER, new IntNormalizer());

View File

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

View File

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

View File

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

View File

@ -386,7 +386,7 @@ public final class PersistentInbox implements Inbox, DiscoveryListener, ThingReg
@Override
public @Nullable Collection<ThingUID> removeOlderResults(DiscoveryService source, long timestamp,
@Nullable Collection<ThingTypeUID> thingTypeUIDs, @Nullable ThingUID bridgeUID) {
HashSet<ThingUID> removedThings = new HashSet<>();
Set<ThingUID> removedThings = new HashSet<>();
for (DiscoveryResult discoveryResult : getAll()) {
Class<?> discoverer = resultDiscovererMap.get(discoveryResult);
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
// 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
Map<Configuration, Dictionary> configMap = new HashMap<Configuration, Dictionary>();
Map<Configuration, Dictionary> configMap = new HashMap<>();
String pid = pidFromFilename(configFile);
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);
if (objects == null) {
objects = new CopyOnWriteArrayList<T_OBJECT>();
objects = new CopyOnWriteArrayList<>();
bundleObjectMap.put(bundle, objects);
}
return objects;

View File

@ -66,8 +66,7 @@ public class ConfigDescriptionConverter extends GenericUnmarshaller<ConfigDescri
URI uri = null;
if (uriText == null) {
throw new ConversionException(
"No URI provided");
throw new ConversionException("No URI provided");
}
try {
@ -78,8 +77,8 @@ public class ConfigDescriptionConverter extends GenericUnmarshaller<ConfigDescri
}
// create the lists to hold parameters and groups
List<ConfigDescriptionParameter> configDescriptionParams = new ArrayList<ConfigDescriptionParameter>();
List<ConfigDescriptionParameterGroup> configDescriptionGroups = new ArrayList<ConfigDescriptionParameterGroup>();
List<ConfigDescriptionParameter> configDescriptionParams = new ArrayList<>();
List<ConfigDescriptionParameterGroup> configDescriptionGroups = new ArrayList<>();
// read values
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}
*/
private Collection<URL> filterPatches(Enumeration<URL> xmlDocumentPaths, Bundle bundle) {
List<URL> hostResources = new ArrayList<URL>();
List<URL> fragmentResources = new ArrayList<URL>();
List<URL> hostResources = new ArrayList<>();
List<URL> fragmentResources = new ArrayList<>();
while (xmlDocumentPaths.hasMoreElements()) {
URL path = xmlDocumentPaths.nextElement();
@ -310,7 +310,7 @@ public class XmlDocumentBundleTracker<T> extends BundleTracker<Bundle> {
}
}
if (!fragmentResources.isEmpty()) {
Map<String, URL> helper = new HashMap<String, URL>();
Map<String, URL> helper = new HashMap<>();
for (URL url : hostResources) {
helper.put(url.getPath(), url);
}

View File

@ -46,7 +46,7 @@ public class ConsoleSupportEclipse implements CommandProvider {
private static final String BASE = "smarthome";
private final SortedMap<String, ConsoleCommandExtension> consoleCommandExtensions = Collections
.synchronizedSortedMap(new TreeMap<String, ConsoleCommandExtension>());
.synchronizedSortedMap(new TreeMap<>());
public ConsoleSupportEclipse() {
}
@ -90,7 +90,7 @@ public class ConsoleSupportEclipse implements CommandProvider {
console.println(String.format("No handler for command '%s' was found.", cmd));
} else {
// Build argument list
final List<String> argsList = new ArrayList<String>();
final List<String> argsList = new ArrayList<>();
while (true) {
final String narg = interpreter.nextArgument();
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.
*/
private final Map<ConsoleCommandExtension, ServiceRegistration<?>> commands = Collections
.synchronizedMap(new HashMap<ConsoleCommandExtension, ServiceRegistration<?>>());
.synchronizedMap(new HashMap<>());
public ConsoleSupportRfc147() {
// 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 */
public static List<String> getUsages(Collection<ConsoleCommandExtension> consoleCommandExtensions) {
List<String> usages = new ArrayList<String>();
List<String> usages = new ArrayList<>();
for (ConsoleCommandExtension consoleCommandExtension : consoleCommandExtensions) {
usages.addAll(consoleCommandExtension.getUsages());
}

View File

@ -54,7 +54,7 @@ public abstract class BaseSmartHomeServlet extends HttpServlet {
try {
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);
} catch (NamespaceException 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) {
Dictionary<String, Object> properties = configuration.getProperties();
return properties != null ? properties : new Hashtable<String, Object>();
return properties != null ? properties : new Hashtable<>();
}
@Reference

View File

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

View File

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

View File

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

View File

@ -91,7 +91,7 @@ public class MDNSAnnouncer {
}
private ServiceDescription getDefaultServiceDescription() {
Hashtable<String, String> serviceProperties = new Hashtable<String, String>();
Hashtable<String, String> serviceProperties = new Hashtable<>();
serviceProperties.put("uri", RESTConstants.REST_URI);
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) {
EList<Widget> widgets = new BasicEList<Widget>();
EList<Widget> widgets = new BasicEList<>();
Sitemap sitemap = getSitemap(sitemapName);
if (sitemap != null) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -59,7 +59,7 @@ public class RootResource {
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;

View File

@ -25,7 +25,7 @@ public class RootBean {
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 Links(String type, String url) {

View File

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

View File

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

View File

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

View File

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

View File

@ -121,7 +121,7 @@ public class ModelRepositoryImpl implements ModelRepository {
resource = resourceSet.createResource(URI.createURI(name));
if (resource != null) {
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");
if (inputStream == null) {
logger.warn(
@ -178,7 +178,7 @@ public class ModelRepositoryImpl implements ModelRepository {
public Iterable<String> getAllModelNamesOfType(final String modelType) {
synchronized (resourceSet) {
// 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 input != null && input.getURI().lastSegment().contains(".") && input.isLoaded()
@ -193,7 +193,7 @@ public class ModelRepositoryImpl implements ModelRepository {
public void reloadAllModelsOfType(final String modelType) {
synchronized (resourceSet) {
// Make a copy to avoid ConcurrentModificationException
List<Resource> resourceListCopy = new ArrayList<Resource>(resourceSet.getResources());
List<Resource> resourceListCopy = new ArrayList<>(resourceSet.getResources());
for (Resource resource : resourceListCopy) {
if (resource != null && resource.getURI().lastSegment().contains(".") && resource.isLoaded()) {
if (modelType.equalsIgnoreCase(resource.getURI().fileExtension())) {
@ -215,7 +215,7 @@ public class ModelRepositoryImpl implements ModelRepository {
Set<String> ret = new HashSet<>();
synchronized (resourceSet) {
// 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) {
if (resource != null && resource.getURI().lastSegment().contains(".") && resource.isLoaded()) {
if (modelType.equalsIgnoreCase(resource.getURI().fileExtension())) {

View File

@ -68,7 +68,7 @@ public class FolderObserver extends AbstractWatchService {
private ModelRepository modelRepo = null;
/* map that stores a list of valid file extensions for each folder */
private final Map<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 */
private final Set<String> parsers = new HashSet<>();
@ -144,7 +144,7 @@ public class FolderObserver extends AbstractWatchService {
}
private void processIgnoredFiles(String extension) {
HashSet<File> clonedSet = new HashSet<>(this.ignoredFiles);
Set<File> clonedSet = new HashSet<>(this.ignoredFiles);
for (File file : clonedSet) {
if (extension.equals(getExtension(file.getPath()))) {
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);
/** 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;
@ -83,7 +83,7 @@ public class GenericItemProvider extends AbstractProvider<Item>
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<>();
@ -160,7 +160,7 @@ public class GenericItemProvider extends AbstractProvider<Item>
@Override
public Collection<Item> getAll() {
List<Item> items = new ArrayList<Item>();
List<Item> items = new ArrayList<>();
stateDescriptionFragments.clear();
for (String name : modelRepository.getAllModelNamesOfType("items")) {
items.addAll(getItemsFromModel(name));
@ -171,7 +171,7 @@ public class GenericItemProvider extends AbstractProvider<Item>
private Collection<Item> getItemsFromModel(String 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);
if (model != null) {
for (ModelItem modelItem : model.getItems()) {

View File

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

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