sonars - protected constructors and typecasting 23/117223/1
authorjhh <jorge.hernandez-herrero@att.com>
Thu, 28 Jan 2021 22:30:51 +0000 (16:30 -0600)
committerjhh <jorge.hernandez-herrero@att.com>
Thu, 28 Jan 2021 22:30:51 +0000 (16:30 -0600)
Issue-ID: POLICY-3017
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: I7e7e384db26e244e2514aec3c3579b7b7f92f8a1

feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleState.java
feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupported.java
policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
policy-management/src/main/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolset.java
policy-management/src/main/java/org/onap/policy/drools/protocol/coders/TopicCoderFilterConfiguration.java
policy-management/src/main/java/org/onap/policy/drools/system/internal/FeatureLockImpl.java
policy-management/src/main/java/org/onap/policy/drools/system/internal/LockManager.java
policy-utils/src/main/java/org/onap/policy/drools/policies/DomainMaker.java
policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerMarkerFilter.java

index d56e06e..ff53a00 100644 (file)
@@ -237,7 +237,7 @@ public class LifecycleFsm implements Startable {
         List<PolicyTypeDroolsController> opControllers =
             policyTypesMap.values().stream()
                 .filter(typeController -> typeController instanceof PolicyTypeDroolsController)
-                .map(typeController -> (PolicyTypeDroolsController) typeController)
+                .map(PolicyTypeDroolsController.class::cast)
                 .filter(opController -> opController.getControllers().containsKey(controller.getName()))
                 .collect(Collectors.toList());
 
index ad202e8..035fff3 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@ public abstract class LifecycleState implements Startable {
     /**
      * Constructor.
      */
-    public LifecycleState(@NonNull LifecycleFsm manager) {
+    protected LifecycleState(@NonNull LifecycleFsm manager) {
         this.fsm = manager;
     }
 
index f37cf68..4300c16 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ public abstract class LifecycleStateUnsupported extends LifecycleState {
      * Constructor.
      * @param manager Lifecycle Manager.
      */
-    public LifecycleStateUnsupported(LifecycleFsm manager) {
+    protected LifecycleStateUnsupported(LifecycleFsm manager) {
         super(manager);
     }
 
index c1eb9f3..4604913 100644 (file)
@@ -486,7 +486,7 @@ public class MavenDroolsController implements DroolsController {
                 topic)) {
 
             logger.warn("{}: DECODING-UNSUPPORTED {}:{}:{}", this,
-                    topic, this.getGroupId(), this.getArtifactId());
+                    topic, this.getGroupId(), this.getArtifactId());        // NOSONAR
             return true;
         }
 
@@ -889,7 +889,8 @@ public class MavenDroolsController implements DroolsController {
         Collection<FactHandle> factHandles = kieSession.getFactHandles(new ClassObjectFilter(objFact.getClass()));
         for (FactHandle factHandle : factHandles) {
             if (Objects.equals(objFact, kieSession.getObject(factHandle))) {
-                logger.info("Slow delete of {} of type {} from {}", objFact, sessionName);
+                logger.info("Slow delete of {} of type {} from {}",
+                        objFact, objFact.getClass().getName(), sessionName);
                 kieSession.delete(factHandle);
                 return true;
             }
index 8f99f0d..7cf3a2f 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -76,7 +76,7 @@ public abstract class ProtocolCoderToolset {
      * @param controllerId the controller id
      * @throws IllegalArgumentException if invalid data has been passed in
      */
-    public ProtocolCoderToolset(EventProtocolParams eventProtocolParams, String controllerId) {
+    protected ProtocolCoderToolset(EventProtocolParams eventProtocolParams, String controllerId) {
 
         if (eventProtocolParams == null || controllerId == null) {
             throw new IllegalArgumentException("Invalid input");
index 2d69453..9da4852 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * policy-management
  * ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ public class TopicCoderFilterConfiguration {
          *
          * @param rawCustomCoder with format: &lt;class-containing-custom-coder&gt;,&lt;static-coder-field&gt.
          */
-        public CustomCoder(String rawCustomCoder) {
+        protected CustomCoder(String rawCustomCoder) {
             if (rawCustomCoder != null && !rawCustomCoder.isEmpty()) {
 
                 this.className = rawCustomCoder.substring(0, rawCustomCoder.indexOf(','));
@@ -64,7 +64,7 @@ public class TopicCoderFilterConfiguration {
          * @param className class name
          * @param staticCoderField static coder field
          */
-        public CustomCoder(String className, String staticCoderField) {
+        protected CustomCoder(String className, String staticCoderField) {
             if (className == null || className.isEmpty()) {
                 throw new IllegalArgumentException("No classname to create CustomCoder cannot be created");
             }
index 799cca7..6ec2dc4 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ public abstract class FeatureLockImpl extends LockImpl {
     /**
      * Constructs the object.
      */
-    public FeatureLockImpl() {
+    protected FeatureLockImpl() {
         this.attached = false;
     }
 
@@ -62,7 +62,7 @@ public abstract class FeatureLockImpl extends LockImpl {
      * @param callback callback to be invoked once the lock is granted, or subsequently
      *        lost; must not be {@code null}
      */
-    public FeatureLockImpl(LockState state, String resourceId, String ownerKey, int holdSec, LockCallback callback) {
+    protected FeatureLockImpl(LockState state, String resourceId, String ownerKey, int holdSec, LockCallback callback) {
         super(state, resourceId, ownerKey, holdSec, callback);
         this.attached = true;
     }
index ef6b48d..eee2a50 100644 (file)
@@ -71,7 +71,7 @@ public abstract class LockManager<T extends FeatureLockImpl> implements PolicyRe
     /**
      * Constructs the object.
      */
-    public LockManager() {
+    protected LockManager() {
         super();
     }
 
index ae85d57..3796665 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ *  Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
  *  Modifications Copyright (C) 2021 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -210,7 +210,7 @@ public class DomainMaker {
      */
     public String convertToSchema(@NonNull ToscaPolicyType policyType) {
         //
-        // TODO:
+        // TODO:   // NOSONAR
         // 1. Convert Tosca Policy Type definition schema to suitable json schema.
         // 2. Call registerValidator to register
         throw new UnsupportedOperationException("schema generation from policy type is not supported");
index e15dae0..b116592 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public abstract class LoggerMarkerFilter extends AbstractMatcherFilter<ILoggingE
 
     protected final Marker marker;
 
-    public LoggerMarkerFilter(Marker marker) {
+    protected LoggerMarkerFilter(Marker marker) {
         this.marker = marker;
     }