summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core')
-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());