Use lombok in policy-common utils 18/122018/2
authorJim Hahn <jrh3@att.com>
Thu, 17 Jun 2021 17:02:08 +0000 (13:02 -0400)
committerJim Hahn <jrh3@att.com>
Thu, 17 Jun 2021 17:32:09 +0000 (13:32 -0400)
Issue-ID: POLICY-3394
Change-Id: I42a18c115c3ca7110f37fc0ae8aeea3f2bbffb37
Signed-off-by: Jim Hahn <jrh3@att.com>
22 files changed:
integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java
integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java
utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoder.java
utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoderObject.java
utils/src/main/java/org/onap/policy/common/utils/coder/YamlJsonTranslator.java
utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrCloser.java
utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloser.java
utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java
utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java
utils/src/main/java/org/onap/policy/common/utils/properties/PropertyObjectUtils.java
utils/src/main/java/org/onap/policy/common/utils/properties/SpecProperties.java
utils/src/main/java/org/onap/policy/common/utils/properties/exception/PropertyException.java
utils/src/main/java/org/onap/policy/common/utils/resources/MessageConstants.java
utils/src/main/java/org/onap/policy/common/utils/resources/ResourceUtils.java
utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java
utils/src/main/java/org/onap/policy/common/utils/services/FeatureApiUtils.java
utils/src/main/java/org/onap/policy/common/utils/services/Registry.java
utils/src/main/java/org/onap/policy/common/utils/services/ServiceManager.java
utils/src/main/java/org/onap/policy/common/utils/time/CurrentTime.java
utils/src/main/java/org/onap/policy/common/utils/validation/Assertions.java
utils/src/main/java/org/onap/policy/common/utils/validation/ParameterValidationUtils.java
utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java

index 1866bba..a8e3fbe 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Integrity Audit
  * ================================================================================
