aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-06-17 16:54:20 -0400
committerAjith Sreekumar <ajith.sreekumar@bell.ca>2021-06-21 09:19:17 +0000
commit417e292dbaff7c30f86780e20da5fc95b108032a (patch)
treee34cf7ed3a8e10fe2bd185fdab8d53543d721aa3
parent1ada3a6368f340df653886c4229b192ce7a5fc35 (diff)
Use lombok for events, base, dao
Issue-ID: POLICY-3396 Change-Id: I7b37efc13a25e0e27d63a85a3ee291e91a4e1682 Signed-off-by: Jim Hahn <jrh3@att.com>
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConcept.java10
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java10
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java9
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfKey.java10
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfModelService.java12
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfUtils.java8
-rw-r--r--models-dao/pom.xml7
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/DaoParameters.java77
-rw-r--r--models-dao/src/test/java/org/onap/policy/models/dao/DaoMiscTest.java6
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/Abated.java3
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java12
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/Onset.java3
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java9
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java9
-rw-r--r--models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java7
15 files changed, 49 insertions, 143 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConcept.java b/models-base/src/main/java/org/onap/policy/models/base/PfConcept.java
index 2357ec00d..8afcaa159 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConcept.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConcept.java
@@ -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,17 +32,11 @@ 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.
*
* @param copyConcept the concept to copy from
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java
index 3c186bbf8..fa1bbb4e7 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptGetterImpl.java
@@ -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) {
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java
index d200a693a..98b67819e 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java
@@ -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() + ")";
- }
}
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfKey.java
index 4b7f8cf95..949598828 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfKey.java
@@ -21,12 +21,15 @@
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;
@@ -68,13 +71,6 @@ public abstract class PfKey extends PfConcept {
}
/**
- * Default constructor.
- */
- protected PfKey() {
- super();
- }
-
- /**
* Copy constructor.
*
* @param copyConcept the concept to copy from
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfModelService.java b/models-base/src/main/java/org/onap/policy/models/base/PfModelService.java
index 7353915b9..860288b8e 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfModelService.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfModelService.java
@@ -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,18 +39,12 @@ 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.
*
* @param <M> the generic type
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfUtils.java b/models-base/src/main/java/org/onap/policy/models/base/PfUtils.java
index 6a119d6c4..6f93010bb 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfUtils.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfUtils.java
@@ -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.
diff --git a/models-dao/pom.xml b/models-dao/pom.xml
index 4b62aa80a..7df645649 100644
--- a/models-dao/pom.xml
+++ b/models-dao/pom.xml
@@ -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.
@@ -43,10 +43,5 @@
<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>
diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/DaoParameters.java b/models-dao/src/main/java/org/onap/policy/models/dao/DaoParameters.java
index a6b6f2f2e..98e31c423 100644
--- a/models-dao/src/main/java/org/onap/policy/models/dao/DaoParameters.java
+++ b/models-dao/src/main/java/org/onap/policy/models/dao/DaoParameters.java
@@ -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.
@@ -21,12 +22,18 @@
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";
@@ -37,65 +44,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.
*
* @param key the key of the 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 + "]";
- }
}
diff --git a/models-dao/src/test/java/org/onap/policy/models/dao/DaoMiscTest.java b/models-dao/src/test/java/org/onap/policy/models/dao/DaoMiscTest.java
index 419714924..3a46570a4 100644
--- a/models-dao/src/test/java/org/onap/policy/models/dao/DaoMiscTest.java
+++ b/models-dao/src/test/java/org/onap/policy/models/dao/DaoMiscTest.java
@@ -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());
}
}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/Abated.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/Abated.java
index 3488e3b6a..f2f879828 100644
--- a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/Abated.java
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/Abated.java
@@ -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);
}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
index 55c133306..18dea09c9 100644
--- a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/ControlLoopTargetType.java
@@ -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");
@@ -21,14 +21,14 @@
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
- }
}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/Onset.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/Onset.java
index 41a0ebab4..3f427734b 100644
--- a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/Onset.java
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/Onset.java
@@ -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);
}
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
index 17a23b749..e7cf7e33b 100644
--- a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopEvent.java
@@ -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");
@@ -21,13 +21,12 @@
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.
*
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
index 12c28c761..3290fb952 100644
--- a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/PhysicalControlLoopNotification.java
@@ -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");
@@ -21,13 +21,12 @@
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.
*
diff --git a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
index 5f124131e..9b70ab86c 100644
--- a/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
+++ b/models-interactions/model-impl/events/src/main/java/org/onap/policy/controlloop/util/Serialization.java
@@ -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