Use lombok in drools-pdp 52/123152/1
authorJim Hahn <jrh3@att.com>
Thu, 5 Aug 2021 14:13:01 +0000 (10:13 -0400)
committerJim Hahn <jrh3@att.com>
Thu, 5 Aug 2021 15:18:36 +0000 (11:18 -0400)
Updated policy-management thru policy-utils.

Issue-ID: POLICY-3397
Change-Id: Ie9498fe912e8338ddc32a40774c3cb63d84f079a
Signed-off-by: Jim Hahn <jrh3@att.com>
41 files changed:
policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java
policy-management/src/main/java/org/onap/policy/drools/persistence/SystemPersistenceConstants.java
policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoder.java
policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderConstants.java
policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolDecoder.java
policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolEncoder.java
policy-management/src/main/java/org/onap/policy/drools/protocol/coders/EventProtocolParams.java
policy-management/src/main/java/org/onap/policy/drools/protocol/coders/GenericEventProtocolCoder.java
policy-management/src/main/java/org/onap/policy/drools/protocol/coders/GsonProtocolCoderToolset.java
policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java
policy-management/src/main/java/org/onap/policy/drools/protocol/coders/MultiplexorEventProtocolCoder.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/protocol/configuration/ControllerConfiguration.java
policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java
policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
policy-management/src/main/java/org/onap/policy/drools/system/Main.java
policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerConstants.java
policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineConstants.java
policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java
policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
policy-management/src/main/java/org/onap/policy/drools/system/internal/LockManager.java
policy-management/src/main/java/org/onap/policy/drools/system/internal/SimpleLockManager.java
policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java
policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java
policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java
policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java
policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java
policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java
policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java
policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java
policy-utils/src/main/java/org/onap/policy/drools/utils/CryptoCoderValueLookup.java
policy-utils/src/main/java/org/onap/policy/drools/utils/PropertyUtil.java
policy-utils/src/main/java/org/onap/policy/drools/utils/Reference.java
policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java
policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerMarkerFilter.java
policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java
policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java

index 5e6e469..d7d387b 100644 (file)
@@ -286,14 +286,14 @@ public class MavenDroolsController implements DroolsController {
                             .eventClass(potentialCodedClass)
                             .protocolFilter(protocolFilter)
                             .customGsonCoder(customGsonCoder)
-                            .modelClassLoaderHash(this.policyContainer.getClassLoader().hashCode()));
+                            .modelClassLoaderHash(this.policyContainer.getClassLoader().hashCode()).build());
                 } else {
                     getCoderManager().addEncoder(
                             EventProtocolParams.builder().groupId(this.getGroupId())
                                     .artifactId(this.getArtifactId()).topic(topic)
                                     .eventClass(potentialCodedClass).protocolFilter(protocolFilter)
                                     .customGsonCoder(customGsonCoder)
-                                    .modelClassLoaderHash(this.policyContainer.getClassLoader().hashCode()));
+                                    .modelClassLoaderHash(this.policyContainer.getClassLoader().hashCode()).build());
                 }
             }
         }
index 02a1a81..d35f546 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.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,6 +33,8 @@ import java.util.Comparator;
 import java.util.List;
 import java.util.Properties;
 import java.util.function.BiPredicate;
+import lombok.Getter;
+import lombok.ToString;
 import org.onap.policy.drools.properties.DroolsPropertyConstants;
 import org.onap.policy.drools.utils.PropertyUtil;
 import org.slf4j.Logger;
@@ -41,6 +43,8 @@ import org.slf4j.LoggerFactory;
 /**
  * Properties based Persistence.
  */
