aboutsummaryrefslogtreecommitdiffstats
path: root/appc-dispatcher
diff options
context:
space:
mode:
Diffstat (limited to 'appc-dispatcher')
-rw-r--r--appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/onap/appc/rankingframework/impl/RankedAttributesTreeBuilder.java22
1 files changed, 10 insertions, 12 deletions
diff --git a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/onap/appc/rankingframework/impl/RankedAttributesTreeBuilder.java b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/onap/appc/rankingframework/impl/RankedAttributesTreeBuilder.java
index 2a7cfbfe0..9092a1361 100644
--- a/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/onap/appc/rankingframework/impl/RankedAttributesTreeBuilder.java
+++ b/appc-dispatcher/appc-dispatcher-common/ranking-framework-lib/src/main/java/org/onap/appc/rankingframework/impl/RankedAttributesTreeBuilder.java
@@ -45,9 +45,7 @@ class RankedAttributesTreeBuilder {
CompositeNode<R> root = new CompositeNode<>("ROOT", Constants.DEFAULT_MATCH, null,
new HashMap<Object, Node<R>>());
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("Building decision tree for ranked attributes: %s", config.getRankedAttributeNames()));
- }
+ logDebugWhenEnabled(String.format("Building decision tree for ranked attributes: %s", config.getRankedAttributeNames()));
for (ConfigurationEntry<R> entry : config.getEntries()) {
process(entry, names, root);
@@ -57,13 +55,9 @@ class RankedAttributesTreeBuilder {
}
private static <R> void process(ConfigurationEntry<R> entry, Object[] names, CompositeNode<R> root) {
- CompositeNode<R> parentNode = null;
+ CompositeNode<R> parentNode = root;
for (int i = 0; i < names.length; i++) {
- if (i == 0) {
- parentNode = root;
- }
-
final String name = (String) names[i];
final Object value = value(entry, name);
@@ -78,12 +72,10 @@ class RankedAttributesTreeBuilder {
} else {
LeafNode<R> currentNode = (LeafNode<R>) parentNode.children().get(value);
if (currentNode == null) {
- currentNode = new LeafNode<R>(name, value, parentNode, entry.getResult());
+ currentNode = new LeafNode<>(name, value, parentNode, entry.getResult());
parentNode.children().put(value, currentNode);
- if (logger.isDebugEnabled()) {
- logger.debug(String.format("Branch has been created: %s", currentNode));
- }
+ logDebugWhenEnabled(String.format("Branch has been created: %s", currentNode));
} else {
logger.error(
String.format("Duplicated configuration entry has been detected for attribute '%s' with value '%s' - the node '%s'exists already",
@@ -96,6 +88,12 @@ class RankedAttributesTreeBuilder {
}
}
+ private static void logDebugWhenEnabled(String message) {
+ if(logger.isDebugEnabled()) {
+ logger.debug(message);
+ }
+ }
+
private static <R> Object value(ConfigurationEntry<R> entry, String name) {
Object value = entry.getAttributeValue(name);
return Utils.value(value);