- * 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.
@@ -243,7 +243,7 @@ public class IntegrityAuditTestBase {
 
         // Clean up the DB
         try (EntityTransCloser etc = new EntityTransCloser(em.getTransaction())) {
-            EntityTransaction et = etc.getTransation();
+            EntityTransaction et = etc.getTransaction();
 
             em.createQuery("Delete from IntegrityAuditEntity").executeUpdate();
 
@@ -290,7 +290,7 @@ public class IntegrityAuditTestBase {
                 EntityTransCloser etc = new EntityTransCloser(emc.getManager().getTransaction())) {
 
             EntityManager entmgr = emc.getManager();
-            EntityTransaction entrans = etc.getTransation();
+            EntityTransaction entrans = etc.getTransaction();
 
             // Clean up the DB
             entmgr.createQuery("Delete from " + tableName).executeUpdate();
index 9ee095f..b68373b 100644 (file)
@@ -530,7 +530,7 @@ public class StateManagement {
         @Override
         public void commit() {
             synchronized (FLUSHLOCK) {
-                if (getTransation().isActive()) {
+                if (getTransaction().isActive()) {
                     super.commit();
                 }
             }
@@ -539,7 +539,7 @@ public class StateManagement {
         @Override
         public void rollback() {
             synchronized (FLUSHLOCK) {
-                if (getTransation().isActive()) {
+                if (getTransaction().isActive()) {
                     super.rollback();
                 }
             }
index 0d84f85..d6135af 100644 (file)
@@ -40,12 +40,15 @@ import java.io.Writer;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
 import org.onap.policy.common.gson.DoubleConverter;
 import org.onap.policy.common.gson.GsonMessageBodyHandler;
 
 /**
  * JSON encoder and decoder using the "standard" mechanism, which is currently gson.
  */
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
 public class StandardCoder implements Coder {
 
     /**
@@ -83,14 +86,6 @@ public class StandardCoder implements Coder {
         this(GSON_STD, GSON_STD_PRETTY);
     }
 
-    /**
-     * Constructs the object.
-     */
-    protected StandardCoder(Gson gson, Gson gsonPretty) {
-        this.gson = gson;
-        this.gsonPretty = gsonPretty;
-    }
-
     @Override
     public <S, T> T convert(S source, Class<T> clazz) throws CoderException {
         if (source == null) {
@@ -377,6 +372,7 @@ public class StandardCoder implements Coder {
     /**
      * Adapter for standard objects.
      */
+    @AllArgsConstructor
     protected static class StandardTypeAdapter extends TypeAdapter<StandardCoderObject> {
 
         /**
@@ -384,13 +380,6 @@ public class StandardCoder implements Coder {
          */
         private static TypeAdapter<JsonElement> elementAdapter = new Gson().getAdapter(JsonElement.class);
 
-        /**
-         * Constructs the object.
-         */
-        public StandardTypeAdapter() {
-            super();
-        }
-
         @Override
         public void write(JsonWriter out, StandardCoderObject value) throws IOException {
             elementAdapter.write(out, value.getData());
index f6c3ca4..55f7f9d 100644 (file)
@@ -22,12 +22,16 @@ package org.onap.policy.common.utils.coder;
 
 import com.google.gson.JsonElement;
 import java.io.Serializable;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
 
 /**
  * Object type used by the {@link StandardCoder}. Different serialization tools have
  * different "standard objects". For instance, GSON uses {@link JsonElement}. This class
  * wraps that object so that it can be used without exposing the object, itself.
  */
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
 public class StandardCoderObject implements Serializable {
     private static final long serialVersionUID = 1L;
 
@@ -38,6 +42,7 @@ public class StandardCoderObject implements Serializable {
      * this should not be transient, but since it isn't serializable, we're stuck with it
      * until there's time to address the issue
      */
+    @Getter(AccessLevel.PROTECTED)
     private final transient JsonElement data;
 
     /**
@@ -47,24 +52,6 @@ public class StandardCoderObject implements Serializable {
         data = null;
     }
 
-    /**
-     * Constructs the object.
-     *
-     * @param data data wrapped by this object.
-     */
-    protected StandardCoderObject(JsonElement data) {
-        this.data = data;
-    }
-
-    /**
-     * Gets the data wrapped by this.
-     *
-     * @return the data wrapped by this
-     */
-    protected JsonElement getData() {
-        return data;
-    }
-
     /**
      * Gets a field's value from this object, traversing the object hierarchy.
      *
index b694dd4..417e2cf 100644 (file)
@@ -34,6 +34,7 @@ import java.io.Writer;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map.Entry;
+import lombok.AllArgsConstructor;
 import org.yaml.snakeyaml.DumperOptions;
 import org.yaml.snakeyaml.Yaml;
 import org.yaml.snakeyaml.emitter.Emitter;
@@ -56,6 +57,7 @@ import org.yaml.snakeyaml.serializer.Serializer;
  * translation. In addition, the {@link #convertFromDouble(Class, Object)} method should
  * be overridden with an appropriate conversion method.
  */
+@AllArgsConstructor
 public class YamlJsonTranslator {
 
     /**
@@ -70,15 +72,6 @@ public class YamlJsonTranslator {
         this(new Gson());
     }
 
-    /**
-     * Constructs the object.
-     *
-     * @param gson the Gson object to be used to serialize and de-serialize
-     */
-    public YamlJsonTranslator(Gson gson) {
-        this.gson = gson;
-    }
-
     /**
      * Translates a POJO into a YAML String.
      *
index 3532002..f975422 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * Common Utils
  * ================================================================================
- * 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.common.utils.jpa;
 
 import javax.persistence.EntityManager;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
 
 /**
  * Wrapper for an <i>EntityManager</i>, providing auto-close functionality. This is useful in
  * try-with-resources statements.
  */
+@AllArgsConstructor
 public class EntityMgrCloser implements AutoCloseable {
 
     /**
      * The wrapped manager.
      */
-    private final EntityManager em;
-
-    /**
-     * Construct an instance with the EntityManager.
-     * 
-     * @param em manager to be auto-closed
-     */
-    public EntityMgrCloser(EntityManager em) {
-        this.em = em;
-    }
-
-    /**
-     * Gets the EntityManager wrapped within this object.
-     * 
-     * @return the associated EntityManager
-     */
-    public EntityManager getManager() {
-        return em;
-    }
+    @Getter
+    private final EntityManager manager;
 
     @Override
     public void close() {
-        em.close();
+        manager.close();
     }
 
 }
index b046cc5..8901277 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * Common Utils
  * ================================================================================
- * 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.common.utils.jpa;
 
 import javax.persistence.EntityManagerFactory;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
 
 /**
  * Wrapper for an <i>EntityManagerFactory</i>, providing auto-close functionality. This is useful in
  * try-with-resources statements.
  */
+@AllArgsConstructor
 public class EntityMgrFactoryCloser implements AutoCloseable {
 
     /**
      * The wrapped factory.
      */
-    private final EntityManagerFactory emf;
-
-    /**
-     * Construct an instance with the given EntityManagerFactory.
-     * 
-     * @param emf manager to be auto-closed
-     */
-    public EntityMgrFactoryCloser(EntityManagerFactory emf) {
-        this.emf = emf;
-    }
-
-    /**
-     * Gets the EntityManagerFactory wrapped within this object.
-     * 
-     * @return the associated EntityManagerFactory
-     */
-    public EntityManagerFactory getFactory() {
-        return emf;
-    }
+    @Getter
+    private final EntityManagerFactory factory;
 
     @Override
     public void close() {
-        emf.close();
+        factory.close();
     }
 
 }
index 3552a6f..bc5623b 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * Common Utils
  * ================================================================================
- * 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.
@@ -21,6 +21,7 @@
 package org.onap.policy.common.utils.jpa;
 
 import javax.persistence.EntityTransaction;
+import lombok.Getter;
 
 /**
  * Wrapper for an <i>EntityTransaction</i> that is auto-rolled back when closed. This is useful in
@@ -31,46 +32,37 @@ public class EntityTransCloser implements AutoCloseable {
     /**
      * Transaction to be rolled back.
      */
-    private final EntityTransaction trans;
+    @Getter
+    private final EntityTransaction transaction;
 
     /**
      * Begins a transaction.
-     * 
+     *
      * @param et transaction to wrap/begin
      */
     public EntityTransCloser(EntityTransaction et) {
-        trans = et;
-        trans.begin();
-    }
-
-    /**
-     * Gets the wrapped transaction.
-     * 
-     * @return the transaction
-     */
-    public EntityTransaction getTransation() {
-        return trans;
+        transaction = et;
+        transaction.begin();
     }
 
     /**
      * Commits the transaction.
      */
     public void commit() {
-        trans.commit();
+        transaction.commit();
     }
 
     /**
      * Rolls back the transaction.
      */
     public void rollback() {
-        trans.rollback();
+        transaction.rollback();
     }
 
     @Override
     public void close() {
-        if (trans.isActive()) {
-            trans.rollback();
+        if (transaction.isActive()) {
+            transaction.rollback();
         }
     }
-
 }
index a0a8390..e3539fb 100644 (file)
@@ -27,6 +27,8 @@ import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.UnknownHostException;
 import javax.net.ssl.TrustManager;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.apache.commons.net.util.TrustManagerUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -34,7 +36,8 @@ import org.slf4j.LoggerFactory;
 /**
  * Network Utilities.
  */
-public class NetworkUtil {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class NetworkUtil {
 
     public static final Logger logger = LoggerFactory.getLogger(NetworkUtil.class.getName());
 
@@ -49,10 +52,6 @@ public class NetworkUtil {
      */
     private static final TrustManager[] ALWAYS_TRUST_MANAGER = { TrustManagerUtils.getAcceptAllTrustManager() };
 
-    private NetworkUtil() {
-        // Empty constructor
-    }
-
     /**
      * Allocates an available port on which a server may listen.
      *
index 1a08bb4..2b6e514 100644 (file)
@@ -25,22 +25,21 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Utilities for generating POJOs from Properties.
  */
-public class PropertyObjectUtils {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class PropertyObjectUtils {
 
     public static final Logger logger = LoggerFactory.getLogger(PropertyObjectUtils.class);
     private static final Pattern NAME_PAT = Pattern.compile("\\[(\\d{1,3})\\]$");
     private static final Pattern DOT_PAT = Pattern.compile("[.]");
 
-    private PropertyObjectUtils() {
-        // do nothing
-    }
-
     /**
      * Converts a set of properties to a Map. Supports json-path style property names with
      * "." separating components, where components may have an optional subscript.
index f711a05..2ea9495 100644 (file)
 package org.onap.policy.common.utils.properties;
 
 import java.util.Properties;
+import lombok.AccessLevel;
+import lombok.Getter;
 
 /**
  * Properties with an optional specialization (e.g., session name, controller name).
  */
+@Getter(AccessLevel.PROTECTED)
 public class SpecProperties extends Properties {
     private static final long serialVersionUID = 1L;
 
@@ -99,14 +102,6 @@ public class SpecProperties extends Properties {
         return super.getProperty(key);
     }
 
-    protected String getPrefix() {
-        return prefix;
-    }
-
-    protected String getSpecPrefix() {
-        return specPrefix;
-    }
-
     @Override
     public final synchronized int hashCode() {
         throw new UnsupportedOperationException("SpecProperties cannot be hashed");
index d689584..3c03f38 100644 (file)
 
 package org.onap.policy.common.utils.properties.exception;
 
+import lombok.Getter;
+
 /**
  * Exception associated with a Property.
  */
+@Getter
 public class PropertyException extends Exception {
     private static final long serialVersionUID = 1L;
 
@@ -92,26 +95,6 @@ public class PropertyException extends Exception {
         this.fieldName = fieldName;
     }
 
-    /**
-     * Get the property name.
-     *
-     * @return name of the property for which the exception was thrown, or {@code null} if
-     *         no name was provided
-     */
-    public String getPropertyName() {
-        return propertyName;
-    }
-
-    /**
-     * Get the field name.
-     *
-     * @return name of the field for which the exception was thrown, or {@code null} if no
-     *         field was provided
-     */
-    public String getFieldName() {
-        return fieldName;
-    }
-
     /**
      * Make the message.
      *
index 8ec0c01..ef46fdf 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2020 Bell Canada. All rights reserved.
+ *  Modifications Copyright (C) 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.common.utils.resources;
 
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
 /**
  * Common messages to be used by all components.
  */
-public class MessageConstants {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class MessageConstants {
 
     public static final String POLICY_API = "policy-api";
     public static final String POLICY_PAP = "policy-pap";
@@ -35,8 +40,4 @@ public class MessageConstants {
 
     public static final String START_SUCCESS_MSG = "Started %s service successfully.";
     public static final String START_FAILURE_MSG = "Start of %s service failed.";
-
-    private MessageConstants() {
-        super();
-    }
 }
index 589c309..83d41fb 100644 (file)
@@ -34,6 +34,8 @@ import java.util.Set;
 import java.util.TreeSet;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,7 +43,8 @@ import org.slf4j.LoggerFactory;
  * This is common utility class with static methods for handling Java resources on the class path. It is an abstract
  * class to prevent any direct instantiation and private constructor to prevent extending this class.
  */
-public abstract class ResourceUtils {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ResourceUtils {
     // Get a reference to the logger
     private static final Logger LOGGER = LoggerFactory.getLogger(ResourceUtils.class);
 
@@ -54,13 +57,6 @@ public abstract class ResourceUtils {
     private static final String FILE_PROTOCOL = "file";
     private static final String JAR_PROTOCOL = "jar";
 
-    /**
-     * Private constructor used to prevent sub class instantiation.
-     */
-    private ResourceUtils() {
-        // Prevent construction of this class
-    }
-
     /**
      * Method to resolve a resource; the local file system is checked first and then the class path is checked.
      *
index 5288bef..9df9880 100644 (file)
@@ -28,6 +28,8 @@ import java.io.InputStreamReader;
 import java.io.Reader;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.apache.commons.io.IOUtils;
 
 /**
@@ -36,11 +38,8 @@ import org.apache.commons.io.IOUtils;
  *
  * @author Liam Fallon (liam.fallon@est.tech)
  */
-public class TextFileUtils {
-
-    private TextFileUtils() {
-        // This class cannot be initialized
-    }
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class TextFileUtils {
 
     /**
      * Method to return the contents of a text file as a string.
index 332e0f6..042ee93 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.
@@ -23,15 +23,14 @@ package org.onap.policy.common.utils.services;
 import java.util.List;
 import java.util.function.BiConsumer;
 import java.util.function.Predicate;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 
 /**
  * Utilities for use with "feature APIs".
  */
-public class FeatureApiUtils {
-
-    private FeatureApiUtils() {
-        // do nothing
-    }
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class FeatureApiUtils {
 
     /**
      * Applies a function on each feature provider, stopping as soon as one returns true.
index c3eabe8..8765ba8 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.
@@ -22,6 +22,8 @@ package org.onap.policy.common.utils.services;
 
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -29,6 +31,7 @@ import org.slf4j.LoggerFactory;
  * This is a simple object registry, similar in spirit to JNDI, but suitable for use in a
  * stand-alone JVM.
  */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
 public class Registry {
     private static final Logger logger = LoggerFactory.getLogger(Registry.class);
 
@@ -39,13 +42,6 @@ public class Registry {
      */
     private Map<String, Object> name2object = new ConcurrentHashMap<>();
 
-    /**
-     * Constructs the object.
-     */
-    private Registry() {
-        super();
-    }
-
     /**
      * Registers an object.
      *
index 78fe853..1387462 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP PAP
  * ================================================================================
- * 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.
@@ -23,6 +23,8 @@ package org.onap.policy.common.utils.services;
 import java.util.Deque;
 import java.util.Iterator;
 import java.util.LinkedList;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
 import org.onap.policy.common.capabilities.Startable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,6 +39,7 @@ public class ServiceManager implements Startable {
     /**
      * Manager name.
      */
+    @Getter
     private final String name;
 
     /**
@@ -65,10 +68,6 @@ public class ServiceManager implements Startable {
         this.name = name;
     }
 
-    public String getName() {
-        return name;
-    }
-
     /**
      * Adds a pair of service actions to the manager.
      *
@@ -204,16 +203,11 @@ public class ServiceManager implements Startable {
     /**
      * Service information.
      */
+    @AllArgsConstructor
     private static class Service {
         private String stepName;
         private RunnableWithEx starter;
         private RunnableWithEx stopper;
-
-        public Service(String stepName, RunnableWithEx starter, RunnableWithEx stopper) {
-            this.stepName = stepName;
-            this.starter = starter;
-            this.stopper = stopper;
-        }
     }
 
     /*
index 857b69b..95f4d69 100644 (file)
@@ -2,14 +2,14 @@
  * ============LICENSE_START=======================================================
  * Common Utils
  * ================================================================================
- * 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.common.utils.time;
 
 import java.util.Date;
+import lombok.NoArgsConstructor;
 
 /**
  * Methods to access the current time. Classes can use objects of this type to get current
  * time information, while allowing the objects to be overridden by junit tests.
  */
+@NoArgsConstructor
 public class CurrentTime {
 
-    /**
-     * Constructor.
-     * 
-     */
-    public CurrentTime() {
-        super();
-    }
-
     /**
      * Get the millisecond time.
-     * 
+     *
      * @return the current time, in milliseconds
      */
     public long getMillis() {
@@ -47,7 +41,7 @@ public class CurrentTime {
 
     /**
      * Get the current date.
-     * 
+     *
      * @return the current Date
      */
     public Date getDate() {
@@ -56,7 +50,7 @@ public class CurrentTime {
 
     /**
      * Sleeps for a period of time.
-     * 
+     *
      * @param sleepMs amount of time to sleep, in milliseconds
      * @throws InterruptedException can be interrupted
      */
index 047989e..8e47420 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
  *  Modifications Copyright (C) 2019 Nordix Foundation.
- *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ *  Modifications 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.
@@ -22,6 +22,8 @@
 
 package org.onap.policy.common.utils.validation;
 
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -29,16 +31,11 @@ import org.slf4j.LoggerFactory;
  * The Class Assertions is a static class that is used as a shorthand for assertions in the source code.
  * It throws runtime exceptions on assertion fails.
  */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class Assertions {
     // Logger for this class
     private static final Logger LOGGER = LoggerFactory.getLogger(Assertions.class);
 
-    /**
-     * Private constructor used to prevent sub class instantiation.
-     */
-    private Assertions() {
-    }
-
     /**
      * Gets the validation message for a string parameter.
      *
index f15d936..0723242 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2018 Ericsson. All rights reserved.
- *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ *  Modifications 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.common.utils.validation;
 
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
 /**
  * Class to provide utility methods for common parameter validations.
  *
  * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
  */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
 public class ParameterValidationUtils {
 
-    private ParameterValidationUtils() {
-
-    }
-
     /**
      * Validates the given string input.
      *
index 3b6e495..18b39d2 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Common Utils
  * ================================================================================
- * 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.
@@ -55,7 +55,7 @@ public class EntityTransCloserTest {
     public void testEntityTransCloser() {
         EntityTransCloser entityTransCloser = new EntityTransCloser(trans);
 
-        assertEquals(trans, entityTransCloser.getTransation());
+        assertEquals(trans, entityTransCloser.getTransaction());
 
         // verify that transaction was started
         verify(trans).begin();
@@ -72,7 +72,7 @@ public class EntityTransCloserTest {
     @Test
     public void testGetTransation() {
         try (EntityTransCloser t = new EntityTransCloser(trans)) {
-            assertEquals(trans, t.getTransation());
+            assertEquals(trans, t.getTransaction());
         }
     }