+@Getter
+@ToString
 public class FileSystemPersistence implements SystemPersistence {
 
     /**
@@ -104,14 +108,15 @@ public class FileSystemPersistence implements SystemPersistence {
     public static final String SYSTEM_PROPERTIES_FILE_SUFFIX = SYSTEM_PROPERTIES_SUFFIX + PROPERTIES_FILE_EXTENSION;
 
     /**
-     * Configuration directory.
+     * Logger.
      */
-    protected Path configurationDirectory = Paths.get(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR);
+    private static final Logger logger = LoggerFactory.getLogger(FileSystemPersistence.class);
 
     /**
-     * Logger.
+     * Configuration directory.
      */
-    private static final Logger logger = LoggerFactory.getLogger(FileSystemPersistence.class);
+    protected Path configurationPath = Paths.get(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR);
+
 
     @Override
     public void setConfigurationDir(String configDir) {
@@ -119,11 +124,11 @@ public class FileSystemPersistence implements SystemPersistence {
 
         if (tempConfigDir == null) {
             tempConfigDir = SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR;
-            this.configurationDirectory = Paths.get(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR);
+            this.configurationPath = Paths.get(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR);
         }
 
         if (!tempConfigDir.equals(SystemPersistenceConstants.DEFAULT_CONFIGURATION_DIR)) {
-            this.configurationDirectory = Paths.get(tempConfigDir);
+            this.configurationPath = Paths.get(tempConfigDir);
         }
 
         setConfigurationDir();
@@ -131,25 +136,20 @@ public class FileSystemPersistence implements SystemPersistence {
 
     @Override
     public void setConfigurationDir() {
-        if (Files.notExists(this.configurationDirectory)) {
+        if (Files.notExists(this.configurationPath)) {
             try {
-                Files.createDirectories(this.configurationDirectory);
+                Files.createDirectories(this.configurationPath);
             } catch (final IOException e) {
-                throw new IllegalStateException("cannot create " + this.configurationDirectory, e);
+                throw new IllegalStateException("cannot create " + this.configurationPath, e);
             }
         }
 
-        if (!Files.isDirectory(this.configurationDirectory)) {
+        if (!Files.isDirectory(this.configurationPath)) {
             throw new IllegalStateException(
-                "config directory: " + this.configurationDirectory + " is not a directory");
+                "config directory: " + this.configurationPath + " is not a directory");
         }
     }
 
-    @Override
-    public Path getConfigurationPath() {
-        return this.configurationDirectory;
-    }
-
     protected Properties getProperties(Path propertiesPath) {
         if (!Files.exists(propertiesPath)) {
             throw new IllegalArgumentException("properties for " + propertiesPath.toString() + " are not persisted.");
@@ -168,7 +168,7 @@ public class FileSystemPersistence implements SystemPersistence {
             throw new IllegalArgumentException("properties name must be provided");
         }
 
-        Path propertiesPath = Paths.get(this.configurationDirectory.toString());
+        var propertiesPath = Paths.get(this.configurationPath.toString());
         if (name.endsWith(PROPERTIES_FILE_EXTENSION) || name.endsWith(ENV_FILE_EXTENSION)) {
             propertiesPath = propertiesPath.resolve(name);
         } else {
@@ -196,7 +196,7 @@ public class FileSystemPersistence implements SystemPersistence {
     private void addToPropertiesList(File file, List<Properties> properties,
                                      BiPredicate<String, Properties> preCondition) {
         try {
-            Properties proposedProps = getProperties(file.getName());
+            var proposedProps = getProperties(file.getName());
             if (preCondition.test(file.getName(), proposedProps)) {
                 properties.add(proposedProps);
             }
@@ -212,7 +212,7 @@ public class FileSystemPersistence implements SystemPersistence {
             throw new IllegalArgumentException("environment name must be provided");
         }
 
-        return this.getProperties(Paths.get(this.configurationDirectory.toString(), name + ENV_FILE_SUFFIX));
+        return this.getProperties(Paths.get(this.configurationPath.toString(), name + ENV_FILE_SUFFIX));
     }
 
     @Override
@@ -276,7 +276,7 @@ public class FileSystemPersistence implements SystemPersistence {
     }
 
     private boolean testControllerName(String controllerFilename, Properties controllerProperties) {
-        String controllerName = controllerFilename
+        var controllerName = controllerFilename
                 .substring(0, controllerFilename.length() - PROPERTIES_FILE_CONTROLLER_SUFFIX.length());
         String controllerPropName = controllerProperties.getProperty(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME);
         if (controllerPropName == null) {
@@ -311,11 +311,11 @@ public class FileSystemPersistence implements SystemPersistence {
     }
 
     protected boolean backup(String name, String fileSuffix) {
-        Path path = Paths.get(this.configurationDirectory.toString(), name + fileSuffix);
+        var path = Paths.get(this.configurationPath.toString(), name + fileSuffix);
         if (Files.exists(path)) {
             try {
                 logger.info("{}: there is an existing configuration file @ {} ", this, path);
-                Path bakPath = Paths.get(this.configurationDirectory.toString(),
+                var bakPath = Paths.get(this.configurationPath.toString(),
                                             name + fileSuffix + FILE_BACKUP_SUFFIX);
                 Files.copy(path, bakPath, StandardCopyOption.REPLACE_EXISTING);
             } catch (Exception e) {
@@ -351,10 +351,10 @@ public class FileSystemPersistence implements SystemPersistence {
     }
 
     private boolean store(String name, Properties properties, String fileSuffix) {
-        Path path = Paths.get(this.configurationDirectory.toString(), name + fileSuffix);
+        var path = Paths.get(this.configurationPath.toString(), name + fileSuffix);
         if (Files.exists(path)) {
             try {
-                Properties oldProperties = PropertyUtil.getProperties(path.toFile());
+                var oldProperties = PropertyUtil.getProperties(path.toFile());
                 if (oldProperties.equals(properties)) {
                     logger.info("{}: noop: a properties file with the same contents exists for controller {}.", this,
                                 name);
@@ -368,8 +368,8 @@ public class FileSystemPersistence implements SystemPersistence {
             }
         }
 
-        File file = path.toFile();
-        try (FileWriter writer = new FileWriter(file)) {
+        var file = path.toFile();
+        try (var writer = new FileWriter(file)) {
             properties.store(writer, "Machine created Policy Controller Configuration");
         } catch (Exception e) {
             logger.warn("{}: {} cannot be saved", this, name, e);
@@ -408,11 +408,11 @@ public class FileSystemPersistence implements SystemPersistence {
     }
 
     protected boolean delete(String name, String fileSuffix) {
-        Path path = Paths.get(this.configurationDirectory.toString(), name + fileSuffix);
+        var path = Paths.get(this.configurationPath.toString(), name + fileSuffix);
 
         if (Files.exists(path)) {
             try {
-                Path bakPath = Paths.get(this.configurationDirectory.toString(),
+                var bakPath = Paths.get(this.configurationPath.toString(),
                                             name + fileSuffix + FILE_BACKUP_SUFFIX);
                 Files.move(path, bakPath, StandardCopyOption.REPLACE_EXISTING);
             } catch (final Exception e) {
@@ -428,7 +428,7 @@ public class FileSystemPersistence implements SystemPersistence {
      * provides a list of files sorted by name in ascending order in the configuration directory.
      */
     private File[] sortedListFiles() {
-        File[] dirFiles = this.configurationDirectory.toFile().listFiles();
+        File[] dirFiles = this.configurationPath.toFile().listFiles();
         if (dirFiles != null) {
             Arrays.sort(dirFiles, Comparator.comparing(File::getName));
         } else {
@@ -436,9 +436,4 @@ public class FileSystemPersistence implements SystemPersistence {
         }
         return dirFiles;
     }
-
-    @Override
-    public String toString() {
-        return "FileSystemPersistence [configurationDirectory=" + this.configurationDirectory + "]";
-    }
 }
index 0b46fb0..ba6c5e7 100644 (file)
 
 package org.onap.policy.drools.persistence;
 
+import lombok.AccessLevel;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 
-public class SystemPersistenceConstants {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class SystemPersistenceConstants {
     /**
      * configuration directory.
      */
@@ -34,8 +37,4 @@ public class SystemPersistenceConstants {
      */
     @Getter
     private static final SystemPersistence manager = new FileSystemPersistence();
-
-    private SystemPersistenceConstants() {
-        // do nothing
-    }
 }
index 7e26859..278ea41 100644 (file)
 package org.onap.policy.drools.protocol.coders;
 
 import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
 import org.onap.policy.drools.controller.DroolsController;
 
 /**
@@ -29,6 +33,10 @@ import org.onap.policy.drools.controller.DroolsController;
  */
 public interface EventProtocolCoder {
 
+    @Getter
+    @Setter
+    @ToString
+    @AllArgsConstructor
     public static class CoderFilters {
 
         /**
@@ -45,73 +53,6 @@ public interface EventProtocolCoder {
          * classloader hash.
          */
         protected int modelClassLoaderHash;
-
-        /**
-         * constructor.
-         *
-         * @param codedClass coder class
-         * @param filter     filters to apply
-         */
-        public CoderFilters(String codedClass, JsonProtocolFilter filter, int modelClassLoaderHash) {
-            this.factClass = codedClass;
-            this.filter = filter;
-            this.modelClassLoaderHash = modelClassLoaderHash;
-        }
-
-        /**
-         * Get coded class.
-         *
-         * @return the codedClass
-         */
-        public String getCodedClass() {
-            return factClass;
-        }
-
-        /**
-         * Set coded class.
-         *
-         * @param codedClass the decodedClass to set
-         */
-        public void setCodedClass(String codedClass) {
-            this.factClass = codedClass;
-        }
-
-        /**
-         * Get filter.
-         *
-         * @return the filter
-         */
-        public JsonProtocolFilter getFilter() {
-            return filter;
-        }
-
-        /**
-         * Set filter.
-         *
-         * @param filter the filter to set
-         */
-        public void setFilter(JsonProtocolFilter filter) {
-            this.filter = filter;
-        }
-
-        public int getModelClassLoaderHash() {
-            return modelClassLoaderHash;
-        }
-
-        public void setFromClassLoaderHash(int fromClassLoaderHash) {
-            this.modelClassLoaderHash = fromClassLoaderHash;
-        }
-
-        @Override
-        public String toString() {
-            return "CoderFilters [factClass="
-                    + factClass
-                    + ", filter="
-                    + filter
-                    + ", modelClassLoaderHash="
-                    + modelClassLoaderHash
-                    + "]";
-        }
     }
 
     /**
index 45dc39e..160da9f 100644 (file)
 
 package org.onap.policy.drools.protocol.coders;
 
+import lombok.AccessLevel;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 
-public class EventProtocolCoderConstants {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class EventProtocolCoderConstants {
 
     /**
      * singleton reference to the global event protocol coder.
      */
     @Getter
     private static final EventProtocolCoder manager = new MultiplexorEventProtocolCoder();
-
-    private EventProtocolCoderConstants() {
-        // do nothing
-    }
 }
index 6bb3a62..cbedbba 100644 (file)
 
 package org.onap.policy.drools.protocol.coders;
 
-class EventProtocolDecoder extends GenericEventProtocolCoder {
+import lombok.ToString;
 
-    public EventProtocolDecoder() {
-        super();
-    }
+@ToString(callSuper = true)
+class EventProtocolDecoder extends GenericEventProtocolCoder {
 
-    @Override
-    public String toString() {
-        return "EventProtocolDecoder [toString()=" + super.toString() + "]";
-    }
 }
index 461c66a..2f81e53 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.
 
 package org.onap.policy.drools.protocol.coders;
 
-class EventProtocolEncoder extends GenericEventProtocolCoder {
+import lombok.ToString;
 
-    public EventProtocolEncoder() {
-        super();
-    }
+@ToString(callSuper = true)
+class EventProtocolEncoder extends GenericEventProtocolCoder {
 
-    @Override
-    public String toString() {
-        return "EventProtocolEncoder [toString()=" + super.toString() + "]";
-    }
 }
index 810562c..c5fdcc6 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- *  Modifications Copyright (C) 2019 AT&T Intellectual Property.
+ *  Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.policy.drools.protocol.coders;
 
-import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomCoder;
+import lombok.Builder;
+import lombok.Getter;
 
+@Getter
+@Builder
 public class EventProtocolParams {
     private String groupId;
     private String artifactId;
@@ -31,118 +34,4 @@ public class EventProtocolParams {
     private JsonProtocolFilter protocolFilter;
     private TopicCoderFilterConfiguration.CustomGsonCoder customGsonCoder;
     private int modelClassLoaderHash;
-
-    public String getGroupId() {
-        return groupId;
-    }
-
-    public String getArtifactId() {
-        return artifactId;
-    }
-
-    public String getTopic() {
-        return topic;
-    }
-
-    public String getEventClass() {
-        return eventClass;
-    }
-
-    public JsonProtocolFilter getProtocolFilter() {
-        return protocolFilter;
-    }
-
-    public TopicCoderFilterConfiguration.CustomGsonCoder getCustomGsonCoder() {
-        return customGsonCoder;
-    }
-
-    public int getModelClassLoaderHash() {
-        return modelClassLoaderHash;
-    }
-
-    public static EventProtocolParams builder() {
-        return new EventProtocolParams();
-    }
-
-    /**
-     * Setter method.
-     *
-     * @param groupId of the controller
-     * @return EventProtocolParams
-     */
-    public EventProtocolParams groupId(String groupId) {
-        this.groupId = groupId;
-        return this;
-    }
-
-    /**
-     * Setter method.
-     *
-     * @param artifactId of the controller
-     * @return EventProtocolParams
-     */
-    public EventProtocolParams artifactId(String artifactId) {
-        this.artifactId = artifactId;
-        return this;
-    }
-
-    /**
-     * Setter method.
-     *
-     * @param topic the topic
-     * @return EventProtocolParams
-     */
-    public EventProtocolParams topic(String topic) {
-        this.topic = topic;
-        return this;
-    }
-
-    /**
-     * Setter method.
-     *
-     * @param eventClass the event class
-     * @return EventProtocolParams
-     */
-    public EventProtocolParams eventClass(String eventClass) {
-        this.eventClass = eventClass;
-        return this;
-    }
-
-    /**
-     * Setter method.
-     *
-     * @param protocolFilter filters to selectively choose a particular decoder
-     *                       when there are multiples
-     * @return EventProtocolParams
-     */
-    public EventProtocolParams protocolFilter(JsonProtocolFilter protocolFilter) {
-        this.protocolFilter = protocolFilter;
-        return this;
-    }
-
-    /**
-     * Setter method.
-     *
-     * @param customGsonCoder custom gscon coder
-     * @return EventProtocolParams
-     */
-    public EventProtocolParams customGsonCoder(
-            TopicCoderFilterConfiguration.CustomGsonCoder customGsonCoder) {
-        this.customGsonCoder = customGsonCoder;
-        return this;
-    }
-
-    /**
-     * Setter method.
-     * @param modelClassLoaderHash integer representing model hash
-     * @return EventProtocolParams
-     */
-    public EventProtocolParams modelClassLoaderHash(int modelClassLoaderHash) {
-        this.modelClassLoaderHash = modelClassLoaderHash;
-        return this;
-    }
-
-    public CustomCoder getCustomCoder() {
-        return this.customGsonCoder;
-    }
 }
index 5faf8a8..8c734d5 100644 (file)
@@ -25,6 +25,9 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
 import org.onap.policy.drools.controller.DroolsController;
 import org.onap.policy.drools.controller.DroolsControllerConstants;
 import org.onap.policy.drools.protocol.coders.EventProtocolCoder.CoderFilters;
@@ -35,6 +38,8 @@ import org.slf4j.LoggerFactory;
  * This protocol Coder that does its best attempt to decode/encode, selecting the best class and best fitted json
  * parsing tools.
  */
+@ToString
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
 abstract class GenericEventProtocolCoder {
     private static final String INVALID_ARTIFACT_ID_MSG = "Invalid artifact id";
     private static final String INVALID_GROUP_ID_MSG = "Invalid group id";
@@ -58,10 +63,6 @@ abstract class GenericEventProtocolCoder {
     protected final HashMap<String, List<ProtocolCoderToolset>>
             reverseCoders = new HashMap<>();
 
-    GenericEventProtocolCoder() {
-        super();
-    }
-
     /**
      * Index a new coder.
      */
@@ -213,7 +214,7 @@ abstract class GenericEventProtocolCoder {
                 logger.info("{}: removed toolset for {}: {}", this, key, coderToolset);
 
                 for (CoderFilters codeFilter : coderToolset.getCoders()) {
-                    String className = codeFilter.getCodedClass();
+                    String className = codeFilter.getFactClass();
                     String reverseKey = this.reverseCodersKey(topic, className);
                     removeReverseCoder(key, reverseKey);
                 }
@@ -483,7 +484,7 @@ abstract class GenericEventProtocolCoder {
         String artifactId = encoderSet.getArtifactId();
         List<CoderFilters> coderFilters = encoderSet.getCoders();
         for (CoderFilters coder : coderFilters) {
-            if (coder.getCodedClass().equals(encodedClass.getClass().getName())) {
+            if (coder.getFactClass().equals(encodedClass.getClass().getName())) {
                 var droolsController =
                                 DroolsControllerConstants.getFactory().get(groupId, artifactId, "");
                 if (droolsController.ownsCoder(
@@ -719,13 +720,4 @@ abstract class GenericEventProtocolCoder {
         }
         return droolsControllers;
     }
-
-    @Override
-    public String toString() {
-        return "GenericEventProtocolCoder [coders="
-                + coders.keySet()
-                + ", reverseCoders="
-                + reverseCoders.keySet()
-                + "]";
-    }
 }
index 637e0c1..f3525e9 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.
@@ -28,14 +28,12 @@ import com.google.gson.JsonElement;
 import com.google.gson.JsonPrimitive;
 import com.google.gson.JsonSerializationContext;
 import com.google.gson.JsonSerializer;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
 import java.lang.reflect.Type;
 import java.time.Instant;
 import java.time.ZonedDateTime;
 import java.time.format.DateTimeFormatter;
+import lombok.ToString;
 import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
-import org.onap.policy.drools.controller.DroolsController;
 import org.onap.policy.drools.controller.DroolsControllerConstants;
 import org.onap.policy.drools.protocol.coders.EventProtocolCoder.CoderFilters;
 import org.slf4j.Logger;
@@ -44,6 +42,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Tools used for encoding/decoding using GSON.
  */
+@ToString(callSuper = true)
 class GsonProtocolCoderToolset extends ProtocolCoderToolset {
     private static final String CANNOT_FETCH_CLASS = "{}: cannot fetch application class {}";
     private static final String FETCH_CLASS_EX_MSG = "cannot fetch application class ";
@@ -151,7 +150,7 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
     @Override
     public Object decode(String json) {
 
-        final DroolsController droolsController =
+        final var droolsController =
                         DroolsControllerConstants.getFactory().get(this.groupId, this.artifactId, "");
         if (droolsController == null) {
             logger.warn("{}: no drools-controller to process {}", this, json);
@@ -166,31 +165,31 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
 
         Class<?> decoderClass;
         try {
-            decoderClass = droolsController.fetchModelClass(decoderFilter.getCodedClass());
+            decoderClass = droolsController.fetchModelClass(decoderFilter.getFactClass());
             if (decoderClass == null) {
-                logger.warn(CANNOT_FETCH_CLASS, this, decoderFilter.getCodedClass());
+                logger.warn(CANNOT_FETCH_CLASS, this, decoderFilter.getFactClass());
                 throw new IllegalStateException(
-                        FETCH_CLASS_EX_MSG + decoderFilter.getCodedClass());
+                        FETCH_CLASS_EX_MSG + decoderFilter.getFactClass());
             }
         } catch (final Exception e) {
-            logger.warn(CANNOT_FETCH_CLASS, this, decoderFilter.getCodedClass());
+            logger.warn(CANNOT_FETCH_CLASS, this, decoderFilter.getFactClass());
             throw new UnsupportedOperationException(
-                    FETCH_CLASS_EX_MSG + decoderFilter.getCodedClass(), e);
+                    FETCH_CLASS_EX_MSG + decoderFilter.getFactClass(), e);
         }
 
         if (this.customCoder != null) {
             try {
-                final Class<?> gsonClassContainer =
+                final var gsonClassContainer =
                         droolsController.fetchModelClass(this.customCoder.getClassContainer());
-                final Field gsonField = gsonClassContainer.getField(this.customCoder.staticCoderField);
-                final Object gsonObject = gsonField.get(null);
-                final Method fromJsonMethod = gsonObject.getClass().getDeclaredMethod("fromJson",
+                final var gsonField = gsonClassContainer.getField(this.customCoder.staticCoderField);
+                final var gsonObject = gsonField.get(null);
+                final var fromJsonMethod = gsonObject.getClass().getDeclaredMethod("fromJson",
                         String.class, Class.class);
                 return fromJsonMethod.invoke(gsonObject, json, decoderClass);
             } catch (final Exception e) {
-                logger.warn(CANNOT_FETCH_CLASS, this, decoderFilter.getCodedClass());
+                logger.warn(CANNOT_FETCH_CLASS, this, decoderFilter.getFactClass());
                 throw new UnsupportedOperationException(
-                        FETCH_CLASS_EX_MSG + decoderFilter.getCodedClass(), e);
+                        FETCH_CLASS_EX_MSG + decoderFilter.getFactClass(), e);
             }
         } else {
             try {
@@ -198,7 +197,7 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
             } catch (final Exception e) {
                 logger.warn("{} cannot decode {} into {}", this, json, decoderClass.getName());
                 throw new UnsupportedOperationException(
-                        "cannont decode into " + decoderFilter.getCodedClass(), e);
+                        "cannont decode into " + decoderFilter.getFactClass(), e);
             }
         }
     }
@@ -211,13 +210,13 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
 
         if (this.customCoder != null) {
             try {
-                final DroolsController droolsController =
+                final var droolsController =
                                 DroolsControllerConstants.getFactory().get(this.groupId, this.artifactId, null);
                 final Class<?> gsonClassContainer =
                         droolsController.fetchModelClass(this.customCoder.getClassContainer());
-                final Field gsonField = gsonClassContainer.getField(this.customCoder.staticCoderField);
-                final Object gsonObject = gsonField.get(null);
-                final Method toJsonMethod =
+                final var gsonField = gsonClassContainer.getField(this.customCoder.staticCoderField);
+                final var gsonObject = gsonField.get(null);
+                final var toJsonMethod =
                         gsonObject.getClass().getDeclaredMethod("toJson", Object.class);
                 return (String) toJsonMethod.invoke(gsonObject, event);
             } catch (final Exception e) {
@@ -233,11 +232,4 @@ class GsonProtocolCoderToolset extends ProtocolCoderToolset {
             }
         }
     }
-
-    @Override
-    public String toString() {
-        final StringBuilder builder = new StringBuilder();
-        builder.append("GsonProtocolCoderToolset [toString()=").append(super.toString()).append("]");
-        return builder.toString();
-    }
 }
index 2ccc010..430f4ff 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -26,10 +26,12 @@ import com.jayway.jsonpath.JsonPath;
 import com.jayway.jsonpath.Option;
 import java.util.ArrayList;
 import java.util.List;
+import lombok.Getter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /** JSON Protocol Filter. */
+@Getter
 public class JsonProtocolFilter {
 
     /** Default filter to match anything. */
@@ -59,15 +61,6 @@ public class JsonProtocolFilter {
         this.setRule(rule);
     }
 
-    /**
-     * Gets the filter expression rule.
-     *
-     * @return the filter expression associated with this JsonProtocolFilter
-     */
-    public String getRule() {
-        return this.rule;
-    }
-
     /**
      * Sets the filter expression rule.
      *
index d341024..3fea682 100644 (file)
@@ -22,6 +22,7 @@ package org.onap.policy.drools.protocol.coders;
 
 import java.util.ArrayList;
 import java.util.List;
+import lombok.ToString;
 import org.onap.policy.drools.controller.DroolsController;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -30,6 +31,7 @@ import org.slf4j.LoggerFactory;
  * Protocol Coder that does its best attempt to decode/encode, selecting the best class and best fitted json parsing
  * tools.
  */
+@ToString
 class MultiplexorEventProtocolCoder implements EventProtocolCoder {
 
     /**
@@ -281,16 +283,4 @@ class MultiplexorEventProtocolCoder implements EventProtocolCoder {
     public List<DroolsController> getDroolsControllers(String topic, Object encodedClass) {
         return this.encoders.getDroolsControllers(topic, encodedClass);
     }
-
-    /**
-     * {@inheritDoc}.
-     */
-    @Override
-    public String toString() {
-        return "MultiplexorEventProtocolCoder [decoders="
-                + decoders
-                + ", encoders="
-                + encoders
-                + "]";
-    }
 }
index 7cf3a2f..493095b 100644 (file)
@@ -24,6 +24,9 @@ package org.onap.policy.drools.protocol.coders;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
 import org.onap.policy.drools.protocol.coders.EventProtocolCoder.CoderFilters;
 import org.onap.policy.drools.protocol.coders.TopicCoderFilterConfiguration.CustomCoder;
 import org.slf4j.Logger;
@@ -32,6 +35,8 @@ import org.slf4j.LoggerFactory;
 /**
  * Protocol Coding/Decoding Toolset.
  */
+@Getter
+@ToString
 public abstract class ProtocolCoderToolset {
 
     /**
@@ -67,6 +72,7 @@ public abstract class ProtocolCoderToolset {
     /**
      * custom coder.
      */
+    @Setter
     protected CustomCoder customCoder;
 
     /**
@@ -90,7 +96,7 @@ public abstract class ProtocolCoderToolset {
                 eventProtocolParams.getEventClass(),
                 eventProtocolParams.getProtocolFilter(),
                 eventProtocolParams.getModelClassLoaderHash()));
-        this.customCoder = eventProtocolParams.getCustomCoder();
+        this.customCoder = eventProtocolParams.getCustomGsonCoder();
     }
 
     /**
@@ -133,9 +139,9 @@ public abstract class ProtocolCoderToolset {
         }
 
         for (final CoderFilters coder : this.coders) {
-            if (coder.getCodedClass().equals(eventClass)) {
+            if (coder.getFactClass().equals(eventClass)) {
                 coder.setFilter(filter);
-                coder.setFromClassLoaderHash(modelClassLoaderHash);
+                coder.setModelClassLoaderHash(modelClassLoaderHash);
                 return;
             }
         }
@@ -162,60 +168,6 @@ public abstract class ProtocolCoderToolset {
         this.coders.removeAll(temp);
     }
 
-    /**
-     * gets the topic.
-     *
-     * @return the topic
-     */
-    public String getTopic() {
-        return this.topic;
-    }
-
-    /**
-     * gets the controller id.
-     *
-     * @return the controller id
-     */
-    public String getControllerId() {
-        return this.controllerId;
-    }
-
-    /**
-     * Get group id.
-     *
-     * @return the groupId
-     */
-    public String getGroupId() {
-        return this.groupId;
-    }
-
-    /**
-     * Get artifact id.
-     *
-     * @return the artifactId
-     */
-    public String getArtifactId() {
-        return this.artifactId;
-    }
-
-    /**
-     * Get custom coder.
-     *
-     * @return the customCoder
-     */
-    public CustomCoder getCustomCoder() {
-        return this.customCoder;
-    }
-
-    /**
-     * Set custom coder.
-     *
-     * @param customCoder the customCoder to set.
-     */
-    public void setCustomCoder(CustomCoder customCoder) {
-        this.customCoder = customCoder;
-    }
-
     /**
      * performs filtering on a json string.
      *
@@ -274,14 +226,4 @@ public abstract class ProtocolCoderToolset {
      * @throws UnsupportedOperationException if parsing into POJO is not possible
      */
     public abstract String encode(Object event);
-
-    @Override
-    public String toString() {
-        final StringBuilder builder = new StringBuilder();
-        builder.append("ProtocolCoderToolset [topic=").append(this.topic).append(", controllerId=")
-        .append(this.controllerId).append(", groupId=").append(this.groupId).append(", artifactId=")
-        .append(this.artifactId).append(", coders=").append(this.coders)
-        .append(", customCoder=").append(this.customCoder).append("]");
-        return builder.toString();
-    }
 }
index 9da4852..4dd132b 100644 (file)
 package org.onap.policy.drools.protocol.coders;
 
 import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
 
+@Getter
+@ToString
 public class TopicCoderFilterConfiguration {
 
     /**
      * Custom coder, contains class and static field to access parser that the controller desires to
      * use instead of the framework provided parser.
      */
+    @Getter
+    @Setter
+    @ToString
     public abstract static class CustomCoder {
-        protected String className;
+        protected String classContainer;
         protected String staticCoderField;
 
         /**
@@ -44,8 +53,8 @@ public class TopicCoderFilterConfiguration {
         protected CustomCoder(String rawCustomCoder) {
             if (rawCustomCoder != null && !rawCustomCoder.isEmpty()) {
 
-                this.className = rawCustomCoder.substring(0, rawCustomCoder.indexOf(','));
-                if (this.className == null || this.className.isEmpty()) {
+                this.classContainer = rawCustomCoder.substring(0, rawCustomCoder.indexOf(','));
+                if (this.classContainer == null || this.classContainer.isEmpty()) {
                     throw new IllegalArgumentException(
                             "No classname to create CustomCoder cannot be created");
                 }
@@ -53,7 +62,7 @@ public class TopicCoderFilterConfiguration {
                 this.staticCoderField = rawCustomCoder.substring(rawCustomCoder.indexOf(',') + 1);
                 if (this.staticCoderField == null || this.staticCoderField.isEmpty()) {
                     throw new IllegalArgumentException(
-                            "No staticCoderField to create CustomCoder cannot be created for class " + className);
+                            "No staticCoderField to create CustomCoder cannot be created for class " + classContainer);
                 }
             }
         }
@@ -74,59 +83,12 @@ public class TopicCoderFilterConfiguration {
                         "No staticCoderField to create CustomCoder cannot be created for class " + className);
             }
 
-            this.className = className;
+            this.classContainer = className;
             this.staticCoderField = staticCoderField;
         }
-
-        /**
-         * Get class container.
-         *
-         * @return the className
-         **/
-        public String getClassContainer() {
-            return className;
-        }
-
-        /**
-         * Set class container.
-         *
-         * @param className the className to set
-         **/
-        public void setClassContainer(String className) {
-            this.className = className;
-        }
-
-        /**
-         * Get static coder field.
-         *
-         * @return the staticCoderField
-         **/
-        public String getStaticCoderField() {
-            return staticCoderField;
-        }
-
-        /**
-         * Set static coder field.
-         *
-         * @param staticCoderField the staticGson to set
-         **/
-        public void setStaticCoderField(String staticCoderField) {
-            this.staticCoderField = staticCoderField;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder builder = new StringBuilder();
-            builder
-                .append("CustomCoder [className=")
-                .append(className)
-                .append(", staticCoderField=")
-                .append(staticCoderField)
-                .append("]");
-            return builder.toString();
-        }
     }
 
+    @ToString(callSuper = true)
     public static class CustomGsonCoder extends CustomCoder {
 
         public CustomGsonCoder(String className, String staticCoderField) {
@@ -136,19 +98,16 @@ public class TopicCoderFilterConfiguration {
         public CustomGsonCoder(String customGson) {
             super(customGson);
         }
-
-        @Override
-        public String toString() {
-            StringBuilder builder = new StringBuilder();
-            builder.append("CustomGsonCoder [toString()=").append(super.toString()).append("]");
-            return builder.toString();
-        }
     }
 
     /**
      * Coder/Decoder class and Filter container. The decoder class is potential, in order to be
      * operational needs to be fetched from an available class loader.
      */
+    @Getter
+    @Setter
+    @ToString
+    @AllArgsConstructor
     public static class PotentialCoderFilter {
 
         /* decoder class (pending from being able to be fetched and found in some class loader) */
@@ -156,64 +115,6 @@ public class TopicCoderFilterConfiguration {
 
         /* filters to apply to the selection of the decodedClass */
         protected JsonProtocolFilter filter;
-
-        /**
-         * constructor.
-         *
-         * @param codedClass decoder class
-         * @param filter filters to apply
-         */
-        public PotentialCoderFilter(String codedClass, JsonProtocolFilter filter) {
-            this.codedClass = codedClass;
-            this.filter = filter;
-        }
-
-        /**
-         * Get coded class.
-         *
-         * @return the decodedClass
-         **/
-        public String getCodedClass() {
-            return codedClass;
-        }
-
-        /** Set coded class.
-         *
-         * @param decodedClass the decodedClass to set
-         **/
-        public void setCodedClass(String decodedClass) {
-            this.codedClass = decodedClass;
-        }
-
-        /**
-         * Get filter.
-         *
-         * @return the filter
-         **/
-        public JsonProtocolFilter getFilter() {
-            return filter;
-        }
-
-        /**
-         * Set filter.
-         *
-         * @param filter the filter to set
-         **/
-        public void setFilter(JsonProtocolFilter filter) {
-            this.filter = filter;
-        }
-
-        @Override
-        public String toString() {
-            StringBuilder builder = new StringBuilder();
-            builder
-                .append("PotentialCoderFilter [codedClass=")
-                .append(codedClass)
-                .append(", filter=")
-                .append(filter)
-                .append("]");
-            return builder.toString();
-        }
     }
 
     /* the source topic */
@@ -223,6 +124,7 @@ public class TopicCoderFilterConfiguration {
     protected final List<PotentialCoderFilter> coderFilters;
 
     /* custom gson coder that this controller prefers to use instead of the framework ones */
+    @Setter
     protected CustomGsonCoder customGsonCoder;
 
     /**
@@ -240,52 +142,4 @@ public class TopicCoderFilterConfiguration {
         this.topic = topic;
         this.customGsonCoder = customGsonCoder;
     }
-
-    /**
-     * Get topic.
-     * @return the topic
-     **/
-    public String getTopic() {
-        return topic;
-    }
-
-    /** Get coder filters.
-     *
-     * @return the decoderFilters
-     **/
-    public List<PotentialCoderFilter> getCoderFilters() {
-        return coderFilters;
-    }
-
-    /**
-     * Get custom gson coder.
-     *
-     * @return the customGsonCoder
-     **/
-    public CustomGsonCoder getCustomGsonCoder() {
-        return customGsonCoder;
-    }
-
-    /**
-     * Set custom gson coder.
-     *
-     * @param customGsonCoder the customGsonCoder to set
-     **/
-    public void setCustomGsonCoder(CustomGsonCoder customGsonCoder) {
-        this.customGsonCoder = customGsonCoder;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder
-            .append("TopicCoderFilterConfiguration [topic=")
-            .append(topic)
-            .append(", coderFilters=")
-            .append(coderFilters)
-            .append(", customGsonCoder=")
-            .append(customGsonCoder)
-            .append("]");
-        return builder.toString();
-    }
 }
index 663d6b8..9b19b8a 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.
@@ -22,9 +22,9 @@ package org.onap.policy.drools.protocol.configuration;
 
 import java.util.HashMap;
 import java.util.Map;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
 import lombok.ToString;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter;
 import org.onap.policy.common.gson.annotation.GsonJsonAnySetter;
 import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
@@ -36,6 +36,8 @@ import org.onap.policy.common.gson.annotation.GsonJsonProperty;
  *
  */
 @ToString
+@EqualsAndHashCode
+@NoArgsConstructor
 public class ControllerConfiguration {
 
     public static final String CONFIG_CONTROLLER_OPERATION_CREATE = "create";
@@ -43,6 +45,8 @@ public class ControllerConfiguration {
     public static final String CONFIG_CONTROLLER_OPERATION_LOCK = "lock";
     public static final String CONFIG_CONTROLLER_OPERATION_UNLOCK = "unlock";
 
+    protected static final Object NOT_FOUND_VALUE = new Object();
+
     /**
      * (Required).
      *
@@ -66,15 +70,6 @@ public class ControllerConfiguration {
     @GsonJsonIgnore
     private Map<String, Object> additionalProperties = new HashMap<>();
 
-    protected static final Object NOT_FOUND_VALUE = new Object();
-
-    /**
-     * No args constructor for use in serialization.
-     *
-     */
-    public ControllerConfiguration() {
-        // Empty
-    }
 
     /**
      * Constructor.
@@ -260,25 +255,6 @@ public class ControllerConfiguration {
         return this;
     }
 
-    @Override
-    public int hashCode() {
-        return new HashCodeBuilder().append(name).append(operation).append(drools).append(additionalProperties)
-                .toHashCode();
-    }
-
-    @Override
-    public boolean equals(Object other) {
-        if (other == this) {
-            return true;
-        }
-        if (!(other instanceof ControllerConfiguration)) {
-            return false;
-        }
-        ControllerConfiguration rhs = ((ControllerConfiguration) other);
-        return new EqualsBuilder().append(name, rhs.name).append(operation, rhs.operation).append(drools, rhs.drools)
-                .append(additionalProperties, rhs.additionalProperties).isEquals();
-    }
-
     /**
      * Call set name.
      *
index 1d4fc8d..b39d005 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.
@@ -22,9 +22,9 @@ package org.onap.policy.drools.protocol.configuration;
 
 import java.util.HashMap;
 import java.util.Map;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
 import lombok.ToString;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter;
 import org.onap.policy.common.gson.annotation.GsonJsonAnySetter;
 import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
@@ -35,8 +35,12 @@ import org.onap.policy.common.gson.annotation.GsonJsonProperty;
  *
  */
 @ToString
+@EqualsAndHashCode
+@NoArgsConstructor
 public class DroolsConfiguration {
 
+    protected static final Object NOT_FOUND_VALUE = new Object();
+
     /**
      * Maven Artifact ID
      * (Required).
@@ -64,15 +68,6 @@ public class DroolsConfiguration {
     @GsonJsonIgnore
     private Map<String, Object> additionalProperties = new HashMap<>();
 
-    protected static final Object NOT_FOUND_VALUE = new Object();
-
-    /**
-     * No args constructor for use in serialization.
-     *
-     */
-    public DroolsConfiguration() {
-        // Empty
-    }
 
     /**
      * Constructor.
@@ -262,26 +257,6 @@ public class DroolsConfiguration {
         return this;
     }
 
-    @Override
-    public int hashCode() {
-        return new HashCodeBuilder().append(artifactId).append(groupId).append(version).append(additionalProperties)
-                .toHashCode();
-    }
-
-    @Override
-    public boolean equals(Object other) {
-        if (other == this) {
-            return true;
-        }
-        if (!(other instanceof DroolsConfiguration)) {
-            return false;
-        }
-        DroolsConfiguration rhs = ((DroolsConfiguration) other);
-        return new EqualsBuilder().append(artifactId, rhs.artifactId)
-                .append(groupId, rhs.groupId).append(version, rhs.version)
-                .append(additionalProperties, rhs.additionalProperties).isEquals();
-    }
-
     /**
      * Call set artifact id.
      *
index 6596408..f3a422e 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.
@@ -24,9 +24,9 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
 import lombok.ToString;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter;
 import org.onap.policy.common.gson.annotation.GsonJsonAnySetter;
 import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
@@ -37,11 +37,15 @@ import org.onap.policy.common.gson.annotation.GsonJsonProperty;
  * ENGINE-CONFIGURATION.
  */
 @ToString
+@EqualsAndHashCode
+@NoArgsConstructor
 public class PdpdConfiguration {
 
     /** Controller Entity ID. */
     public static final String CONFIG_ENTITY_CONTROLLER = "controller";
 
+    protected static final Object NOT_FOUND_VALUE = new Object();
+
     /** Unique Transaction ID. This is an UUID. (Required) */
     @GsonJsonProperty("requestID")
     private String requestId;
@@ -53,12 +57,6 @@ public class PdpdConfiguration {
     private List<ControllerConfiguration> controllers = new ArrayList<>();
 
     @GsonJsonIgnore private Map<String, Object> additionalProperties = new HashMap<>();
-    protected static final Object NOT_FOUND_VALUE = new Object();
-
-    /** No args constructor for use in serialization. */
-    public PdpdConfiguration() {
-        // Empty
-    }
 
     /**
      * Constructor.
@@ -231,33 +229,6 @@ public class PdpdConfiguration {
         return this;
     }
 
-    @Override
-    public int hashCode() {
-        return new HashCodeBuilder()
-                .append(requestId)
-                .append(entity)
-                .append(controllers)
-                .append(additionalProperties)
-                .toHashCode();
-    }
-
-    @Override
-    public boolean equals(Object other) {
-        if (other == this) {
-            return true;
-        }
-        if (!(other instanceof PdpdConfiguration)) {
-            return false;
-        }
-        PdpdConfiguration rhs = (PdpdConfiguration) other;
-        return new EqualsBuilder()
-                .append(requestId, rhs.requestId)
-                .append(entity, rhs.entity)
-                .append(controllers, rhs.controllers)
-                .append(additionalProperties, rhs.additionalProperties)
-                .isEquals();
-    }
-
     /**
      * Call set request id.
      *
index 99b0ce6..4374eb8 100644 (file)
@@ -54,6 +54,10 @@ import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
 import org.onap.policy.common.endpoints.event.comm.Topic;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
@@ -92,6 +96,7 @@ import org.slf4j.LoggerFactory;
         produces = {MediaType.APPLICATION_JSON, YamlMessageBodyHandler.APPLICATION_YAML},
         schemes = {SwaggerDefinition.Scheme.HTTP},
         tags = {@Tag(name = "pdp-d-telemetry", description = "Drools PDP Telemetry Operations")})
+@ToString
 public class RestManager {
 
     private static final String OFFER_FAILED = "{}: cannot offer to topic {} because of {}";
@@ -2143,14 +2148,11 @@ public class RestManager {
      * Helper classes for aggregation of results
      */
 
-    @Override
-    public String toString() {
-        return "rest-telemetry-api []";
-    }
-
     /**
      * Coding/Encoding Results Aggregation Helper class.
      */
+    @Getter
+    @Setter
     public static class CodingResult {
         /**
          * serialized output.
@@ -2167,42 +2169,15 @@ public class RestManager {
          * decoding result.
          */
         private Boolean decoding;
-
-        public String getJsonEncoding() {
-            return jsonEncoding;
-        }
-
-        public void setJsonEncoding(String jsonEncoding) {
-            this.jsonEncoding = jsonEncoding;
-        }
-
-        public Boolean getEncoding() {
-            return encoding;
-        }
-
-        public void setEncoding(Boolean encoding) {
-            this.encoding = encoding;
-        }
-
-        public Boolean getDecoding() {
-            return decoding;
-        }
-
-        public void setDecoding(Boolean decoding) {
-            this.decoding = decoding;
-        }
     }
 
     /**
      * Generic Error Reporting class.
      */
+    @AllArgsConstructor
     public static class Error {
         private String msg;
 
-        public Error(String msg) {
-            this.setError(msg);
-        }
-
         public String getError() {
             return msg;
         }
@@ -2212,4 +2187,3 @@ public class RestManager {
         }
     }
 }
-
index be0cb82..c28d4c9 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.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
 package org.onap.policy.drools.system;
 
 import java.util.Properties;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
 import org.onap.policy.common.endpoints.http.client.HttpClientConfigException;
@@ -39,16 +41,13 @@ import org.slf4j.LoggerFactory;
 /**
  * Programmatic entry point to the management layer.
  */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
 public class Main {
     /**
      * Symmetric Key to decode sensitive configuration data.
      */
     protected static final String SYSTEM_SYMM_KEY = "engine.symm.key";
 
-    /** constructor (hides public default one). */
-    private Main() {
-    }
-
     /**
      * main.
      *
@@ -62,7 +61,7 @@ public class Main {
          */
 
         /* start logger */
-        Logger logger = LoggerFactory.getLogger(Main.class);
+        var logger = LoggerFactory.getLogger(Main.class);
 
         /* system properties */
         setSystemProperties();
@@ -191,7 +190,7 @@ public class Main {
                         .setTargetEntity("controller:" + controllerName)
                         .setTargetServiceName("start");
 
-                final PolicyController controller =
+                final var controller =
                         PolicyEngineConstants.getManager().createPolicyController(controllerName, controllerProperties);
                 controller.start();
 
@@ -226,4 +225,4 @@ public class Main {
             }
         }
     }
-}
\ No newline at end of file
+}
index 78d2412..c04cc0d 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.
 
 package org.onap.policy.drools.system;
 
+import lombok.AccessLevel;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 
-public class PolicyControllerConstants {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class PolicyControllerConstants {
 
     /**
      * Factory that tracks and manages Policy Controllers.
      */
     @Getter
     private static final PolicyControllerFactory factory = new IndexedPolicyControllerFactory();
-
-    private PolicyControllerConstants() {
-        // do nothing
-    }
 }
index 2173687..23fc247 100644 (file)
 
 package org.onap.policy.drools.system;
 
+import lombok.AccessLevel;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import org.onap.policy.common.utils.network.NetworkUtil;
 
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class PolicyEngineConstants {
 
     /**
@@ -50,8 +53,4 @@ public final class PolicyEngineConstants {
      */
     @Getter
     private static final PolicyEngine manager = new PolicyEngineManager();
-
-    private PolicyEngineConstants() {
-        // do nothing
-    }
 }
index ec24286..664f7c7 100644 (file)
@@ -39,6 +39,7 @@ import java.util.stream.Stream;
 import lombok.AccessLevel;
 import lombok.Getter;
 import lombok.NonNull;
+import lombok.ToString;
 import org.apache.commons.lang3.StringUtils;
 import org.onap.policy.common.endpoints.event.comm.Topic;
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
@@ -88,6 +89,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Policy Engine Manager Implementation.
  */
+@ToString(onlyExplicitlyIncluded = true)
 class PolicyEngineManager implements PolicyEngine {
     /**
      * String literals.
@@ -110,12 +112,14 @@ class PolicyEngineManager implements PolicyEngine {
      * Is the Policy Engine running.
      */
     @Getter
+    @ToString.Include
     private volatile boolean alive = false;
 
     /**
      * Is the engine locked.
      */
     @Getter
+    @ToString.Include
     private volatile boolean locked = false;
 
     /**
@@ -1350,11 +1354,6 @@ class PolicyEngineManager implements PolicyEngine {
                         && policyControllers.size() == configControllers.size());
     }
 
-    @Override
-    public String toString() {
-        return "PolicyEngineManager [alive=" + this.alive + ", locked=" + this.locked + "]";
-    }
-
     // these methods may be overridden by junit tests
 
     protected List<PolicyEngineFeatureApi> getEngineProviders() {
index 44b07a5..06b3f4e 100644 (file)
@@ -28,6 +28,8 @@ import java.util.List;
 import java.util.Properties;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
+import lombok.Getter;
+import lombok.ToString;
 import org.onap.policy.common.endpoints.event.comm.Topic;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpoint;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
@@ -55,6 +57,7 @@ import org.slf4j.LoggerFactory;
  * This implementation of the Policy Controller merely aggregates and tracks for management purposes
  * all underlying resources that this controller depends upon.
  */
+@ToString(onlyExplicitlyIncluded = true)
 public class AggregatedPolicyController implements PolicyController, TopicListener {
 
     private static final String BEFORE_OFFER_FAILURE = "{}: feature {} before-offer failure because of {}";
@@ -69,17 +72,21 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
     /**
      * identifier for this policy controller.
      */
+    @Getter
+    @ToString.Include
     private final String name;
 
     /**
      * Abstracted Event Sources List regardless communication technology.
      */
-    protected final List<TopicSource> sources;
+    @Getter
+    protected final List<TopicSource> topicSources;
 
     /**
      * Abstracted Event Sinks List regardless communication technology.
      */
-    protected final List<TopicSink> sinks;
+    @Getter
+    protected final List<TopicSink> topicSinks;
 
     /**
      * Mapping topics to sinks.
@@ -90,6 +97,8 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
     /**
      * Is this Policy Controller running (alive) ? reflects invocation of start()/stop() only.
      */
+    @Getter
+    @ToString.Include
     private volatile boolean alive;
 
     /**
@@ -97,11 +106,14 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
      * are permitted, more specifically: start(), deliver() and onTopicEvent(). It does not affect
      * the ability to stop the underlying drools infrastructure
      */
+    @Getter
+    @ToString.Include
     private volatile boolean locked;
 
     /**
      * Policy Drools Controller.
      */
+    @ToString.Include
     protected final AtomicReference<DroolsController> droolsController = new AtomicReference<>();
 
     /**
@@ -135,8 +147,8 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
 
         // Create/Reuse Readers/Writers for all event sources endpoints
 
-        this.sources = getEndpointManager().addTopicSources(properties);
-        this.sinks = getEndpointManager().addTopicSinks(properties);
+        this.topicSources = getEndpointManager().addTopicSources(properties);
+        this.topicSinks = getEndpointManager().addTopicSinks(properties);
 
         initDrools(properties);
         initSinks();
@@ -192,7 +204,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
     protected void initDrools(Properties properties) {
         try {
             // Register with drools infrastructure
-            this.droolsController.set(getDroolsFactory().build(properties, sources, sinks));
+            this.droolsController.set(getDroolsFactory().build(properties, topicSources, topicSinks));
         } catch (Exception | LinkageError e) {
             logger.error("{}: cannot init-drools", this);
             throw new IllegalArgumentException(e);
@@ -206,7 +218,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
      */
     private void initSinks() {
         this.topic2Sinks.clear();
-        for (TopicSink sink : sinks) {
+        for (TopicSink sink : topicSinks) {
             this.topic2Sinks.put(sink.getTopic(), sink);
         }
     }
@@ -280,14 +292,6 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
         return finalSuccess;
     }
 
-    /**
-     * {@inheritDoc}.
-     */
-    @Override
-    public String getName() {
-        return this.name;
-    }
-
     /**
      * {@inheritDoc}.
      */
@@ -318,11 +322,11 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
 
         // register for events
 
-        for (TopicSource source : sources) {
+        for (TopicSource source : topicSources) {
             source.register(this);
         }
 
-        for (TopicSink sink : sinks) {
+        for (TopicSink sink : topicSinks) {
             try {
                 sink.start();
             } catch (Exception e) {
@@ -364,7 +368,7 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
 
         // 1. Stop registration
 
-        for (TopicSource source : sources) {
+        for (TopicSource source : topicSources) {
             source.unregister(this);
         }
 
@@ -528,14 +532,6 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
         return success;
     }
 
-    /**
-     * {@inheritDoc}.
-     */
-    @Override
-    public boolean isAlive() {
-        return this.alive;
-    }
-
     /**
      * {@inheritDoc}.
      */
@@ -604,30 +600,6 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
         return success;
     }
 
-    /**
-     * {@inheritDoc}.
-     */
-    @Override
-    public boolean isLocked() {
-        return this.locked;
-    }
-
-    /**
-     * {@inheritDoc}.
-     */
-    @Override
-    public List<TopicSource> getTopicSources() {
-        return this.sources;
-    }
-
-    /**
-     * {@inheritDoc}.
-     */
-    @Override
-    public List<TopicSink> getTopicSinks() {
-        return this.sinks;
-    }
-
     /**
      * {@inheritDoc}.
      */
@@ -646,12 +618,6 @@ public class AggregatedPolicyController implements PolicyController, TopicListen
         return this.properties;
     }
 
-    @Override
-    public String toString() {
-        return "AggregatedPolicyController [name=" + name + ", alive=" + alive
-                + ", locked=" + locked + ", droolsController=" + droolsController + "]";
-    }
-
     // the following methods may be overridden by junit tests
 
     protected SystemPersistence getPersistenceManager() {
index 88037bb..1683b0f 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import lombok.AccessLevel;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import org.onap.policy.drools.core.lock.AlwaysFailLock;
 import org.onap.policy.drools.core.lock.Lock;
 import org.onap.policy.drools.core.lock.LockCallback;
@@ -45,6 +46,8 @@ import org.slf4j.LoggerFactory;
  * will be added to the map once free() or extend() is invoked, provided there isn't
  * already an entry.
  */
+@Getter
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
 public abstract class LockManager<T extends FeatureLockImpl> implements PolicyResourceLockManager {
 
     private static final Logger logger = LoggerFactory.getLogger(LockManager.class);
@@ -68,18 +71,6 @@ public abstract class LockManager<T extends FeatureLockImpl> implements PolicyRe
     private boolean locked = false;
 
 
-    /**
-     * Constructs the object.
-     */
-    protected LockManager() {
-        super();
-    }
-
-    @Override
-    public boolean isAlive() {
-        return alive;
-    }
-
     @Override
     public synchronized boolean start() {
         if (alive) {
@@ -108,11 +99,6 @@ public abstract class LockManager<T extends FeatureLockImpl> implements PolicyRe
         stop();
     }
 
-    @Override
-    public boolean isLocked() {
-        return locked;
-    }
-
     @Override
     public synchronized boolean lock() {
         if (locked) {
index c2c921f..855d18b 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.
@@ -232,7 +232,7 @@ public class SimpleLockManager extends LockManager<SimpleLockManager.SimpleLock>
                 return false;
             }
 
-            AtomicBoolean result = new AtomicBoolean(false);
+            var result = new AtomicBoolean(false);
 
             resource2lock.computeIfPresent(getResourceId(), (resourceId, curlock) -> {
 
index 521666e..1384501 100644 (file)
@@ -431,7 +431,7 @@ public class MavenDroolsController2Test {
         // validate parameters
         EventProtocolParams params = dec.getAllValues().get(0);
         assertEquals(ARTIFACT, params.getArtifactId());
-        assertEquals(gson1, params.getCustomCoder());
+        assertEquals(gson1, params.getCustomGsonCoder());
         assertEquals(Object.class.getName(), params.getEventClass());
         assertEquals(GROUP, params.getGroupId());
         assertEquals(CLASS_LOADER_HASHCODE, params.getModelClassLoaderHash());
@@ -440,7 +440,7 @@ public class MavenDroolsController2Test {
 
         params = dec.getAllValues().get(1);
         assertEquals(ARTIFACT, params.getArtifactId());
-        assertEquals(gson1, params.getCustomCoder());
+        assertEquals(gson1, params.getCustomGsonCoder());
         assertEquals(String.class.getName(), params.getEventClass());
         assertEquals(GROUP, params.getGroupId());
         assertEquals(CLASS_LOADER_HASHCODE, params.getModelClassLoaderHash());
@@ -449,7 +449,7 @@ public class MavenDroolsController2Test {
 
         params = enc.getAllValues().get(0);
         assertEquals(ARTIFACT, params.getArtifactId());
-        assertEquals(gson2, params.getCustomCoder());
+        assertEquals(gson2, params.getCustomGsonCoder());
         assertEquals(Integer.class.getName(), params.getEventClass());
         assertEquals(GROUP, params.getGroupId());
         assertEquals(CLASS_LOADER_HASHCODE, params.getModelClassLoaderHash());
index 2fc1467..b6168a2 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 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.
@@ -24,6 +24,8 @@ package org.onap.policy.drools.protocol.coders;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Properties;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
 import org.junit.Test;
 import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
 import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
@@ -57,22 +59,10 @@ public class EventProtocolCoderTest {
     /**
      * Event Test Class.
      */
+    @Getter
+    @AllArgsConstructor
     public static class EventTest {
-
         private String field;
-
-        public EventTest(String field) {
-            super();
-            this.field = field;
-        }
-
-        public String getField() {
-            return this.field;
-        }
-
-        public void setField(String field) {
-            this.field = field;
-        }
     }
 
     @Test
@@ -87,7 +77,7 @@ public class EventProtocolCoderTest {
                 EventProtocolParams.builder().groupId(ENCODER_GROUP).artifactId(ENCODER_ARTIFACT)
                         .topic(NOOP_TOPIC).eventClass(DroolsConfiguration.class.getName())
                         .protocolFilter(new JsonProtocolFilter()).customGsonCoder(null)
-                        .modelClassLoaderHash(DroolsConfiguration.class.getName().hashCode()));
+                        .modelClassLoaderHash(DroolsConfiguration.class.getName().hashCode()).build());
 
         final String json = EventProtocolCoderConstants.getManager().encode(NOOP_TOPIC,
                 new DroolsConfiguration(ENCODER_ARTIFACT, ENCODER_GROUP, ENCODER_VERSION));
index abf9b38..7920723 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 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.
@@ -108,7 +108,7 @@ public class ProtocolCoderToolsetTest {
                         new GsonProtocolCoderToolset(EventProtocolParams.builder().topic(JUNIT_PROTOCOL_CODER_TOPIC)
                                         .groupId(releaseId.getGroupId()).artifactId(releaseId.getArtifactId())
                                         .eventClass(ThreeStrings.class.getName()).protocolFilter(protocolFilter)
-                                        .customGsonCoder(null).modelClassLoaderHash(12345678), CONTROLLER_ID);
+                                        .customGsonCoder(null).modelClassLoaderHash(12345678).build(), CONTROLLER_ID);
 
         Assert.assertNotNull(gsonToolset.getEncoder());
         Assert.assertNotNull(gsonToolset.getDecoder());
@@ -155,7 +155,7 @@ public class ProtocolCoderToolsetTest {
         }
 
         CoderFilters coderFilters = coderToolset.getCoder(ThreeStrings.class.getName());
-        Assert.assertSame(coderFilters.getCodedClass(), ThreeStrings.class.getName());
+        Assert.assertSame(coderFilters.getFactClass(), ThreeStrings.class.getName());
         Assert.assertSame(coderFilters.getFilter(), protocolFilter);
         Assert.assertNotNull(coderFilters.getFilter().getRule());
 
index 3560671..7248f11 100644 (file)
@@ -1,7 +1,8 @@
 /*-
  * ============LICENSE_START=======================================================
- * Configuration Test * ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * ONAP
+ * ================================================================================
+ * 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.
 
 package org.onap.policy.drools.protocol.configuration;
 
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Properties;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.junit.Test;
 import org.onap.policy.common.utils.gson.GsonTestUtils;
 
@@ -99,9 +100,7 @@ public class ControllerConfigurationTest {
         assertEquals(DROOLS_CONFIG2, controllerConfig2.declaredPropertyOrNotFound(DROOLS_STRING, DROOLS_CONFIG2));
         assertEquals(NAME, controllerConfig2.declaredPropertyOrNotFound("dummy", NAME));
 
-        int hashCode = new HashCodeBuilder().append(NAME2).append(OPERATION2).append(DROOLS_CONFIG2)
-                .append(additionalProperties).toHashCode();
-        assertEquals(controllerConfig2.hashCode(), hashCode);
+        assertThat(controllerConfig2.hashCode()).isNotZero();
     }
 
     @Test
index a18a20b..2d1ed7e 100644 (file)
@@ -1,8 +1,8 @@
 /*-
  * ============LICENSE_START=======================================================
- * Configuration Test
+ * ONAP
  * ================================================================================
- * 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.
 
 package org.onap.policy.drools.protocol.configuration;
 
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Properties;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.junit.Test;
 import org.onap.policy.common.utils.gson.GsonTestUtils;
 
@@ -92,9 +92,7 @@ public class DroolsConfigurationTest {
         assertEquals(VERSION2, droolsConfig2.declaredPropertyOrNotFound(VERSION_STRING, VERSION2));
         assertEquals(ARTIFACT2, droolsConfig2.declaredPropertyOrNotFound("dummy", ARTIFACT2));
 
-        final int hashCode = new HashCodeBuilder().append(ARTIFACT2).append(GROUPID2).append(VERSION2)
-                .append(additionalProperties).toHashCode();
-        assertEquals(droolsConfig2.hashCode(), hashCode);
+        assertThat(droolsConfig2.hashCode()).isNotZero();
     }
 
     @Test
index b02090b..a8a0a2a 100644 (file)
@@ -1,8 +1,8 @@
 /*-
  * ============LICENSE_START=======================================================
- * Configuration Test
+ * ONAP
  * ================================================================================
- * 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.
index 1930dfb..4be25d1 100644 (file)
@@ -1783,7 +1783,7 @@ public class PolicyEngineManagerTest {
 
     @Test
     public void testToString() {
-        assertTrue(mgr.toString().startsWith("PolicyEngineManager ["));
+        assertTrue(mgr.toString().startsWith("PolicyEngineManager("));
     }
 
     /**
index 30d38ce..0fdc00a 100644 (file)
@@ -222,7 +222,7 @@ public class PolicyEngineTest {
                 EventProtocolParams.builder().groupId(ENCODER_GROUP).artifactId(ENCODER_ARTIFACT)
                         .topic(NOOP_TOPIC).eventClass(DroolsConfiguration.class.getName())
                         .protocolFilter(new JsonProtocolFilter()).customGsonCoder(null)
-                        .modelClassLoaderHash(DroolsConfiguration.class.getName().hashCode()));
+                        .modelClassLoaderHash(DroolsConfiguration.class.getName().hashCode()).build());
 
         assertTrue(PolicyEngineConstants.getManager().deliver(NOOP_TOPIC,
                 new DroolsConfiguration(ENCODER_ARTIFACT, ENCODER_GROUP, ENCODER_VERSION)));
index 6b669a2..a6aa9d9 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 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.
@@ -782,7 +782,7 @@ public class AggregatedPolicyControllerTest {
 
     @Test
     public void testToString() {
-        assertTrue(apc.toString().startsWith("AggregatedPolicyController ["));
+        assertTrue(apc.toString().startsWith("AggregatedPolicyController("));
     }
 
     private void validateDeliverFailure(String topic, String event) {
index 9d4a882..8120abd 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-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.
@@ -20,6 +20,7 @@
 
 package org.onap.policy.drools.utils;
 
+import lombok.AllArgsConstructor;
 import org.apache.commons.configuration2.interpol.Lookup;
 import org.apache.commons.lang3.StringUtils;
 import org.onap.policy.common.utils.security.CryptoCoder;
@@ -27,19 +28,11 @@ import org.onap.policy.common.utils.security.CryptoCoder;
 /**
  * Crypto Coder value look up.  Syntax:  ${enc:encoded-value}.
  */
+@AllArgsConstructor
 public class CryptoCoderValueLookup implements Lookup {
 
     protected final CryptoCoder cryptoCoder;
 
-    /**
-     * Crypto Coder Lookup.
-     *
-     * @param crypto crypto coder
-     */
-    public CryptoCoderValueLookup(CryptoCoder crypto) {
-        this.cryptoCoder = crypto;
-    }
-
     @Override
     public String lookup(String key) {
         if (StringUtils.isBlank(key)) {
index 10871e7..0e6c1ec 100644 (file)
@@ -31,6 +31,8 @@ import java.util.Set;
 import java.util.Timer;
 import java.util.TimerTask;
 import java.util.concurrent.atomic.AtomicReference;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.apache.commons.configuration2.ConfigurationConverter;
 import org.apache.commons.configuration2.SystemConfiguration;
 import org.onap.policy.common.utils.security.CryptoCoder;
@@ -41,7 +43,8 @@ import org.slf4j.LoggerFactory;
  * This class provides utilities to read properties from a properties
  * file, and optionally get notifications of future changes.
  */
-public class PropertyUtil {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class PropertyUtil {
     public static final String ENV_WITH_DEFAULT_PROPERTY_PREFIX = "envd";
     public static final String CRYPTO_CODER_PROPERTY_PREFIX = "enc";
 
index 7755177..c21fe31 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 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.
  * 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.
 
 package org.onap.policy.drools.utils;
 
+import lombok.AllArgsConstructor;
+
 /**
  * Reference to an object. Used within functional methods, where thread-safety is not
  * required.
- * 
+ *
  * @param <T> type of object contained within the reference
  */
+@AllArgsConstructor
 public class Reference<T> {
     private T value;
 
-    /**
-     * Constructor.
-     * 
-     * @param value value
-     */
-    public Reference(T value) {
-        this.value = value;
-    }
-
     /**
      * Get the value.
-     * 
+     *
      * @return the current value
      */
     public final T get() {
@@ -49,7 +43,7 @@ public class Reference<T> {
 
     /**
      * Sets the reference to point to a new value.
-     * 
+     *
      * @param newValue the new value
      */
     public final void set(T newValue) {
@@ -58,7 +52,7 @@ public class Reference<T> {
 
     /**
      * Sets the value to a new value, if the value is currently the same as the old value.
-     * 
+     *
      * @param oldValue old value
      * @param newValue new value
      * @return {@code true} if the value was updated, {@code false} otherwise
index bb6c542..8afc1e1 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * policy-utils
  * ================================================================================
- * 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.
  * 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.
@@ -20,6 +20,8 @@
 
 package org.onap.policy.drools.utils;
 
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -27,22 +29,20 @@ import org.slf4j.LoggerFactory;
  * Reflection utilities.
  *
  */
-public class ReflectionUtil {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ReflectionUtil {
 
     protected static final Logger logger = LoggerFactory.getLogger(ReflectionUtil.class);
 
-    private ReflectionUtil() {
-    }
-
     /**
      * returns (if exists) a class fetched from a given classloader.
-     * 
+     *
      * @param classLoader the class loader
      * @param className the class name
      * @return the actual class
      * @throws IllegalArgumentException if an invalid parameter has been passed in
      */
-    public static Class<?> fetchClass(ClassLoader classLoader, 
+    public static Class<?> fetchClass(ClassLoader classLoader,
             String className) {
         if (classLoader == null) {
             throw new IllegalArgumentException("A class loader must be provided");
@@ -64,7 +64,7 @@ public class ReflectionUtil {
 
     /**
      * Is class.
-     * 
+     *
      * @param classLoader target class loader
      * @param classname class name to fetch
      * @return true if exists
@@ -76,7 +76,7 @@ public class ReflectionUtil {
 
     /**
      * Is it a sub class.
-     * 
+     *
      * @param parent superclass
      * @param presumedSubclass subclass
      * @return true if it is a sub class
index b116592..7468b52 100644 (file)
@@ -23,20 +23,19 @@ package org.onap.policy.drools.utils.logging;
 import ch.qos.logback.classic.spi.ILoggingEvent;
 import ch.qos.logback.core.filter.AbstractMatcherFilter;
 import ch.qos.logback.core.spi.FilterReply;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
 import org.slf4j.Marker;
 
 /**
  * Logger Marker Filters to be used in logback.xml configuration
  * to accept/deny metric or transaction (audit) events
  */
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
 public abstract class LoggerMarkerFilter extends AbstractMatcherFilter<ILoggingEvent> {
 
     protected final Marker marker;
 
-    protected LoggerMarkerFilter(Marker marker) {
-        this.marker = marker;
-    }
-
     @Override
     public FilterReply decide(ILoggingEvent event) {
 
index e3f565d..eef0fa3 100644 (file)
@@ -21,6 +21,8 @@
 package org.onap.policy.drools.utils.logging;
 
 import ch.qos.logback.classic.LoggerContext;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Marker;
@@ -29,7 +31,8 @@ import org.slf4j.MarkerFactory;
 /**
  * Loger Utils.
  */
-public class LoggerUtil {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class LoggerUtil {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(LoggerUtil.class);
 
@@ -68,10 +71,6 @@ public class LoggerUtil {
      */
     public static final Marker TRANSACTION_LOG_MARKER = MarkerFactory.getMarker(TRANSACTION_LOG_MARKER_NAME);
 
-    private LoggerUtil() {
-        // Empty constructor
-    }
-
     /**
      * Set the log level of a logger.
      *
index 1c98eac..1db498f 100644 (file)
 
 package org.onap.policy.drools.utils.logging;
 
-public class MdcTransactionConstants {
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class MdcTransactionConstants {
     /*
      * The fields must match the naming given at
      * https://wiki.onap.org/pages/viewpage.action?pageId=20087036
@@ -170,8 +174,4 @@ public class MdcTransactionConstants {
      * Status Code Error.
      */
     public static final String STATUS_CODE_FAILURE = "ERROR";
-
-    private MdcTransactionConstants() {
-        // do nothing
-    }
 }