Use lombok for errors pap, pdp, sim-dmaap, sim-pdp 27/122027/2
authorJim Hahn <jrh3@att.com>
Thu, 17 Jun 2021 20:29:33 +0000 (16:29 -0400)
committerAjith Sreekumar <ajith.sreekumar@bell.ca>
Mon, 21 Jun 2021 09:22:35 +0000 (09:22 +0000)
Issue-ID: POLICY-3396
Change-Id: Ib2c9bc5dc199e15ae9ca077031c0f2cfbc5b6a81
Signed-off-by: Jim Hahn <jrh3@att.com>
models-errors/src/main/java/org/onap/policy/models/errors/concepts/ErrorResponseUtils.java
models-pap/src/main/java/org/onap/policy/models/pap/concepts/PdpGroupDeployResponse.java
models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/DeploymentSubGroup.java
models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java
models-sim/models-sim-dmaap/src/main/java/org/onap/policy/models/sim/dmaap/startstop/Main.java
models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorConstants.java
models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/PdpSimulatorMain.java
models-sim/policy-models-sim-pdp/src/main/java/org/onap/policy/models/sim/pdp/comm/PdpStatusPublisher.java

index eb5212e..7496513 100644 (file)
@@ -23,19 +23,16 @@ package org.onap.policy.models.errors.concepts;
 
 import java.util.ArrayList;
 import java.util.List;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
 
 /**
  * Utility class for managing {@link ErrorResponse objects}.
  *
  * @author Liam Fallon (liam.fallon@est.tech)
  */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
 public final class ErrorResponseUtils {
-    /**
-     * Private constructor used to prevent sub class instantiation.
-     */
-    private ErrorResponseUtils() {
-        // Default constructor
-    }
 
     /**
      * Store the cascaded messages from an exception and all its nested exceptions in an ErrorResponse object.
index 6d94d71..43485cc 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Models
  * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,7 @@
 
 package org.onap.policy.models.pap.concepts;
 
+import lombok.AllArgsConstructor;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
@@ -33,6 +34,7 @@ import lombok.ToString;
 @Setter
 @ToString(callSuper = true)
 @NoArgsConstructor
+@AllArgsConstructor
 public class PdpGroupDeployResponse extends SimpleResponse {
 
     /**
@@ -44,15 +46,4 @@ public class PdpGroupDeployResponse extends SimpleResponse {
      * URI to fetch the deployment status.
      */
     private String uri;
-
-    /**
-     * Constructs the object.
-     *
-     * @param message the message
-     * @param uri the uri to get actual deployment status
-     */
-    public PdpGroupDeployResponse(String message, String uri) {
-        this.message = message;
-        this.uri = uri;
-    }
 }
index 361f7da..2bf816a 100644 (file)
@@ -24,6 +24,7 @@ package org.onap.policy.models.pdp.concepts;
 import java.util.ArrayList;
 import java.util.List;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 import lombok.NonNull;
 import org.onap.policy.common.parameters.BeanValidationResult;
 import org.onap.policy.common.parameters.ValidationResult;
@@ -35,6 +36,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
  * particular domain.
  */
 @Data
