summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src
diff options
context:
space:
mode:
authoravigaffa <avi.gaffa@amdocs.com>2017-12-31 15:07:39 +0200
committervempo <vitaliy.emporopulo@amdocs.com>2018-01-02 09:41:41 +0200
commitda5dfcd1a354807d13849c7f4ead535ccfa722fa (patch)
treeb4ef0b97d4c25a38bf4a7a8aa5d3626d6b820a17 /openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src
parent25ca73d85757869a6d9cc33861070778503ff153 (diff)
Fixing sonar Exception Handling
Change-Id: I04eb047973a3f5c07dd9dc410cb13af974e8ded1 Issue-ID: SDC-810 Signed-off-by: avigaffa <avi.gaffa@amdocs.com> Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src')
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java32
1 files changed, 27 insertions, 5 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java
index d34d46796d..802827e343 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaConverterUtil.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright © 2016-2017 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.openecomp.core.impl;
import org.apache.commons.collections4.CollectionUtils;
@@ -17,18 +33,23 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
public class ToscaConverterUtil {
+
private static final String SET = "set";
private static final String DEFAULT = "default";
private static final String DEFAULT_CAPITAL = "Default";
- private static Set<String> defaultValueKeys;
+ private static final Set<String> DEFAULT_VALUE_KEYS;
- private static Logger LOGGER = LoggerFactory.getLogger(ToscaConverterUtil.class.getName());
+ private static final Logger LOGGER = LoggerFactory.getLogger(ToscaConverterUtil.class);
static {
- defaultValueKeys =
+ DEFAULT_VALUE_KEYS =
Stream.of(DEFAULT, DEFAULT_CAPITAL).collect(Collectors.toSet());
}
+ private ToscaConverterUtil() {
+ // static utility methods only, prevent instantiation
+ }
+
public static <T> Optional<T> createObjectFromClass(String objectId,
Object objectCandidate,
Class<T> classToCreate) {
@@ -42,7 +63,8 @@ public class ToscaConverterUtil {
}
private static <T> Optional<T> createObjectUsingSetters(Object objectCandidate,
- Class<T> classToCreate) throws Exception {
+ Class<T> classToCreate)
+ throws ReflectiveOperationException {
if (Objects.isNull(objectCandidate)
|| !(objectCandidate instanceof Map)) {
return Optional.empty();
@@ -91,7 +113,7 @@ public class ToscaConverterUtil {
private static Object getDefaultParameterValue(Map<String, Object> entryValue) {
Object defaultValue = null;
Set<String> keys = new HashSet<>(entryValue.keySet());
- keys.retainAll(defaultValueKeys);
+ keys.retainAll(DEFAULT_VALUE_KEYS);
if (CollectionUtils.isNotEmpty(keys)) {
defaultValue = entryValue.get(keys.iterator().next());