From 1ecf9de8c889adb2dbc9ddd9a79d28e1da89d87b Mon Sep 17 00:00:00 2001 From: Krishnajinka Date: Thu, 26 Jul 2018 20:58:24 +0900 Subject: Fix Sonar issues in utils PDP ParseLog rework Fix Major Sonar issues in ParseLog BackupMonitor and ONAP-PDP component. Issues related to nested control statements. Rework2 based on review comments Issue-ID: POLICY-1013 Change-Id: I10edb242b45a649df902a4e7c1aba0a285b8b7fb Signed-off-by: Krishnajinka --- .../custom/OnapFunctionDefinitionFactory.java | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'ONAP-PDP') diff --git a/ONAP-PDP/src/main/java/org/onap/policy/xacml/custom/OnapFunctionDefinitionFactory.java b/ONAP-PDP/src/main/java/org/onap/policy/xacml/custom/OnapFunctionDefinitionFactory.java index 35080d396..b69141f48 100644 --- a/ONAP-PDP/src/main/java/org/onap/policy/xacml/custom/OnapFunctionDefinitionFactory.java +++ b/ONAP-PDP/src/main/java/org/onap/policy/xacml/custom/OnapFunctionDefinitionFactory.java @@ -3,6 +3,7 @@ * ONAP-PDP * ================================================================================ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,25 +59,25 @@ public class OnapFunctionDefinitionFactory extends FunctionDefinitionFactory { needMapInit = false; final Field[] declaredFields = StdFunctions.class.getDeclaredFields(); for (final Field field : declaredFields) { - if (Modifier.isStatic(field.getModifiers()) && field.getName().startsWith(StdFunctions.FD_PREFIX) - && FunctionDefinition.class.isAssignableFrom(field.getType()) - && Modifier.isPublic(field.getModifiers())) { - try { - register((FunctionDefinition) (field.get(null))); - } catch (final IllegalAccessException ex) { - logger.error(ex.getMessage() + ex); - } - } + registerFunctionDefinition(field); } - // - // Our custom function - // - // register(FunctionDefinitionCustomRegexpMatch); register(FD_CUSTOM_REGEXP_MATCH); } } } + private static void registerFunctionDefinition(Field field) { + if (Modifier.isStatic(field.getModifiers()) && field.getName().startsWith(StdFunctions.FD_PREFIX) + && FunctionDefinition.class.isAssignableFrom(field.getType()) + && Modifier.isPublic(field.getModifiers())) { + try { + register((FunctionDefinition) (field.get(null))); + } catch (final IllegalAccessException ex) { + logger.error(ex.getMessage() + ex); + } + } + } + public OnapFunctionDefinitionFactory() { initMap(); } -- cgit 1.2.3-korg