You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2022/04/08 15:55:09 UTC
[hop] branch master updated: HOP-3202 Code cleanup and Sonar issues
This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/master by this push:
new e977917288 HOP-3202 Code cleanup and Sonar issues
new 729ec9d506 Merge pull request #1448 from nadment/HOP-3202
e977917288 is described below
commit e97791728860ef74fd04505c2f05272ff75d40ad
Author: Nicolas Adment <na...@gmail.com>
AuthorDate: Fri Apr 8 12:03:14 2022 +0200
HOP-3202 Code cleanup and Sonar issues
---
.../apache/hop/core/variables/VariableRegistry.java | 4 ++--
.../org/apache/hop/core/variables/Variables.java | 20 +++++++++-----------
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/core/src/main/java/org/apache/hop/core/variables/VariableRegistry.java b/core/src/main/java/org/apache/hop/core/variables/VariableRegistry.java
index 5c0960362c..7319f1c875 100644
--- a/core/src/main/java/org/apache/hop/core/variables/VariableRegistry.java
+++ b/core/src/main/java/org/apache/hop/core/variables/VariableRegistry.java
@@ -37,7 +37,7 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -54,7 +54,7 @@ public class VariableRegistry {
private final List<String> deprecatedNames;
private VariableRegistry() {
- variableScopes = new HashMap<>();
+ variableScopes = new EnumMap<>(VariableScope.class);
variableScopes.put(VariableScope.SYSTEM, new ArrayList<>());
variableScopes.put(VariableScope.APPLICATION, new ArrayList<>());
variableScopes.put(VariableScope.ENGINE, new ArrayList<>());
diff --git a/core/src/main/java/org/apache/hop/core/variables/Variables.java b/core/src/main/java/org/apache/hop/core/variables/Variables.java
index 1cd9cefd6c..200ee2be31 100644
--- a/core/src/main/java/org/apache/hop/core/variables/Variables.java
+++ b/core/src/main/java/org/apache/hop/core/variables/Variables.java
@@ -68,11 +68,11 @@ public class Variables implements IVariables {
@Override
public String getVariable(String variableName, String defaultValue) {
- String var = properties.get(variableName);
- if (var == null) {
+ String value = properties.get(variableName);
+ if (value == null) {
return defaultValue;
}
- return var;
+ return value;
}
@Override
@@ -183,10 +183,9 @@ public class Variables implements IVariables {
if (initialized) {
// variables are already initialized
if (map != null) {
- for (String key : map.keySet()) {
- String value = map.get(key);
- if (!Utils.isEmpty(key)) {
- properties.put(key, Const.NVL(value, ""));
+ for (Map.Entry<String,String> entry : map.entrySet()) {
+ if (!Utils.isEmpty(entry.getKey())) {
+ properties.put(entry.getKey(), Const.NVL(entry.getValue(), ""));
}
}
injection = null;
@@ -195,10 +194,9 @@ public class Variables implements IVariables {
// We have our own personal copy, so changes afterwards
// to the input properties don't affect us.
injection = new Hashtable<>();
- for (String key : map.keySet()) {
- String value = map.get(key);
- if (!Utils.isEmpty(key)) {
- injection.put(key, Const.NVL(value, ""));
+ for (Map.Entry<String,String> entry : map.entrySet()) {
+ if (!Utils.isEmpty(entry.getKey())) {
+ injection.put(entry.getKey(), Const.NVL(entry.getValue(), ""));
}
}
}