+@NoArgsConstructor
 public class DeploymentSubGroup {
 
     public enum Action {
@@ -47,13 +49,6 @@ public class DeploymentSubGroup {
     private Action action;
     private List<ToscaConceptIdentifier> policies;
 
-    /**
-     * Constructs the object.
-     */
-    public DeploymentSubGroup() {
-        super();
-    }
-
     /**
      * Constructs the object, making a deep copy from the source.
      *
index 3cf8b9b..e35e4a3 100644 (file)
@@ -26,6 +26,7 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 import lombok.NonNull;
 import org.onap.policy.common.parameters.BeanValidationResult;
 import org.onap.policy.common.parameters.ValidationResult;
@@ -40,6 +41,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
  * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
  */
 @Data
+@NoArgsConstructor
 public class PdpSubGroup {
     private String pdpType;
     private List<ToscaConceptIdentifier> supportedPolicyTypes;
@@ -49,13 +51,6 @@ public class PdpSubGroup {
     private Map<String, String> properties;
     private List<Pdp> pdpInstances;
 
-    /**
-     * Constructs the object.
-     */
-    public PdpSubGroup() {
-        super();
-    }
-
     /**
      * Constructs the object, making a deep copy from the source.
      *
index e136509..9c368e0 100644 (file)
@@ -22,6 +22,7 @@
 package org.onap.policy.models.sim.dmaap.startstop;
 
 import java.util.Arrays;
+import lombok.Getter;
 import org.onap.policy.common.utils.cmd.CommandLineException;
 import org.onap.policy.models.sim.dmaap.DmaapSimException;
 import org.onap.policy.models.sim.dmaap.DmaapSimRuntimeException;
@@ -38,7 +39,8 @@ public class Main {
     private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
 
     private DmaapSimActivator activator;
-    private DmaapSimParameterGroup parameterGroup;
+    @Getter
+    private DmaapSimParameterGroup parameters;
 
     /**
      * Instantiates the DMaap Simulator service.
@@ -67,14 +69,14 @@ public class Main {
 
         // Read the parameters
         try {
-            parameterGroup = new DmaapSimParameterHandler().getParameters(arguments);
+            parameters = new DmaapSimParameterHandler().getParameters(arguments);
         } catch (final Exception e) {
             LOGGER.error("start of DMaaP simulator service failed", e);
             return;
         }
 
         // Now, create the activator for the DMaaP Simulator service
-        activator = new DmaapSimActivator(parameterGroup);
+        activator = new DmaapSimActivator(parameters);
 
         // Start the activator
         try {
@@ -89,15 +91,6 @@ public class Main {
         LOGGER.info("Started DMaaP simulator service");
     }
 
-    /**
-     * Get the parameters specified in JSON.
-     *
-     * @return the parameters
-     */
-    public DmaapSimParameterGroup getParameters() {
-        return parameterGroup;
-    }
-
     /**
      * Shut down Execution.
      *
@@ -105,7 +98,7 @@ public class Main {
      */
     public void shutdown() throws DmaapSimException {
         // clear the parameterGroup variable
-        parameterGroup = null;
+        parameters = null;
 
         // clear the DMaaP simulator activator
         if (activator != null && activator.isAlive()) {
index 22dbc46..62ea092 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.sim.pdp;
 
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
 /**
  * Names of various items contained in the Registry.
  */
-public class PdpSimulatorConstants {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class PdpSimulatorConstants {
     // Registry keys
     public static final String REG_PDP_SIMULATOR_ACTIVATOR = "object:activator/pdp_simulator";
     public static final String REG_PDP_STATUS_OBJECT = "object:pdp/status";
     public static final String REG_PDP_TOSCA_POLICY_LIST = "object:pdp/tosca/policy/list";
     public static final String REG_PDP_STATUS_PUBLISHER = "object:pdp/status/publisher";
     public static final String REG_PDP_TOPIC_SINKS = "object:pdp/topic/sinks";
-
-    private PdpSimulatorConstants() {
-        super();
-    }
 }
index 57fc8a1..1441ba3 100644 (file)
@@ -22,6 +22,7 @@
 package org.onap.policy.models.sim.pdp;
 
 import java.util.Arrays;
+import lombok.Getter;
 import org.onap.policy.common.utils.cmd.CommandLineException;
 import org.onap.policy.common.utils.services.Registry;
 import org.onap.policy.models.sim.pdp.exception.PdpSimulatorException;
@@ -43,7 +44,8 @@ public class PdpSimulatorMain {
     private static final Logger LOGGER = LoggerFactory.getLogger(PdpSimulatorMain.class);
 
     private PdpSimulatorActivator activator;
-    private PdpSimulatorParameterGroup parameterGroup;
+    @Getter
+    private PdpSimulatorParameterGroup parameters;
 
     /**
      * Instantiates the PdpSimulator.
@@ -73,14 +75,14 @@ public class PdpSimulatorMain {
 
         // Read the parameters
         try {
-            parameterGroup = new PdpSimulatorParameterHandler().getParameters(arguments);
+            parameters = new PdpSimulatorParameterHandler().getParameters(arguments);
         } catch (final Exception e) {
             LOGGER.error(PDP_SIMULATOR_FAIL_MSG, e);
             return;
         }
 
         // create the activator
-        activator = new PdpSimulatorActivator(parameterGroup);
+        activator = new PdpSimulatorActivator(parameters);
         Registry.register(PdpSimulatorConstants.REG_PDP_SIMULATOR_ACTIVATOR, activator);
         // Start the activator
         try {
@@ -97,15 +99,6 @@ public class PdpSimulatorMain {
         LOGGER.info("Started PdpSimulator service");
     }
 
-    /**
-     * Get the parameters specified in JSON.
-     *
-     * @return parameterGroup the parameters
-     */
-    public PdpSimulatorParameterGroup getParameters() {
-        return parameterGroup;
-    }
-
 
     /**
      * Shut down Execution.
@@ -114,7 +107,7 @@ public class PdpSimulatorMain {
      */
     public void shutdown() throws PdpSimulatorException {
         // clear the parameterGroup variable
-        parameterGroup = null;
+        parameters = null;
 
         // clear the pdp simulator activator
         if (activator != null && activator.isAlive()) {
index e490fe7..6be59b1 100644 (file)
@@ -24,6 +24,7 @@ package org.onap.policy.models.sim.pdp.comm;
 import java.util.List;
 import java.util.Timer;
 import java.util.TimerTask;
+import lombok.Getter;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
 import org.onap.policy.models.pdp.concepts.PdpStatus;
@@ -42,6 +43,7 @@ public class PdpStatusPublisher extends TimerTask {
 
     private TopicSinkClient topicSinkClient;
     private Timer timer;
+    @Getter
     private long interval;
 
     /**
@@ -72,15 +74,6 @@ public class PdpStatusPublisher extends TimerTask {
         timer.purge();
     }
 
-    /**
-     * Get the current time interval used by the timer task.
-     *
-     * @return interval the current time interval
-     */
-    public long getInterval() {
-        return interval;
-    }
-
     /**
      * Method to send pdp status message to pap on demand.
      *