summaryrefslogtreecommitdiffstats
path: root/common/onap-common-configuration-management/onap-configuration-management-core
diff options
context:
space:
mode:
Diffstat (limited to 'common/onap-common-configuration-management/onap-configuration-management-core')
-rw-r--r--common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java66
1 files changed, 34 insertions, 32 deletions
diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java
index 0a5a141f09..5d49fa970f 100644
--- a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java
+++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationImpl.java
@@ -435,17 +435,18 @@ public class ConfigurationImpl implements org.onap.config.api.Configuration {
field.setAccessible(true);
Config fieldConfAnnotation = field.getAnnotation(Config.class);
Class<?> fieldType = field.getType();
- if (fieldConfAnnotation != null) {
- if (ConfigurationUtils.isAPrimitiveOrWrapper(fieldType) ||
- ConfigurationUtils.isAPrimitivesOrWrappersArray(fieldType)) {
- setPrimitiveField(field, objToReturn, tenant, namespace, keyPrefix, hints);
- }
- if (ConfigurationUtils.isACollection(fieldType)) {
- setCollectionField(field, objToReturn, tenant, namespace, keyPrefix, hints);
- }
- if (ConfigurationUtils.isAMap(fieldType)) {
- setMapField(field, objToReturn, tenant, namespace, keyPrefix);
- }
+ if (fieldConfAnnotation == null) {
+ continue;
+ }
+ if (ConfigurationUtils.isAPrimitiveOrWrapper(fieldType) ||
+ ConfigurationUtils.isAPrimitivesOrWrappersArray(fieldType)) {
+ setPrimitiveField(field, objToReturn, tenant, namespace, keyPrefix, hints);
+ }
+ if (ConfigurationUtils.isACollection(fieldType)) {
+ setCollectionField(field, objToReturn, tenant, namespace, keyPrefix, hints);
+ }
+ if (ConfigurationUtils.isAMap(fieldType)) {
+ setMapField(field, objToReturn, tenant, namespace, keyPrefix);
}
}
return objToReturn;
@@ -471,30 +472,31 @@ public class ConfigurationImpl implements org.onap.config.api.Configuration {
Object obj = get(tenant, namespace, keyPrefix + fieldConfAnnotationKey,
ConfigurationUtils.getArrayClass(ConfigurationUtils.getCollectionGenericType(field)),
hints);
- if (obj != null) {
- List<Object> list = Arrays.asList((Object[]) obj);
- Class clazzToInstantiate;
- if (fieldType.isInterface()) {
- clazzToInstantiate = ConfigurationUtils.getConcreteCollection(fieldType).getClass();
- } else if (Modifier.isAbstract(fieldType.getModifiers())) {
- clazzToInstantiate =
- ConfigurationUtils.getCompatibleCollectionForAbstractDef(fieldType)
- .getClass();
- } else {
- clazzToInstantiate = fieldType;
- }
- Constructor construct = getConstructorWithArguments(clazzToInstantiate, Collection.class);
+ if (obj == null) {
+ return;
+ }
+ List<Object> list = Arrays.asList((Object[]) obj);
+ Class clazzToInstantiate;
+ if (fieldType.isInterface()) {
+ clazzToInstantiate = ConfigurationUtils.getConcreteCollection(fieldType).getClass();
+ } else if (Modifier.isAbstract(fieldType.getModifiers())) {
+ clazzToInstantiate =
+ ConfigurationUtils.getCompatibleCollectionForAbstractDef(fieldType)
+ .getClass();
+ } else {
+ clazzToInstantiate = fieldType;
+ }
+ Constructor construct = getConstructorWithArguments(clazzToInstantiate, Collection.class);
+ if (construct != null) {
+ construct.setAccessible(true);
+ field.set(objToReturn, construct.newInstance(list));
+ } else {
+ construct = getConstructorWithArguments(clazzToInstantiate, Integer.class,
+ Boolean.class, Collection.class);
if (construct != null) {
construct.setAccessible(true);
- field.set(objToReturn, construct.newInstance(list));
- } else {
- construct = getConstructorWithArguments(clazzToInstantiate, Integer.class,
- Boolean.class, Collection.class);
- if (construct != null) {
- construct.setAccessible(true);
- field.set(objToReturn, construct.newInstance(list.size(), true, list));
- }
+ field.set(objToReturn, construct.newInstance(list.size(), true, list));
}
}
}