Use lombok for events, base, dao 29/122029/2
authorJim Hahn <jrh3@att.com>
Thu, 17 Jun 2021 20:54:20 +0000 (16:54 -0400)
committerAjith Sreekumar <ajith.sreekumar@bell.ca>
Mon, 21 Jun 2021 09:19:17 +0000 (09:19 +0000)
Issue-ID: POLICY-3396
Change-Id: I7b37efc13a25e0e27d63a85a3ee291e91a4e1682
Signed-off-by: Jim Hahn <jrh3@att.com>
15 files changed:
models-base/src/main/java/org/onap/policy/models/base/PfConcept.java
models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java
models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java
models-base/src/main/java/org/onap/policy/models/base/PfKey.java
models-base/src/main/java/org/onap/policy/models/base/PfModelService.java
models-base/src/main/java/org/onap/policy/models/base/PfUtils.java
models-dao/pom.xml
models-dao/src/main/java/org/onap/policy/models/dao/DaoParameters.java
models-dao/src/test/java/org/onap/policy/models/dao/DaoMiscTest.java
models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/Abated.java
models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/Onset.java
models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java

index 2357ec0..8afcaa1 100644 (file)
@@ -23,6 +23,8 @@ package org.onap.policy.models.base;
 
 import java.io.Serializable;
 import java.util.List;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import lombok.NonNull;
 
 /**
@@ -30,16 +32,10 @@ import lombok.NonNull;
  * and interfaces on all concepts that are sub-classes of this class.
  */
 
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
 public abstract class PfConcept extends Validated implements Serializable, Comparable<PfConcept> {
     private static final long serialVersionUID = -7434939557282697490L;
 
-    /**
-     * Default constructor.
-     */
-    protected PfConcept() {
-        // Default Constructor
-    }
-
     /**
      * Copy constructor.
      *
index 3c186bb..fa1bbb4 100644 (file)
@@ -24,6 +24,7 @@ package org.onap.policy.models.base;
 import java.util.NavigableMap;
 import java.util.Set;
 import java.util.TreeSet;
+import lombok.AllArgsConstructor;
 import org.onap.policy.common.utils.validation.Assertions;
 
 /**
@@ -31,19 +32,12 @@ import org.onap.policy.common.utils.validation.Assertions;
  *
  * @param <C> the type of concept on which the interface implementation is applied.
  */
+@AllArgsConstructor
 public class PfConceptGetterImpl<C> implements PfConceptGetter<C> {
 
     // The map from which to get concepts
     private final NavigableMap<PfConceptKey, C> conceptMap;
 
-    /**
-     * Constructor that sets the concept map on which the getter methods in the interface will operate..
-     *
-     * @param conceptMap the concept map on which the method will operate
-     */
-    public PfConceptGetterImpl(final NavigableMap<PfConceptKey, C> conceptMap) {
-        this.conceptMap = conceptMap;
-    }
 
     @Override
     public C get(final PfConceptKey conceptKey) {
index d200a69..98b6781 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  *  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.
@@ -26,6 +26,7 @@ import javax.persistence.Embeddable;
 import lombok.EqualsAndHashCode;
 import lombok.Getter;
 import lombok.NonNull;
+import lombok.ToString;
 import org.onap.policy.common.parameters.annotations.Pattern;
 import org.onap.policy.common.utils.validation.Assertions;
 
@@ -40,6 +41,7 @@ import org.onap.policy.common.utils.validation.Assertions;
 @Embeddable
 @Getter
 @EqualsAndHashCode(callSuper = false)
+@ToString
 public class PfConceptKey extends PfKeyImpl {
     private static final long serialVersionUID = 8932717618579392561L;
 
@@ -102,9 +104,4 @@ public class PfConceptKey extends PfKeyImpl {
     public static final PfConceptKey getNullKey() {
         return new PfConceptKey(PfKey.NULL_KEY_NAME, PfKey.NULL_KEY_VERSION);
     }
-
-    @Override
-    public String toString() {
-        return "PfConceptKey(name=" + getName() + ", version=" + getVersion() + ")";
-    }
 }
index 4b7f8cf..9495988 100644 (file)
 
 package org.onap.policy.models.base;
 
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import lombok.NonNull;
 
 /**
  * The key uniquely identifies every entity in the system. This class is an abstract class to give a common parent for
  * all key types in the system.
  */
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
 public abstract class PfKey extends PfConcept {
     private static final long serialVersionUID = 6281159885962014041L;
 
@@ -67,13 +70,6 @@ public abstract class PfKey extends PfConcept {
         IDENTICAL
     }
 
-    /**
-     * Default constructor.
-     */
-    protected PfKey() {
-        super();
-    }
-
     /**
      * Copy constructor.
      *
index 7353915..860288b 100644 (file)
@@ -24,6 +24,8 @@ package org.onap.policy.models.base;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import javax.ws.rs.core.Response;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import lombok.NonNull;
 
 /**
@@ -37,17 +39,11 @@ import lombok.NonNull;
  * exist in Policy Framework (particularly the engine) at any time. Of course the model in a JVM can be changed at any
  * time provided all users of the model are stopped and restarted in an orderly manner.
  */
-public abstract class PfModelService {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class PfModelService {
     // The map holding the models
     private static Map<String, PfConcept> modelMap = new ConcurrentHashMap<>();
 
-    /**
-     * This class is an abstract static class that cannot be extended.
-     */
-    private PfModelService() {
-        // Default constructor
-    }
-
     /**
      * Register a model with the model service.
      *
index 6a119d6..6f93010 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019-2021 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.
@@ -30,6 +30,8 @@ import java.util.Map.Entry;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 import javax.ws.rs.core.Response;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.MapUtils;
 
@@ -38,10 +40,8 @@ import org.apache.commons.collections4.MapUtils;
  *
  * @author Liam Fallon (liam.fallon@est.tech)
  */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class PfUtils {
-    private PfUtils() {
-        // Cannot be subclassed
-    }
 
     /**
      * Compare two objects using their equals methods, nulls are allowed.
index 4b62aa8..7df6456 100644 (file)
@@ -1,7 +1,7 @@
 <!--
   ============LICENSE_START=======================================================
    Copyright (C) 2019 Nordix Foundation.
-   Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+   Copyright (C) 2020-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.
             <artifactId>h2</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>javax.xml.bind</groupId>
-            <artifactId>jaxb-api</artifactId>
-            <version>2.3.1</version>
-        </dependency>
     </dependencies>
 </project>
index a6b6f2f..98e31c4 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  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.models.dao;
 
 import java.util.Properties;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
 
 /**
  * This class is a POJO that holds properties for PF DAOs.
  *
  * @author Liam Fallon (liam.fallon@est.tech)
  */
+@Getter
+@Setter
+@ToString
 public class DaoParameters {
     /** The default PF DAO plugin class. */
     public static final String DEFAULT_PLUGIN_CLASS = "org.onap.policy.models.dao.impl.DefaultPfDao";
@@ -36,65 +43,6 @@ public class DaoParameters {
 
     private Properties jdbcProperties = new Properties();
 
-    /**
-     * Gets the DAO plugin class, this is the DAO class to use and it must implement the
-     * {@link PfDao} interface.
-     *
-     * @return the DAO plugin class
-     */
-    public String getPluginClass() {
-        return pluginClass;
-    }
-
-    /**
-     * Sets the DAO plugin class, a class that implements the {@link PfDao} interface.
-     *
-     * @param daoPluginClass the DAO plugin class
-     */
-    public void setPluginClass(final String daoPluginClass) {
-        pluginClass = daoPluginClass;
-    }
-
-    /**
-     * Gets the persistence unit for the DAO. The persistence unit defines the JDBC properties the
-     * DAO will use. The persistence unit must defined in the {@code META-INF/persistence.xml}
-     * resource file
-     *
-     * @return the persistence unit to use for JDBC access
-     */
-    public String getPersistenceUnit() {
-        return persistenceUnit;
-    }
-
-    /**
-     * Sets the persistence unit for the DAO. The persistence unit defines the JDBC properties the
-     * DAO will use. The persistence unit must defined in the {@code META-INF/persistence.xml}
-     * resource file
-     *
-     * @param daoPersistenceUnit the persistence unit to use for JDBC access
-     */
-    public void setPersistenceUnit(final String daoPersistenceUnit) {
-        persistenceUnit = daoPersistenceUnit;
-    }
-
-    /**
-     * Gets the JDBC properties.
-     *
-     * @return the JDBC properties
-     */
-    public Properties getJdbcProperties() {
-        return jdbcProperties;
-    }
-
-    /**
-     * Sets the JDBC properties.
-     *
-     * @param jdbcProperties the JDBC properties
-     */
-    public void setJdbcProperties(final Properties jdbcProperties) {
-        this.jdbcProperties = jdbcProperties;
-    }
-
     /**
      * Gets a single JDBC property.
      *
@@ -114,15 +62,4 @@ public class DaoParameters {
     public void setJdbcProperty(final String key, final String value) {
         jdbcProperties.setProperty(key, value);
     }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.lang.Object#toString()
-     */
-    @Override
-    public String toString() {
-        return "DAOParameters [pluginClass=" + pluginClass + ", persistenceUnit=" + persistenceUnit
-                + ", jdbcProperties=" + jdbcProperties + "]";
-    }
 }
index 4197149..3a46570 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  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.
@@ -73,7 +73,7 @@ public class DaoMiscTest {
         pars.setPluginClass(SOMEWHERE_OVER_THE_RAINBOW);
         assertEquals(SOMEWHERE_OVER_THE_RAINBOW, pars.getPluginClass());
 
-        assertEquals("DAOParameters [pluginClass=somewhere.over.the.rainbow, "
-                + "persistenceUnit=Kansas, jdbcProperties={name=Dorothy}]", pars.toString());
+        assertEquals("DaoParameters(pluginClass=somewhere.over.the.rainbow, "
+                + "persistenceUnit=Kansas, jdbcProperties={name=Dorothy})", pars.toString());
     }
 }
index 3488e3b..f2f8798 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,7 +33,6 @@ public class Abated extends VirtualControlLoopEvent {
      * No arguments constructor.
      */
     public Abated() {
-        super();
         setClosedLoopEventStatus(ControlLoopEventStatus.ABATED);
     }
 
index 55c1333..18dea09 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * controlloop
  * ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
 
 package org.onap.policy.controlloop;
 
-public class ControlLoopTargetType {
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ControlLoopTargetType {
     public static final String VM = "VM";
     public static final String VF = "VF";
     public static final String VFC = "VFC";
     public static final String VNF = "VNF";
     public static final String PNF = "PNF";
-
-    private ControlLoopTargetType() {
-        // do nothing
-    }
 }
index 41a0eba..3f42773 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -35,7 +35,6 @@ public class Onset extends VirtualControlLoopEvent {
      * No arguments constructor.
      */
     public Onset() {
-        super();
         setClosedLoopEventStatus(ControlLoopEventStatus.ONSET);
     }
 
index 17a23b7..e7cf7e3 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * controlloop
  * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
 
 package org.onap.policy.controlloop;
 
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor
 public class PhysicalControlLoopEvent extends ControlLoopEvent {
     private static final long serialVersionUID = -7282930271094849487L;
 
-    public PhysicalControlLoopEvent() {
-        // Default constructor
-    }
-
     /**
      * Construct an instance from an existing instance.
      *
index 12c28c7..3290fb9 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * controlloop
  * ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019, 2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
 
 package org.onap.policy.controlloop;
 
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor
 public class PhysicalControlLoopNotification extends ControlLoopNotification {
     private static final long serialVersionUID = 8105197217140032892L;
 
-    public PhysicalControlLoopNotification() {
-        // Default constructor
-    }
-
     /**
      * Construct an instance from an existing instance.
      *
index 5f12413..9b70ab8 100644 (file)
@@ -33,10 +33,13 @@ import java.lang.reflect.Type;
 import java.time.Instant;
 import java.time.ZonedDateTime;
 import java.time.format.DateTimeFormatter;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 import org.onap.policy.common.gson.InstantAsMillisTypeAdapter;
 import org.onap.policy.common.gson.ZonedDateTimeTypeAdapter;
 import org.onap.policy.controlloop.ControlLoopNotificationType;
 
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class Serialization {
     public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
 
@@ -54,10 +57,6 @@ public final class Serialization {
             .registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeTypeAdapter(format))
             .registerTypeAdapter(Instant.class, new InstantAsMillisTypeAdapter()).create();
 
-    private Serialization() {
-        // Private constructor to prevent subclassing
-    }
-
     public static class NotificationTypeAdapter
             implements JsonSerializer<ControlLoopNotificationType>, JsonDeserializer<ControlLoopNotificationType> {
         @Override