aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/main/java
diff options
context:
space:
mode:
authorSravanKumarGunda <sravan.kumar1@huawei.com>2020-07-14 14:55:47 +0530
committerSravanKumarGunda <sravan.kumar1@huawei.com>2020-07-14 19:22:59 +0530
commit9a08d687e48312beef47bce357d374ede2ce0dc7 (patch)
tree3717d377dd4ea90f4e88c28d52bb3c0d5d28f34c /framework/src/main/java
parent5f23e02caa5ab128a4c01866dec91eaea8dc7cee (diff)
Code Improvements
Signed-off-by: SravanKumarGunda <sravan.kumar1@huawei.com> Issue-ID: CLI-270 Change-Id: I3de621dab68f153c16a36102239b095c60abf9ab
Diffstat (limited to 'framework/src/main/java')
-rw-r--r--framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java5
-rw-r--r--framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java2
-rw-r--r--framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java1
-rw-r--r--framework/src/main/java/org/onap/cli/fw/store/OnapCommandProfileStore.java4
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java10
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java6
6 files changed, 8 insertions, 20 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java b/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java
index 7a125ce5..09050c6c 100644
--- a/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java
+++ b/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java
@@ -71,10 +71,7 @@ public class OnapCommandPrint {
* @return list
*/
public List<String> getColumn(String header) {
- if (this.data.get(header) == null) {
- this.data.put(header, new ArrayList<String>());
- }
- return this.data.get(header);
+ return this.data.computeIfAbsent(header, k -> new ArrayList<String>());
}
public boolean isPrintTitle() {
diff --git a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java
index 04a81aa7..7de56025 100644
--- a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java
+++ b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaLoader.java
@@ -511,7 +511,7 @@ public class OnapCommandSchemaLoader {
* @throws OnapCommandInvalidSchema
* exception
*/
- public static Map<String, Object> loadSchema(InputStream stream, String schemaName) throws OnapCommandInvalidSchema {
+ public static Map<String, Object> loadSchema(InputStream stream, String schemaName) throws OnapCommandInvalidSchema { //NOSONAR
return OnapCommandDiscoveryUtils.loadYaml(stream);
}
diff --git a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java
index 15996a8f..7352eced 100644
--- a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java
+++ b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandExecutionStore.java
@@ -17,7 +17,6 @@
package org.onap.cli.fw.store;
import java.io.File;
-import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
diff --git a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandProfileStore.java b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandProfileStore.java
index 677c45ea..39645120 100644
--- a/framework/src/main/java/org/onap/cli/fw/store/OnapCommandProfileStore.java
+++ b/framework/src/main/java/org/onap/cli/fw/store/OnapCommandProfileStore.java
@@ -19,7 +19,6 @@ package org.onap.cli.fw.store;
import static org.onap.cli.fw.conf.OnapCommandConstants.DATA_PATH_PROFILE_JSON;
import java.io.File;
-import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -147,8 +146,7 @@ public class OnapCommandProfileStore {
}
private void load(String profileName, boolean include) throws OnapCommandException {
- List<OnapCommandParamEntity> params= new ArrayList<>();
- params = this.loadParamFromCache(profileName);
+ List<OnapCommandParamEntity> params = this.loadParamFromCache(profileName);
for (OnapCommandParamEntity p : params) {
if (include) {
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
index b2999077..b866db09 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
@@ -113,7 +113,7 @@ public class OnapCommandDiscoveryUtils {
* exception
*/
public static List<OnapCommandSchemaInfo> discoverOrLoadSchemas(boolean forceRefresh) throws OnapCommandException {
- List<OnapCommandSchemaInfo> schemas = new ArrayList<>();
+ List<OnapCommandSchemaInfo> schemas = new ArrayList<>(); //NOSONAR
if (forceRefresh || Boolean.parseBoolean(OnapCommandConfig.getPropertyValue(OnapCommandConstants.DISCOVER_ALWAYS))
|| !OnapCommandDiscoveryUtils.isAlreadyDiscovered()) {
schemas = OnapCommandDiscoveryUtils.discoverSchemas();
@@ -219,13 +219,7 @@ public class OnapCommandDiscoveryUtils {
* exception
*/
public static Map<String, Object> loadSchema(Resource resource) throws OnapCommandInvalidSchema {
- Map<String, Object> values = null;
- try {
- values = loadYaml(resource.getInputStream());
- } catch (Exception e) {
- throw new OnapCommandInvalidSchema(resource.getFilename(), e);
- }
- return values;
+ return loadYaml(resource);
}
/**
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
index 60bf2d2b..58fe7df6 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
@@ -328,11 +328,11 @@ public class OnapCommandUtils {
|| OnapCommandParameterType.JSON.equals(param.getParameterType())
|| OnapCommandParameterType.YAML.equals(param.getParameterType())) {
// ignore the front and back double quotes in json body
- String va_ = params.get(paramName).getValue().toString();
+ String value = params.get(paramName).getValue().toString();
if (idxS > 0)
- result.append(line.substring(currentIdx, idxS - 1) + va_);
+ result.append(line.substring(currentIdx, idxS - 1) + value);
else
- result.append(va_);
+ result.append(value);
currentIdx = idxE + 2;
} else if (OnapCommandParameterType.MAP.equals(param.getParameterType())) {
try {