diff options
62 files changed, 337 insertions, 977 deletions
diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java index 1550cc9b..842b4772 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/OnapLoggingUtils.java @@ -22,16 +22,15 @@ package org.onap.policy.common.logging; import com.google.re2j.Pattern; import javax.servlet.http.HttpServletRequest; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; -public class OnapLoggingUtils { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class OnapLoggingUtils { private static final Pattern COMMA_PAT = Pattern.compile(","); private static final Pattern CURLS_PAT = Pattern.compile("[{][}]"); - private OnapLoggingUtils() { - // Private constructor to prevent subclassing - } - /** * Get the ONAPLoggingContext for a request. * diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java index 32bb6fec..9e461916 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/ErrorCodeMap.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * Copyright (C) 2020 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 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. @@ -21,6 +21,8 @@ package org.onap.policy.common.logging.eelf; import java.util.EnumMap; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; /** * ErrorCodeMap contains a HashMap of ErrorCodeInfo (error code and error description). @@ -32,7 +34,8 @@ import java.util.EnumMap; * 500 – business process errors * 900 – unknown errors */ -public class ErrorCodeMap { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class ErrorCodeMap { private static final EnumMap<MessageCodes, ErrorCodeInfo> hm = new EnumMap<>(MessageCodes.class); @@ -93,10 +96,6 @@ public class ErrorCodeMap { hm.put(MessageCodes.ERROR_AUDIT, new ErrorCodeInfo(ERROR_AUDIT, ERROR_AUDIT_DESCRIPTION)); } - private ErrorCodeMap() { - // Private constructor to prevent subclassing - } - public static ErrorCodeInfo getErrorCodeInfo(MessageCodes messageCode) { return hm.get(messageCode); } diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java index 02403992..87a96a19 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventData.java @@ -21,7 +21,9 @@ package org.onap.policy.common.logging.eelf; import java.time.Instant; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; /** @@ -29,32 +31,14 @@ import lombok.Setter; */ @Getter @Setter +@NoArgsConstructor +@AllArgsConstructor public class EventData { private String requestId = null; private Instant startTime = null; private Instant endTime = null; - // Default constructor takes no arguments. - // Is empty because instance variables are assigned - // their default values upon declaration. - public EventData() { - // See above comments for the reason this constructor is empty - } - - /** - * Create an instance. - * - * @param requestId the request ID - * @param startTime the start time - * @param endTime the end time - */ - public EventData(String requestId, Instant startTime, Instant endTime) { - this.requestId = requestId; - this.startTime = startTime; - this.endTime = endTime; - } - @Override public String toString() { return requestId + " Starting Time : " + this.startTime + " Ending Time : " + this.endTime; diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java index 3e021169..f6f38d0d 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/EventTrackInfo.java @@ -22,12 +22,14 @@ package org.onap.policy.common.logging.eelf; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import lombok.Getter; /** * EventTrackInfo contains a ConcurrentHashMap of EventData. */ public class EventTrackInfo { + @Getter private final ConcurrentMap<String, EventData> eventInfo; /** @@ -80,11 +82,4 @@ public class EventTrackInfo { eventInfo.remove(eventId); } } - - /** - * Returns a ConcurrentHashMap of EventData. - */ - public ConcurrentMap<String, EventData> getEventInfo() { - return eventInfo; - } } diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java index 47c027c2..d71ebe54 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/OnapConfigProperties.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 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. @@ -20,8 +20,11 @@ package org.onap.policy.common.logging.eelf; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; -public class OnapConfigProperties { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class OnapConfigProperties { /** * The Date-time of the start of a transaction. @@ -81,8 +84,4 @@ public class OnapConfigProperties { public static final String SERVER_NAME = "ServerName"; public static final String INVOCATION_ID = "InvocationID"; - - private OnapConfigProperties() { - // do nothing - } } diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java index 15659561..662ca764 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/eelf/PolicyLogger.java @@ -61,6 +61,10 @@ import java.util.Timer; import java.util.UUID; import java.util.concurrent.ConcurrentMap; import java.util.function.Consumer; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.onap.policy.common.logging.OnapLoggingUtils; import org.onap.policy.common.logging.flexlogger.LoggerType; @@ -69,6 +73,7 @@ import org.slf4j.MDC; /** * PolicyLogger contains all the static methods for EELF logging. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class PolicyLogger { private static EELFLogger errorLogger = EELFManager.getErrorLogger(); @@ -110,7 +115,9 @@ public class PolicyLogger { // size drops to this point, stop the Timer private static int stopCheckPoint = 2500; - private static boolean isOverrideLogbackLevel = false; + @Getter + @Setter + private static boolean overrideLogbackLevel = false; private static Level debugLevel = Level.INFO; private static Level auditLevel = Level.INFO; @@ -133,10 +140,6 @@ public class PolicyLogger { } } - private PolicyLogger() { - - } - public static synchronized Level getDebugLevel() { return debugLevel; } @@ -150,7 +153,7 @@ public class PolicyLogger { */ public static synchronized void setDebugLevel(String newDebugLevel) { - if (isOverrideLogbackLevel) { + if (overrideLogbackLevel) { PolicyLogger.debugLevel = Level.valueOf(newDebugLevel); debugLogger.setLevel(debugLevel); } @@ -170,7 +173,7 @@ public class PolicyLogger { */ public static synchronized void setAuditLevel(String newAuditLevel) { - if (isOverrideLogbackLevel) { + if (overrideLogbackLevel) { if ("OFF".equalsIgnoreCase(newAuditLevel)) { PolicyLogger.auditLevel = Level.OFF; auditLogger.setLevel(auditLevel); @@ -195,7 +198,7 @@ public class PolicyLogger { */ public static synchronized void setMetricsLevel(String newMetricsLevel) { - if (isOverrideLogbackLevel) { + if (overrideLogbackLevel) { if ("OFF".equalsIgnoreCase(newMetricsLevel)) { PolicyLogger.metricsLevel = Level.OFF; metricsLogger.setLevel(metricsLevel); @@ -221,7 +224,7 @@ public class PolicyLogger { */ public static synchronized void setErrorLevel(String newErrorLevel) { - if (isOverrideLogbackLevel) { + if (overrideLogbackLevel) { if ("OFF".equalsIgnoreCase(newErrorLevel)) { PolicyLogger.errorLevel = Level.OFF; errorLogger.setLevel(errorLevel); @@ -1373,10 +1376,10 @@ public class PolicyLogger { } private static void setOverrideLogbackLevels(Properties loggerProperties) { - final String overrideLogbackLevel = loggerProperties.getProperty("override.logback.level.setup"); + final var overrideLogbackLevelText = loggerProperties.getProperty("override.logback.level.setup"); - if (!StringUtils.isBlank(overrideLogbackLevel)) { - isOverrideLogbackLevel = "TRUE".equalsIgnoreCase(overrideLogbackLevel); + if (!StringUtils.isBlank(overrideLogbackLevelText)) { + overrideLogbackLevel = "TRUE".equalsIgnoreCase(overrideLogbackLevelText); } } @@ -1395,24 +1398,6 @@ public class PolicyLogger { } } - - /** - * Returns true for overriding logback levels; returns false for not. - */ - public static boolean isOverrideLogbackLevel() { - - return isOverrideLogbackLevel; - } - - /** - * Sets true for overriding logback levels; sets false for not. - */ - public static void setOverrideLogbackLevel(boolean odl) { - - isOverrideLogbackLevel = odl; - - } - /** * Sets server information to MDC. */ diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/DisplayUtils.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/DisplayUtils.java index 6cc5dc13..425c62a4 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/DisplayUtils.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/DisplayUtils.java @@ -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. @@ -20,16 +20,17 @@ package org.onap.policy.common.logging.flexlogger; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + /** * Utilities to display messages. These are generally used while logging is being * configured, or when logging being directed to System.out. As a result, it directly * writes to System.out rather than to a logger. */ -public class DisplayUtils { - private DisplayUtils() { - // do nothing - } +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class DisplayUtils { /* * As the comment above says, these purposely write to System.out rather than a diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java index 837a584f..0e0ef2bf 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/EelfLogger.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * 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. @@ -23,6 +23,7 @@ package org.onap.policy.common.logging.flexlogger; import com.att.eelf.configuration.EELFLogger.Level; import java.io.Serializable; import java.util.UUID; +import lombok.Getter; import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; @@ -34,6 +35,7 @@ public class EelfLogger implements Logger, Serializable { private static final long serialVersionUID = 5385586713941277192L; private String className = ""; + @Getter private String transId = UUID.randomUUID().toString(); /** @@ -135,14 +137,6 @@ public class EelfLogger implements Logger, Serializable { } /** - * Returns transaction Id for logging. - */ - @Override - public String getTransId() { - return transId; - } - - /** * Records a message. * * @param message the message diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java index ccd6048c..ef6c2e95 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/PropertyUtil.java @@ -32,23 +32,23 @@ import java.util.Properties; import java.util.Set; import java.util.Timer; import java.util.TimerTask; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; /** * This class provides utilities to read properties from a properties file, and optionally get * notifications of future changes. */ -public class PropertyUtil { +public final class PropertyUtil { + + @NoArgsConstructor(access = AccessLevel.PRIVATE) protected static class LazyHolder { /** * Timer thread. Will not be allocated by the JVM until it is first referenced. * This may be overridden by junit tests. */ private static Timer timer = new Timer("PropertyUtil-Timer", true); - - private LazyHolder() { - super(); - } } // this table maps canonical file into a 'ListenerRegistration' instance diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java index a059bd77..d16a1d7a 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/flexlogger/SystemOutLogger.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * 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. @@ -26,6 +26,7 @@ import com.att.eelf.configuration.EELFLogger.Level; import java.io.Serializable; import java.util.Arrays; import java.util.UUID; +import lombok.Getter; import org.onap.policy.common.logging.OnapLoggingUtils; import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; @@ -33,16 +34,17 @@ import org.onap.policy.common.logging.eelf.PolicyLogger; /** * SystemOutLogger implements all the methods of interface Logger by calling System.out.println */ +@Getter public class SystemOutLogger implements Logger, Serializable { private static final long serialVersionUID = 4956408061058933929L; private String className = ""; - private boolean isDebugEnabled = true; - private boolean isInfoEnabled = true; - private boolean isWarnEnabled = true; - private boolean isErrorEnabled = true; - private boolean isAuditEnabled = true; - private boolean isMetricsEnabled = true; + private boolean debugEnabled = true; + private boolean infoEnabled = true; + private boolean warnEnabled = true; + private boolean errorEnabled = true; + private boolean auditEnabled = true; + private boolean metricsEnabled = true; private String transId = UUID.randomUUID().toString(); /** @@ -77,35 +79,35 @@ public class SystemOutLogger implements Logger, Serializable { private void initLevel() { if (PolicyLogger.getDebugLevel() == Level.DEBUG) { - isDebugEnabled = true; - isInfoEnabled = true; - isWarnEnabled = true; + debugEnabled = true; + infoEnabled = true; + warnEnabled = true; } else { - isDebugEnabled = false; + debugEnabled = false; } if (PolicyLogger.getDebugLevel() == Level.INFO) { - isInfoEnabled = true; - isWarnEnabled = true; - isDebugEnabled = false; + infoEnabled = true; + warnEnabled = true; + debugEnabled = false; } if (PolicyLogger.getDebugLevel() == Level.OFF) { - isInfoEnabled = false; - isWarnEnabled = false; - isDebugEnabled = false; + infoEnabled = false; + warnEnabled = false; + debugEnabled = false; } if (PolicyLogger.getErrorLevel() == Level.OFF) { - isErrorEnabled = false; + errorEnabled = false; } if (PolicyLogger.getAuditLevel() == Level.OFF) { - isAuditEnabled = false; + auditEnabled = false; } if (PolicyLogger.getMetricsLevel() == Level.OFF) { - isMetricsEnabled = false; + metricsEnabled = false; } } @@ -120,15 +122,6 @@ public class SystemOutLogger implements Logger, Serializable { } /** - * Returns transaction Id. - */ - @Override - public String getTransId() { - - return transId; - } - - /** * Records a message. * * @param message the message @@ -345,68 +338,6 @@ public class SystemOutLogger implements Logger, Serializable { } /** - * Returns true for debug enabled, or false for not. - * - * @return boolean - */ - @Override - public boolean isDebugEnabled() { - return isDebugEnabled; - } - - /** - * Returns true for warn enabled, or false for not. - * - * @return boolean - */ - @Override - public boolean isWarnEnabled() { - return isWarnEnabled; - } - - /** - * Returns true for info enabled, or false for not. - * - * @return boolean - */ - @Override - public boolean isInfoEnabled() { - return isInfoEnabled; - } - - /** - * Returns true for error enabled, or false for not. - * - * @return boolean - */ - @Override - public boolean isErrorEnabled() { - return isErrorEnabled; - } - - /** - * Returns true for audit enabled, or false for not. - * - * @return boolean - */ - @Override - public boolean isAuditEnabled() { - - return isAuditEnabled; - } - - /** - * Returns true for metrics enabled, or false for not. - * - * @return boolean - */ - @Override - public boolean isMetricsEnabled() { - - return isMetricsEnabled; - } - - /** * Records an audit message. * * @param message the message diff --git a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContextFactory.java b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContextFactory.java index ee64306f..eb2b318e 100644 --- a/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContextFactory.java +++ b/common-logging/src/main/java/org/onap/policy/common/logging/nsa/LoggingContextFactory.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-Logging * ================================================================================ - * 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,8 @@ package org.onap.policy.common.logging.nsa; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.onap.policy.common.logging.nsa.impl.SharedContext; import org.onap.policy.common.logging.nsa.impl.Slf4jLoggingContext; @@ -27,6 +29,7 @@ import org.onap.policy.common.logging.nsa.impl.Slf4jLoggingContext; * A factory for setting up a LoggingContext. * */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class LoggingContextFactory { public static class Builder { @@ -47,8 +50,4 @@ public class LoggingContextFactory { return forShared ? new SharedContext(baseContext) : new Slf4jLoggingContext(baseContext); } } - - private LoggingContextFactory() { - // do nothing - } } diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java index 240b1f40..300d49c7 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterConstants.java @@ -1,45 +1,43 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. 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. * 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. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.policy.common.parameters; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + /** * This static class holds the values of constants for parameter handling. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class ParameterConstants { // Indentation is 0 on the left and 2 for each level of hierarchy public static final String DEFAULT_INITIAL_RESULT_INDENTATION = ""; public static final String DEFAULT_RESULT_INDENTATION = " "; - + // By default we do not show validation results for parameters that are validated as clean public static final boolean DO_NOT_SHOW_CLEAN_RESULTS = false; - + // Messages for clean validations public static final String PARAMETER_GROUP_HAS_STATUS_MESSAGE = "parameter group has status "; public static final String PARAMETER_GROUP_MAP_HAS_STATUS_MESSAGE = "parameter group map has status "; public static final String PARAMETER_HAS_STATUS_MESSAGE = "parameter has status "; - - /** - * Private constructor to prevent subclassing. - */ - private ParameterConstants() { - // Private constructor to prevent subclassing - } -}
\ No newline at end of file +} diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java index 84faa9c8..aa3105ef 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterException.java @@ -21,6 +21,8 @@ package org.onap.policy.common.parameters; +import lombok.Getter; + /** * Exception thrown oon parameter reading, validation, and check errors. * @@ -30,6 +32,7 @@ public class ParameterException extends Exception { private static final long serialVersionUID = -8507246953751956974L; // The object on which the exception was thrown + @Getter private final transient Object object; /** @@ -100,13 +103,4 @@ public class ParameterException extends Exception { return builder.toString(); } - - /** - * Get the object on which the exception was thrown. - * - * @return The object on which the exception was thrown - */ - public Object getObject() { - return object; - } } diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterRuntimeException.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterRuntimeException.java index 071593a9..4eb79447 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterRuntimeException.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterRuntimeException.java @@ -1,25 +1,28 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. 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. * 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. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.policy.common.parameters; +import lombok.Getter; + /** * A run time exception thrown on parameter validations. * @@ -29,6 +32,7 @@ public class ParameterRuntimeException extends RuntimeException { private static final long serialVersionUID = -8507246953751956974L; // The object on which the exception was thrown + @Getter private final transient Object object; /** @@ -81,13 +85,4 @@ public class ParameterRuntimeException extends RuntimeException { public String getCascadedMessage() { return ParameterException.buildCascadedMessage(this); } - - /** - * Get the object on which the exception was thrown. - * - * @return The object - */ - public Object getObject() { - return object; - } } diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java index 7bf0ac5f..a368d25f 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ParameterService.java @@ -25,6 +25,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; /** * The parameter service makes ONAP PF parameter groups available to all classes in a JVM. @@ -37,25 +39,18 @@ import java.util.concurrent.ConcurrentHashMap; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public abstract class ParameterService { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class ParameterService { // The map holding the parameters private static Map<String, ParameterGroup> parameterGroupMap = new ConcurrentHashMap<>(); /** - * This class is an abstract static class that cannot be extended. - */ - private ParameterService() { - } - - /** * Register a parameter group with the parameter service. * * @param parameterGroup the parameter group */ public static void register(final ParameterGroup parameterGroup) { - if (!parameterGroupMap.containsKey(parameterGroup.getName())) { - parameterGroupMap.put(parameterGroup.getName(), parameterGroup); - } else { + if (parameterGroupMap.putIfAbsent(parameterGroup.getName(), parameterGroup) != null) { throw new ParameterRuntimeException( "\"" + parameterGroup.getName() + "\" already registered in parameter service"); } @@ -81,9 +76,7 @@ public abstract class ParameterService { * @param parameterGroupName the name of the parameter group */ public static void deregister(final String parameterGroupName) { - if (parameterGroupMap.containsKey(parameterGroupName)) { - parameterGroupMap.remove(parameterGroupName); - } else { + if (parameterGroupMap.remove(parameterGroupName) == null) { throw new ParameterRuntimeException("\"" + parameterGroupName + "\" not registered in parameter service"); } } @@ -121,7 +114,7 @@ public abstract class ParameterService { * @return true if the parameter is defined */ public static boolean contains(final String parameterGroupName) { - return parameterGroupMap.containsKey(parameterGroupName) && parameterGroupMap.get(parameterGroupName) != null; + return parameterGroupMap.get(parameterGroupName) != null; } /** diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java index 0fda51ad..45898818 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValidationResultImpl.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,12 +21,14 @@ package org.onap.policy.common.parameters; +import lombok.AllArgsConstructor; import lombok.Getter; /** * Basic implementation of a ValidationResult. */ @Getter +@AllArgsConstructor public abstract class ValidationResultImpl implements ValidationResult { public static final String ITEM_HAS_STATUS_MESSAGE = "item has status "; @@ -63,21 +65,6 @@ public abstract class ValidationResultImpl implements ValidationResult { } /** - * Constructs the object. - * - * @param name name of the object of this result - * @param object object being validated - * @param status the validation status - * @param message the validation message explaining the validation status - */ - protected ValidationResultImpl(String name, Object object, ValidationStatus status, String message) { - this.name = name; - this.object = object; - this.status = status; - this.message = message; - } - - /** * Validates that the value is not {@code null}. * * @return {@code true} if the value is not null, {@code false} otherwise diff --git a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValueValidator.java b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValueValidator.java index a8a0e614..faf41008 100644 --- a/common-parameters/src/main/java/org/onap/policy/common/parameters/ValueValidator.java +++ b/common-parameters/src/main/java/org/onap/policy/common/parameters/ValueValidator.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List; import lombok.AccessLevel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import org.onap.policy.common.parameters.annotations.NotNull; @@ -34,6 +35,7 @@ import org.onap.policy.common.parameters.annotations.NotNull; * Note: this currently does not support Min/Max validation of "short" or "byte"; these * annotations are simply ignored for these types. */ +@NoArgsConstructor public class ValueValidator { /** @@ -55,14 +57,6 @@ public class ValueValidator { */ protected List<Checker> checkers = new ArrayList<>(10); - - /** - * Constructs the object. - */ - public ValueValidator() { - // do nothing - } - /** * Determines if the validator has anything to check. * diff --git a/gson/src/main/java/org/onap/policy/common/gson/DoubleConverter.java b/gson/src/main/java/org/onap/policy/common/gson/DoubleConverter.java index cbf5d0e7..4d10bd13 100644 --- a/gson/src/main/java/org/onap/policy/common/gson/DoubleConverter.java +++ b/gson/src/main/java/org/onap/policy/common/gson/DoubleConverter.java @@ -25,18 +25,17 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; /** * Converter for Double values. By default, GSON treats all Objects that are numbers, as * Double. This converts Doubles to Integer or Long, if possible. It converts stand-alone * Doubles, as well as those found within Arrays and Maps. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class DoubleConverter { - private DoubleConverter() { - // do nothing - } - /** * Performs in-place conversion of all values in a list. * diff --git a/gson/src/main/java/org/onap/policy/common/gson/internal/Adapter.java b/gson/src/main/java/org/onap/policy/common/gson/internal/Adapter.java index c15ccb7d..af4a746c 100644 --- a/gson/src/main/java/org/onap/policy/common/gson/internal/Adapter.java +++ b/gson/src/main/java/org/onap/policy/common/gson/internal/Adapter.java @@ -29,6 +29,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.function.Supplier; +import lombok.Getter; import org.onap.policy.common.gson.annotation.GsonJsonProperty; /** @@ -49,6 +50,7 @@ public class Adapter { /** * Name of the property within the json structure containing the item. */ + @Getter private final String propName; /** @@ -69,6 +71,7 @@ public class Adapter { /** * Name of the item being lifted - used when throwing exceptions. */ + @Getter private final String fullName; /** @@ -143,14 +146,6 @@ public class Adapter { return reader.getConverter().fromJsonTree(tree); } - public final String getPropName() { - return propName; - } - - public final String getFullName() { - return fullName; - } - /** * Makes an error message, appending the item's full name to the message prefix. * diff --git a/gson/src/main/java/org/onap/policy/common/gson/internal/ClassWalker.java b/gson/src/main/java/org/onap/policy/common/gson/internal/ClassWalker.java index ef4eaae3..954d3f4c 100644 --- a/gson/src/main/java/org/onap/policy/common/gson/internal/ClassWalker.java +++ b/gson/src/main/java/org/onap/policy/common/gson/internal/ClassWalker.java @@ -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. @@ -30,6 +30,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import lombok.Getter; import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter; import org.onap.policy.common.gson.annotation.GsonJsonAnySetter; import org.onap.policy.common.gson.annotation.GsonJsonIgnore; @@ -79,23 +80,16 @@ public class ClassWalker { * Method having {@link GsonJsonAnyGetter} annotation. Overwritten as new "any-getters" * are identified. */ + @Getter private Method anyGetter = null; /** * Method having {@link GsonJsonAnySetter} annotation. Overwritten as new "any-setters" * are identified. */ + @Getter private Method anySetter = null; - - public Method getAnyGetter() { - return anyGetter; - } - - public Method getAnySetter() { - return anySetter; - } - /** * Gets the names of input properties that are not being ignored. * diff --git a/integrity-audit/pom.xml b/integrity-audit/pom.xml index cf46fc7a..4e857919 100644 --- a/integrity-audit/pom.xml +++ b/integrity-audit/pom.xml @@ -39,6 +39,10 @@ <dependencies> <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java index 95eecbc3..5bfedaac 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/AuditorTime.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * Integrity Audit * ================================================================================ - * 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,11 +21,14 @@ package org.onap.policy.common.ia; import java.util.function.Supplier; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.onap.policy.common.utils.time.CurrentTime; /** * "Current" time used by IntegrityMonitor classes. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class AuditorTime { /** @@ -41,15 +44,8 @@ public class AuditorTime { private static Supplier<CurrentTime> supplier = () -> currentTime; /** - * Constructor. - */ - private AuditorTime() { - super(); - } - - /** * Get instance. - * + * * @return the CurrentTime singleton */ public static CurrentTime getInstance() { diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java index 10900e3c..66ab307c 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAudit.java @@ -21,6 +21,8 @@ package org.onap.policy.common.ia; import java.util.Properties; +import lombok.Getter; +import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.onap.policy.common.ia.IntegrityAuditProperties.NodeTypeEnum; import org.onap.policy.common.logging.flexlogger.FlexLogger; @@ -34,8 +36,12 @@ public class IntegrityAudit { private static final Logger logger = FlexLogger.getLogger(IntegrityAudit.class); - private static boolean isUnitTesting; - private boolean isThreadInitialized = false; + @Getter + @Setter + private static boolean unitTesting; + + @Getter + private boolean threadInitialized = false; AuditThread auditThread = null; @@ -54,6 +60,7 @@ public class IntegrityAudit { * indicated period * */ + @Getter private int integrityAuditPeriodSeconds; /** @@ -94,13 +101,6 @@ public class IntegrityAudit { } /** - * Used during JUnit testing by AuditPeriodTest.java - */ - public int getIntegrityAuditPeriodSeconds() { - return integrityAuditPeriodSeconds; - } - - /** * Determine if the nodeType conforms to the required node types. */ public static boolean isNodeTypeEnum(String nt) { @@ -237,21 +237,9 @@ public class IntegrityAudit { logger.info("stopAuditThread: Exiting"); } - public boolean isThreadInitialized() { - return isThreadInitialized; - } - public void setThreadInitialized(boolean isThreadInitialized) { logger.info("setThreadInitialized: Setting isThreadInitialized=" + isThreadInitialized); - this.isThreadInitialized = isThreadInitialized; - } - - public static boolean isUnitTesting() { - return isUnitTesting; - } - - public static void setUnitTesting(boolean isUnitTesting) { - IntegrityAudit.isUnitTesting = isUnitTesting; + this.threadInitialized = isThreadInitialized; } /** diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java index 365afd25..9122b721 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/IntegrityAuditProperties.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Integrity Audit * ================================================================================ - * 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. @@ -20,6 +20,10 @@ package org.onap.policy.common.ia; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class IntegrityAuditProperties { public static final int DEFAULT_AUDIT_PERIOD_SECONDS = -1; // Audit does not run @@ -38,9 +42,4 @@ public class IntegrityAuditProperties { PDP_XACML, PDP_DROOLS, PAP, PAP_ADMIN, LOGPARSER, BRMS_GATEWAY, ASTRA_GATEWAY, ELK_SERVER, PYPDP } - - private IntegrityAuditProperties() { - - } - } diff --git a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java index 1c8277c0..37688859 100644 --- a/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java +++ b/integrity-audit/src/main/java/org/onap/policy/common/ia/jpa/IntegrityAuditEntity.java @@ -35,6 +35,10 @@ import javax.persistence.PreUpdate; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /* * The Entity class to for management of IntegrityAudits */ @@ -44,15 +48,20 @@ import org.onap.policy.common.ia.AuditorTime; @Table(name = "IntegrityAuditEntity") @NamedQuery(name = " IntegrityAuditEntity.findAll", query = "SELECT e FROM IntegrityAuditEntity e ") @NamedQuery(name = "IntegrityAuditEntity.deleteAll", query = "DELETE FROM IntegrityAuditEntity WHERE 1=1") - +@NoArgsConstructor +@Getter +@Setter public class IntegrityAuditEntity implements Serializable { private static final long serialVersionUID = 1L; - private static boolean isUnitTesting; + @Getter + @Setter + private static boolean unitTesting; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") + @Setter(AccessLevel.PRIVATE) private long id; @Column(name = "persistenceUnit", nullable = false) @@ -90,11 +99,6 @@ public class IntegrityAuditEntity implements Serializable { @Column(name = "lastUpdated") private Date lastUpdated; - - public IntegrityAuditEntity() { - // Empty constructor - } - /** * Pre persist. */ @@ -110,106 +114,6 @@ public class IntegrityAuditEntity implements Serializable { this.lastUpdated = AuditorTime.getInstance().getDate(); } - public long getId() { - return id; - } - - public String getPersistenceUnit() { - return persistenceUnit; - } - - public void setPersistenceUnit(String persistenceUnit) { - this.persistenceUnit = persistenceUnit; - } - - public String getSite() { - return site; - } - - public void setSite(String site) { - this.site = site; - } - - public String getNodeType() { - return nodeType; - } - - public void setNodeType(String nodeType) { - this.nodeType = nodeType; - } - - public String getResourceName() { - return resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - public boolean isDesignated() { - return designated; - } - - public void setDesignated(boolean designated) { - this.designated = designated; - } - - public String getJdbcDriver() { - return jdbcDriver; - } - - public void setJdbcDriver(String jdbcDriver) { - this.jdbcDriver = jdbcDriver; - } - - public String getJdbcUrl() { - return jdbcUrl; - } - - public void setJdbcUrl(String jdbcUrl) { - this.jdbcUrl = jdbcUrl; - } - - public String getJdbcUser() { - return jdbcUser; - } - - public void setJdbcUser(String jdbcUser) { - this.jdbcUser = jdbcUser; - } - - public String getJdbcPassword() { - return jdbcPassword; - } - - public void setJdbcPassword(String jdbcPassword) { - this.jdbcPassword = jdbcPassword; - } - - public Date getLastUpdated() { - return lastUpdated; - } - - public void setLastUpdated(Date lastUpdated) { - this.lastUpdated = lastUpdated; - } - - public Date getCreatedDate() { - return createdDate; - } - - public void setCreatedDate(Date created) { - this.createdDate = created; - } - - public static boolean isUnitTesting() { - return isUnitTesting; - } - - public static void setUnitTesting(boolean isUnitTesting) { - IntegrityAuditEntity.isUnitTesting = isUnitTesting; - } - private void writeObject(ObjectOutputStream out) throws IOException { if (isUnitTesting()) { /* diff --git a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java index 1866bba0..a8e3fbef 100644 --- a/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java +++ b/integrity-audit/src/test/java/org/onap/policy/common/ia/IntegrityAuditTestBase.java @@ -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(); diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java index 71a5db06..d4454db3 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitor.java @@ -44,6 +44,8 @@ import javax.persistence.FlushModeType; import javax.persistence.LockModeType; import javax.persistence.Persistence; import javax.persistence.TypedQuery; +import lombok.Getter; +import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.eclipse.persistence.config.PersistenceUnitProperties; import org.onap.policy.common.im.jmx.ComponentAdmin; @@ -104,6 +106,7 @@ public class IntegrityMonitor { public static final long CYCLE_INTERVAL_MILLIS = 1000L; + @Getter private StateManagement stateManager = null; /** @@ -162,7 +165,9 @@ public class IntegrityMonitor { // For non-lead subsystems, the dependency_group property will be absent. private static String[] depGroups = null; - private static boolean isUnitTesting = false; + @Getter + @Setter + private static boolean unitTesting = false; // can turn on health checking of dependents via jmx test() call by setting // this property to true @@ -198,7 +203,9 @@ public class IntegrityMonitor { private final Object refreshStateAuditLock = new Object(); private final Object imFlushLock = new Object(); + @Getter private Map<String, String> allSeemsWellMap; + @Getter private Map<String, String> allNotWellMap; /** @@ -1254,11 +1261,6 @@ public class IntegrityMonitor { } } - // retrieve state manager reference - public final StateManagement getStateManager() { - return this.stateManager; - } - /** * Read and validate properties. * @@ -1894,14 +1896,6 @@ public class IntegrityMonitor { return (value < 0 ? -1 : value * 1000L); } - public Map<String, String> getAllSeemsWellMap() { - return allSeemsWellMap; - } - - public Map<String, String> getAllNotWellMap() { - return allNotWellMap; - } - // these methods may be overridden by junit tests /** @@ -1930,16 +1924,4 @@ public class IntegrityMonitor { protected String getPersistenceUnit() { return PERSISTENCE_UNIT; } - - /* - * The remaining methods are used by JUnit tests. - */ - - public static boolean isUnitTesting() { - return isUnitTesting; - } - - public static void setUnitTesting(boolean isUnitTesting) { - IntegrityMonitor.isUnitTesting = isUnitTesting; - } } diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java index 252fd27b..75aed5b3 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/IntegrityMonitorProperties.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Integrity Monitor * ================================================================================ - * Copyright (C) 2017-2018, 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018, 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. @@ -20,7 +20,11 @@ package org.onap.policy.common.im; -public class IntegrityMonitorProperties { +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class IntegrityMonitorProperties { public static final String DB_DRIVER = "javax.persistence.jdbc.driver"; public static final String DB_URL = "javax.persistence.jdbc.url"; @@ -54,8 +58,4 @@ public class IntegrityMonitorProperties { // AllSeemsWell types public static final Boolean ALLNOTWELL = Boolean.FALSE; public static final Boolean ALLSEEMSWELL = Boolean.TRUE; - - private IntegrityMonitorProperties() { - // Private constructor to prevent subclassing - } } diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/MonitorTime.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/MonitorTime.java index e489a8c1..61afb682 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/MonitorTime.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/MonitorTime.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * Integrity Monitor * ================================================================================ - * 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. @@ -20,31 +20,20 @@ package org.onap.policy.common.im; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; import org.onap.policy.common.utils.time.CurrentTime; /** * "Current" time used by IntegrityMonitor classes. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class MonitorTime { /** * Instance to be used. This is overridden by junit tests. */ + @Getter private static CurrentTime instance = new CurrentTime(); - - /** - * Constructor. - */ - private MonitorTime() { - super(); - } - - /** - * Get instance. - * - * @return the CurrentTime singleton - */ - public static CurrentTime getInstance() { - return instance; - } } diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateChangeNotifier.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateChangeNotifier.java index eee3a9ef..5fc111e0 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateChangeNotifier.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateChangeNotifier.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Integrity Monitor * ================================================================================ - * Copyright (C) 2017, 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017, 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. @@ -20,6 +20,7 @@ package org.onap.policy.common.im; +import lombok.Getter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /* @@ -43,6 +44,7 @@ import org.slf4j.LoggerFactory; * StateManagement class. * */ +@Getter public class StateChangeNotifier { private static final Logger logger = LoggerFactory.getLogger(StateChangeNotifier.class); // The observable class @@ -71,12 +73,4 @@ public class StateChangeNotifier { logger.debug("handleStateChange, message: {}", this.message); } } - - public StateManagement getStateManagement() { - return stateManagement; - } - - public String getMessage() { - return message; - } } diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateElement.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateElement.java index 73724b30..d1bc9cc1 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateElement.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateElement.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Integrity Monitor * ================================================================================ - * 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. @@ -21,12 +21,14 @@ package org.onap.policy.common.im; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Getter @Setter +@NoArgsConstructor public class StateElement { private static final Logger logger = LoggerFactory.getLogger(StateElement.class); @@ -41,10 +43,6 @@ public class StateElement { String endingStandbyStatus = null; String exception = null; - public StateElement() { - // Empty constructor - } - /** * Display the state element. */ diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java index 9ee095fb..b68373ba 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/StateManagement.java @@ -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(); } } diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java index 2f9544e9..ad1ef365 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ForwardProgressEntity.java @@ -33,6 +33,10 @@ import javax.persistence.PreUpdate; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; /* * The Entity class to persist a policy object ForwardProgress */ @@ -43,7 +47,9 @@ import org.onap.policy.common.im.MonitorTime; @NamedQuery(name = " ForwardProgressEntity.findAll", query = "SELECT e FROM ForwardProgressEntity e ") @NamedQuery(name = "ForwardProgressEntity.deleteAll", query = "DELETE FROM ForwardProgressEntity WHERE 1=1") // @SequenceGenerator(name="seqForwardProgress", initialValue=1, allocationSize=1) - +@Getter +@Setter +@NoArgsConstructor public class ForwardProgressEntity implements Serializable { private static final long serialVersionUID = 1L; @@ -51,6 +57,7 @@ public class ForwardProgressEntity implements Serializable { // @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqForwardProgress") @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "forwardProgressId") + @Setter(AccessLevel.NONE) private long forwardProgressId; @Column(name = "resourceName", nullable = false, length = 100, unique = true) @@ -67,10 +74,6 @@ public class ForwardProgressEntity implements Serializable { @Column(name = "last_updated") private Date lastUpdated; - public ForwardProgressEntity() { - // default constructor - } - /** * PrePersist callback method. */ @@ -86,57 +89,4 @@ public class ForwardProgressEntity implements Serializable { public void preUpdate() { this.lastUpdated = MonitorTime.getInstance().getDate(); } - - /** - * Get the forward progress Id. - * - * @return the Id - */ - public long getForwardProgressId() { - return forwardProgressId; - } - - public String getResourceName() { - return this.resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - /** - * Get the fpcCount. - * - * @return the fpcCount - */ - public long getFpcCount() { - return fpcCount; - } - - /** - * Set the fpcCount. - * - * @param fpcCount the fpcCount to set - */ - public void setFpcCount(long fpcCount) { - this.fpcCount = fpcCount; - } - - /** - * Get the lastUpdated. - * - * @return the lastUpdated - */ - public Date getLastUpdated() { - return lastUpdated; - } - - /** - * Set the lastUpdated. - * - * @param lastUpdated the lastUpdated to set - */ - public void setLastUpdated(Date lastUpdated) { - this.lastUpdated = lastUpdated; - } } diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java index 858a3f77..2b7b3d74 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ImTestEntity.java @@ -33,6 +33,10 @@ import javax.persistence.PreUpdate; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import org.onap.policy.common.im.MonitorTime; @Entity @@ -40,7 +44,9 @@ import org.onap.policy.common.im.MonitorTime; @NamedQuery(name = " ImTestEntity.findAll", query = "SELECT e FROM ImTestEntity e ") @NamedQuery(name = "ImTestEntity.deleteAll", query = "DELETE FROM ImTestEntity WHERE 1=1") // @SequenceGenerator(name="seqImTest", initialValue=1, allocationSize=1) - +@Getter +@Setter +@NoArgsConstructor public class ImTestEntity implements Serializable { private static final long serialVersionUID = 1L; @@ -48,6 +54,7 @@ public class ImTestEntity implements Serializable { // @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqImTest") @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "ImTestId") + @Setter(AccessLevel.NONE) private long imTestId; @Column(name = "created_by", nullable = false, length = 255) @@ -64,10 +71,6 @@ public class ImTestEntity implements Serializable { @Column(name = "modified_date", nullable = false) private Date modifiedDate; - public ImTestEntity() { - // default constructor - } - /** * PrePersist callback method. */ @@ -82,76 +85,4 @@ public class ImTestEntity implements Serializable { public void preUpdate() { this.modifiedDate = MonitorTime.getInstance().getDate(); } - - /** - * Get the Im test Id. - * - * @return the Id - */ - public long getImTestId() { - return imTestId; - } - - /** - * Get the createdBy. - * - * @return the createdBy - */ - public String getCreatedBy() { - return createdBy; - } - - /** - * Set the createdBy. - * - * @param createdBy the createdBy to set - */ - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - /** - * Get the modifiedBy. - * - * @return the modifiedBy - */ - public String getModifiedBy() { - return modifiedBy; - } - - /** - * Set the ModifiedBy. - * - * @param modifiedBy the modifiedBy to set - */ - public void setModifiedBy(String modifiedBy) { - this.modifiedBy = modifiedBy; - } - - /** - * Get the modifiedDate. - * - * @return the modifiedDate - */ - public Date getModifiedDate() { - return modifiedDate; - } - - /** - * Set the modifiedDate. - * - * @param modifiedDate the modifiedDate to set - */ - public void setModifiedDate(Date modifiedDate) { - this.modifiedDate = modifiedDate; - } - - /** - * Get the createdDate. - * - * @return the createdDate - */ - public Date getCreatedDate() { - return createdDate; - } } diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java index 0e654d36..1754c405 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/ResourceRegistrationEntity.java @@ -33,6 +33,10 @@ import javax.persistence.PreUpdate; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import org.onap.policy.common.im.MonitorTime; /* * The Entity class to persist a policy object ResourceRegistration @@ -43,7 +47,9 @@ import org.onap.policy.common.im.MonitorTime; @NamedQuery(name = " ResourceRegistrationEntity.findAll", query = "SELECT e FROM ResourceRegistrationEntity e ") @NamedQuery(name = "ResourceRegistrationEntity.deleteAll", query = "DELETE FROM ResourceRegistrationEntity WHERE 1=1") // @SequenceGenerator(name="seqResourceRegistration", initialValue=1, allocationSize=1) - +@Getter +@Setter +@NoArgsConstructor public class ResourceRegistrationEntity implements Serializable { private static final long serialVersionUID = 1L; @@ -51,6 +57,7 @@ public class ResourceRegistrationEntity implements Serializable { // @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqResourceRegistration") @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "ResourceRegistrationId") + @Setter(AccessLevel.NONE) private long resourceRegistrationId; @Column(name = "resourceName", nullable = false, length = 100, unique = true) @@ -73,10 +80,6 @@ public class ResourceRegistrationEntity implements Serializable { @Column(name = "last_updated") private Date lastUpdated; - public ResourceRegistrationEntity() { - // default constructor - } - /** * PrePersist callback method. */ @@ -91,72 +94,4 @@ public class ResourceRegistrationEntity implements Serializable { public void preUpdate() { this.lastUpdated = MonitorTime.getInstance().getDate(); } - - /** - * Get the resource registration Id. - * - * @return the Id - */ - public long getResourceRegistrationId() { - return resourceRegistrationId; - } - - public String getResourceName() { - return this.resourceName; - } - - public void setResourceName(String resourceName) { - this.resourceName = resourceName; - } - - public String getResourceUrl() { - return this.resourceUrl; - } - - public void setResourceUrl(String resourceUrl) { - this.resourceUrl = resourceUrl; - } - - public String getSite() { - return this.site; - } - - public void setSite(String site) { - this.site = site; - } - - public String getNodeType() { - return this.nodeType; - } - - public void setNodeType(String nodeType) { - this.nodeType = nodeType; - } - - /** - * Get the createdDate. - * - * @return the createdDate - */ - public Date getCreatedDate() { - return createdDate; - } - - /** - * Get the lastUpdated. - * - * @return the lastUpdated - */ - public Date getLastUpdated() { - return lastUpdated; - } - - /** - * Set the lastUpdated. - * - * @param lastUpdated the lastUpdated to set - */ - public void setLastUpdated(Date lastUpdated) { - this.lastUpdated = lastUpdated; - } } diff --git a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java index b13d3a76..c04a1b3a 100644 --- a/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java +++ b/integrity-monitor/src/main/java/org/onap/policy/common/im/jpa/StateManagementEntity.java @@ -35,6 +35,7 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import lombok.AccessLevel; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; import org.onap.policy.common.im.MonitorTime; @@ -45,7 +46,7 @@ import org.onap.policy.common.im.MonitorTime; @Getter @Setter - +@NoArgsConstructor public class StateManagementEntity implements Serializable { private static final long serialVersionUID = 1L; @@ -81,10 +82,6 @@ public class StateManagementEntity implements Serializable { @Column(name = "modifiedDate", nullable = false) private Date modifiedDate; - public StateManagementEntity() { - // default constructor - } - @PrePersist public void prePersist() { this.createdDate = MonitorTime.getInstance().getDate(); diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java b/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java index 1357a51f..161e7c5c 100644 --- a/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java +++ b/utils-test/src/main/java/org/onap/policy/common/utils/gson/GsonTestUtils.java @@ -37,6 +37,9 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map.Entry; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.apache.commons.jexl3.JexlBuilder; import org.apache.commons.jexl3.JexlContext; import org.apache.commons.jexl3.JexlEngine; @@ -48,6 +51,7 @@ import org.slf4j.LoggerFactory; /** * Utilities used to test encoding and decoding of Policy objects. */ +@AllArgsConstructor(access = AccessLevel.PROTECTED) public class GsonTestUtils { private static final Logger logger = LoggerFactory.getLogger(GsonTestUtils.class); @@ -65,6 +69,7 @@ public class GsonTestUtils { /** * Used to encode and decode an object via gson. */ + @Getter private Gson gson; /** @@ -77,19 +82,6 @@ public class GsonTestUtils { } /** - * Constructs the object. - * - * @param gson used to encode via gson - */ - protected GsonTestUtils(Gson gson) { - this.gson = gson; - } - - public Gson getGson() { - return gson; - } - - /** * Serializes and then deserializes an object using gson. * * @param object the object to be serialized diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/io/Serializer.java b/utils-test/src/main/java/org/onap/policy/common/utils/io/Serializer.java index 39266a66..f3e1418a 100644 --- a/utils-test/src/main/java/org/onap/policy/common/utils/io/Serializer.java +++ b/utils-test/src/main/java/org/onap/policy/common/utils/io/Serializer.java @@ -25,10 +25,13 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; /** * Utilities for testing serialization and de-serialization of objects. */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class Serializer { /** @@ -37,13 +40,6 @@ public class Serializer { private static Factory factory = new Factory(); /** - * The constructor. - */ - private Serializer() { - - } - - /** * Serializes an object into a byte array. * * @param object the object to be serialized diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/test/ToStringTester.java b/utils-test/src/main/java/org/onap/policy/common/utils/test/ToStringTester.java index 3890ae95..ab09291c 100644 --- a/utils-test/src/main/java/org/onap/policy/common/utils/test/ToStringTester.java +++ b/utils-test/src/main/java/org/onap/policy/common/utils/test/ToStringTester.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,6 +29,7 @@ import com.openpojo.reflection.PojoClass; import com.openpojo.validation.affirm.Affirm; import com.openpojo.validation.test.Tester; import com.openpojo.validation.utils.ValidationHelper; +import lombok.AllArgsConstructor; import org.hamcrest.Matcher; @@ -37,6 +38,7 @@ import org.hamcrest.Matcher; * * @author Ram Krishna Verma (ram.krishna.verma@est.tech) */ +@AllArgsConstructor public class ToStringTester implements Tester { private final Matcher<?> matcher; @@ -45,10 +47,6 @@ public class ToStringTester implements Tester { matcher = anything(); } - public ToStringTester(final Matcher<?> matcher) { - this.matcher = matcher; - } - @SuppressWarnings("unchecked") @Override public void run(final PojoClass pojoClass) { diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorService.java b/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorService.java index 847b058e..71a24528 100644 --- a/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorService.java +++ b/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledExecutorService.java @@ -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. @@ -31,6 +31,7 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; +import lombok.Getter; /** * Scheduled executor service that uses {@link TestTimeMulti} to execute its tasks. Note: @@ -48,6 +49,7 @@ public class PseudoScheduledExecutorService implements ScheduledExecutorService * {@code True} if {@link #shutdown()} or {@link #shutdownNow()} has been called, * {@code false} otherwise. */ + @Getter private boolean shutdown = false; /** @@ -80,11 +82,6 @@ public class PseudoScheduledExecutorService implements ScheduledExecutorService } @Override - public boolean isShutdown() { - return shutdown; - } - - @Override public boolean isTerminated() { return isShutdown(); } diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledFuture.java b/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledFuture.java index 6ce7bc04..34c756bb 100644 --- a/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledFuture.java +++ b/utils-test/src/main/java/org/onap/policy/common/utils/time/PseudoScheduledFuture.java @@ -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. @@ -39,6 +39,7 @@ class PseudoScheduledFuture<T> extends FutureTask<T> implements RunnableSchedule /** * {@code True} if this task is periodic, {@code false} otherwise. */ + @Getter private final boolean periodic; /** @@ -82,11 +83,6 @@ class PseudoScheduledFuture<T> extends FutureTask<T> implements RunnableSchedule } @Override - public boolean isPeriodic() { - return periodic; - } - - @Override public void run() { if (isPeriodic()) { super.runAndReset(); diff --git a/utils-test/src/main/java/org/onap/policy/common/utils/time/TestTime.java b/utils-test/src/main/java/org/onap/policy/common/utils/time/TestTime.java index 420021f3..ace19160 100644 --- a/utils-test/src/main/java/org/onap/policy/common/utils/time/TestTime.java +++ b/utils-test/src/main/java/org/onap/policy/common/utils/time/TestTime.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * Common Utils-Test * ================================================================================ - * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-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,12 +22,14 @@ package org.onap.policy.common.utils.time; import java.util.Date; import java.util.concurrent.atomic.AtomicLong; +import lombok.NoArgsConstructor; /** * "Current" time, when running junit tests. This is intended to be injected into classes * under test, to replace their {@link CurrentTime} objects. When {@link #sleep(long)} is * invoked, it simply advances the notion of "current" time and returns immediately. */ +@NoArgsConstructor public class TestTime extends CurrentTime { /** @@ -35,14 +37,6 @@ public class TestTime extends CurrentTime { */ private AtomicLong tcur = new AtomicLong(System.currentTimeMillis()); - /** - * Constructor. - * - */ - public TestTime() { - super(); - } - @Override public long getMillis() { return tcur.get(); diff --git a/utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoder.java b/utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoder.java index 0d84f85c..d6135afd 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoder.java +++ b/utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoder.java @@ -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()); diff --git a/utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoderObject.java b/utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoderObject.java index f6c3ca43..55f7f9d7 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoderObject.java +++ b/utils/src/main/java/org/onap/policy/common/utils/coder/StandardCoderObject.java @@ -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; /** @@ -48,24 +53,6 @@ public class StandardCoderObject implements Serializable { } /** - * 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. * * @param fields field hierarchy. These may be strings, identifying fields within the diff --git a/utils/src/main/java/org/onap/policy/common/utils/coder/YamlJsonTranslator.java b/utils/src/main/java/org/onap/policy/common/utils/coder/YamlJsonTranslator.java index b694dd4f..417e2cf2 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/coder/YamlJsonTranslator.java +++ b/utils/src/main/java/org/onap/policy/common/utils/coder/YamlJsonTranslator.java @@ -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 { /** @@ -71,15 +73,6 @@ public class YamlJsonTranslator { } /** - * 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. * * @param object POJO to be translated diff --git a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrCloser.java b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrCloser.java index 3532002e..f975422e 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrCloser.java +++ b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrCloser.java @@ -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,39 +21,25 @@ 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(); } } diff --git a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloser.java b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloser.java index b046cc55..8901277f 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloser.java +++ b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityMgrFactoryCloser.java @@ -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,39 +21,25 @@ 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(); } } diff --git a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java index 3552a6fa..bc5623b0 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java +++ b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java @@ -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(); } } - } diff --git a/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java b/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java index a0a83905..e3539fb7 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java +++ b/utils/src/main/java/org/onap/policy/common/utils/network/NetworkUtil.java @@ -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. * diff --git a/utils/src/main/java/org/onap/policy/common/utils/properties/PropertyObjectUtils.java b/utils/src/main/java/org/onap/policy/common/utils/properties/PropertyObjectUtils.java index 1a08bb47..2b6e514f 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/properties/PropertyObjectUtils.java +++ b/utils/src/main/java/org/onap/policy/common/utils/properties/PropertyObjectUtils.java @@ -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. diff --git a/utils/src/main/java/org/onap/policy/common/utils/properties/SpecProperties.java b/utils/src/main/java/org/onap/policy/common/utils/properties/SpecProperties.java index f711a058..2ea94959 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/properties/SpecProperties.java +++ b/utils/src/main/java/org/onap/policy/common/utils/properties/SpecProperties.java @@ -21,10 +21,13 @@ 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"); diff --git a/utils/src/main/java/org/onap/policy/common/utils/properties/exception/PropertyException.java b/utils/src/main/java/org/onap/policy/common/utils/properties/exception/PropertyException.java index d6895847..3c03f38d 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/properties/exception/PropertyException.java +++ b/utils/src/main/java/org/onap/policy/common/utils/properties/exception/PropertyException.java @@ -20,9 +20,12 @@ 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; @@ -93,26 +96,6 @@ public class PropertyException extends Exception { } /** - * 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. * * @param propnm name of the property causing the exception, or {@code null} diff --git a/utils/src/main/java/org/onap/policy/common/utils/resources/MessageConstants.java b/utils/src/main/java/org/onap/policy/common/utils/resources/MessageConstants.java index 8ec0c018..ef46fdf5 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/resources/MessageConstants.java +++ b/utils/src/main/java/org/onap/policy/common/utils/resources/MessageConstants.java @@ -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. @@ -20,10 +21,14 @@ 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(); - } } diff --git a/utils/src/main/java/org/onap/policy/common/utils/resources/ResourceUtils.java b/utils/src/main/java/org/onap/policy/common/utils/resources/ResourceUtils.java index 589c3098..83d41fb3 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/resources/ResourceUtils.java +++ b/utils/src/main/java/org/onap/policy/common/utils/resources/ResourceUtils.java @@ -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); @@ -55,13 +58,6 @@ public abstract class ResourceUtils { 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. * * @param resourceName The resource name diff --git a/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java b/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java index 5288beff..9df98801 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java +++ b/utils/src/main/java/org/onap/policy/common/utils/resources/TextFileUtils.java @@ -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. diff --git a/utils/src/main/java/org/onap/policy/common/utils/services/FeatureApiUtils.java b/utils/src/main/java/org/onap/policy/common/utils/services/FeatureApiUtils.java index 332e0f67..042ee937 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/services/FeatureApiUtils.java +++ b/utils/src/main/java/org/onap/policy/common/utils/services/FeatureApiUtils.java @@ -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. diff --git a/utils/src/main/java/org/onap/policy/common/utils/services/Registry.java b/utils/src/main/java/org/onap/policy/common/utils/services/Registry.java index c3eabe8e..8765ba8b 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/services/Registry.java +++ b/utils/src/main/java/org/onap/policy/common/utils/services/Registry.java @@ -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); @@ -40,13 +43,6 @@ public class Registry { private Map<String, Object> name2object = new ConcurrentHashMap<>(); /** - * Constructs the object. - */ - private Registry() { - super(); - } - - /** * Registers an object. * * @param name name by which the object is known diff --git a/utils/src/main/java/org/onap/policy/common/utils/services/ServiceManager.java b/utils/src/main/java/org/onap/policy/common/utils/services/ServiceManager.java index 78fe853b..1387462f 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/services/ServiceManager.java +++ b/utils/src/main/java/org/onap/policy/common/utils/services/ServiceManager.java @@ -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; - } } /* diff --git a/utils/src/main/java/org/onap/policy/common/utils/time/CurrentTime.java b/utils/src/main/java/org/onap/policy/common/utils/time/CurrentTime.java index 857b69b6..95f4d69a 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/time/CurrentTime.java +++ b/utils/src/main/java/org/onap/policy/common/utils/time/CurrentTime.java @@ -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,24 +21,18 @@ 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 */ diff --git a/utils/src/main/java/org/onap/policy/common/utils/validation/Assertions.java b/utils/src/main/java/org/onap/policy/common/utils/validation/Assertions.java index 047989e7..8e474204 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/validation/Assertions.java +++ b/utils/src/main/java/org/onap/policy/common/utils/validation/Assertions.java @@ -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,17 +31,12 @@ 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. * * @param parameterName the string parameter name diff --git a/utils/src/main/java/org/onap/policy/common/utils/validation/ParameterValidationUtils.java b/utils/src/main/java/org/onap/policy/common/utils/validation/ParameterValidationUtils.java index f15d936b..0723242d 100644 --- a/utils/src/main/java/org/onap/policy/common/utils/validation/ParameterValidationUtils.java +++ b/utils/src/main/java/org/onap/policy/common/utils/validation/ParameterValidationUtils.java @@ -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. @@ -21,17 +21,17 @@ 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. * diff --git a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java index 3b6e4955..18b39d26 100644 --- a/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java +++ b/utils/src/test/java/org/onap/policy/common/utils/jpa/EntityTransCloserTest.java @@ -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()); } } |