diff options
author | Jim Hahn <jrh3@att.com> | 2021-08-05 10:13:01 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-08-05 11:18:36 -0400 |
commit | 1744dac574fb771301027be74c9257eb070125f7 (patch) | |
tree | b35035a120a2fb5d99114091c89ed8dbfa57cd22 /policy-utils/src/main | |
parent | 43cb6711bbc9b231e904ff3ef5266f0f0df3faec (diff) |
Use lombok in drools-pdp
Updated policy-management thru policy-utils.
Issue-ID: POLICY-3397
Change-Id: Ie9498fe912e8338ddc32a40774c3cb63d84f079a
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-utils/src/main')
7 files changed, 40 insertions, 52 deletions
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/CryptoCoderValueLookup.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/CryptoCoderValueLookup.java index 9d4a8824..8120abd3 100644 --- a/policy-utils/src/main/java/org/onap/policy/drools/utils/CryptoCoderValueLookup.java +++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/CryptoCoderValueLookup.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * 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,7 @@ package org.onap.policy.drools.utils; +import lombok.AllArgsConstructor; import org.apache.commons.configuration2.interpol.Lookup; import org.apache.commons.lang3.StringUtils; import org.onap.policy.common.utils.security.CryptoCoder; @@ -27,19 +28,11 @@ import org.onap.policy.common.utils.security.CryptoCoder; /** * Crypto Coder value look up. Syntax: ${enc:encoded-value}. */ +@AllArgsConstructor public class CryptoCoderValueLookup implements Lookup { protected final CryptoCoder cryptoCoder; - /** - * Crypto Coder Lookup. - * - * @param crypto crypto coder - */ - public CryptoCoderValueLookup(CryptoCoder crypto) { - this.cryptoCoder = crypto; - } - @Override public String lookup(String key) { if (StringUtils.isBlank(key)) { diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/PropertyUtil.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/PropertyUtil.java index 10871e72..0e6c1ec0 100644 --- a/policy-utils/src/main/java/org/onap/policy/drools/utils/PropertyUtil.java +++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/PropertyUtil.java @@ -31,6 +31,8 @@ import java.util.Set; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.atomic.AtomicReference; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.apache.commons.configuration2.ConfigurationConverter; import org.apache.commons.configuration2.SystemConfiguration; import org.onap.policy.common.utils.security.CryptoCoder; @@ -41,7 +43,8 @@ import org.slf4j.LoggerFactory; * This class provides utilities to read properties from a properties * file, and optionally get notifications of future changes. */ -public class PropertyUtil { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class PropertyUtil { public static final String ENV_WITH_DEFAULT_PROPERTY_PREFIX = "envd"; public static final String CRYPTO_CODER_PROPERTY_PREFIX = "enc"; diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/Reference.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/Reference.java index 7755177e..c21fe316 100644 --- a/policy-utils/src/main/java/org/onap/policy/drools/utils/Reference.java +++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/Reference.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * 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,27 +20,21 @@ package org.onap.policy.drools.utils; +import lombok.AllArgsConstructor; + /** * Reference to an object. Used within functional methods, where thread-safety is not * required. - * + * * @param <T> type of object contained within the reference */ +@AllArgsConstructor public class Reference<T> { private T value; /** - * Constructor. - * - * @param value value - */ - public Reference(T value) { - this.value = value; - } - - /** * Get the value. - * + * * @return the current value */ public final T get() { @@ -49,7 +43,7 @@ public class Reference<T> { /** * Sets the reference to point to a new value. - * + * * @param newValue the new value */ public final void set(T newValue) { @@ -58,7 +52,7 @@ public class Reference<T> { /** * Sets the value to a new value, if the value is currently the same as the old value. - * + * * @param oldValue old value * @param newValue new value * @return {@code true} if the value was updated, {@code false} otherwise diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java index bb6c5428..8afc1e1e 100644 --- a/policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java +++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * policy-utils * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-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,6 +20,8 @@ package org.onap.policy.drools.utils; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,22 +29,20 @@ import org.slf4j.LoggerFactory; * Reflection utilities. * */ -public class ReflectionUtil { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class ReflectionUtil { protected static final Logger logger = LoggerFactory.getLogger(ReflectionUtil.class); - private ReflectionUtil() { - } - /** * returns (if exists) a class fetched from a given classloader. - * + * * @param classLoader the class loader * @param className the class name * @return the actual class * @throws IllegalArgumentException if an invalid parameter has been passed in */ - public static Class<?> fetchClass(ClassLoader classLoader, + public static Class<?> fetchClass(ClassLoader classLoader, String className) { if (classLoader == null) { throw new IllegalArgumentException("A class loader must be provided"); @@ -64,7 +64,7 @@ public class ReflectionUtil { /** * Is class. - * + * * @param classLoader target class loader * @param classname class name to fetch * @return true if exists @@ -76,7 +76,7 @@ public class ReflectionUtil { /** * Is it a sub class. - * + * * @param parent superclass * @param presumedSubclass subclass * @return true if it is a sub class diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerMarkerFilter.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerMarkerFilter.java index b116592c..7468b523 100644 --- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerMarkerFilter.java +++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerMarkerFilter.java @@ -23,20 +23,19 @@ package org.onap.policy.drools.utils.logging; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.filter.AbstractMatcherFilter; import ch.qos.logback.core.spi.FilterReply; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; import org.slf4j.Marker; /** * Logger Marker Filters to be used in logback.xml configuration * to accept/deny metric or transaction (audit) events */ +@AllArgsConstructor(access = AccessLevel.PROTECTED) public abstract class LoggerMarkerFilter extends AbstractMatcherFilter<ILoggingEvent> { protected final Marker marker; - protected LoggerMarkerFilter(Marker marker) { - this.marker = marker; - } - @Override public FilterReply decide(ILoggingEvent event) { diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java index e3f565d2..eef0fa3d 100644 --- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java +++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/LoggerUtil.java @@ -21,6 +21,8 @@ package org.onap.policy.drools.utils.logging; import ch.qos.logback.classic.LoggerContext; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.Marker; @@ -29,7 +31,8 @@ import org.slf4j.MarkerFactory; /** * Loger Utils. */ -public class LoggerUtil { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class LoggerUtil { private static final Logger LOGGER = LoggerFactory.getLogger(LoggerUtil.class); @@ -68,10 +71,6 @@ public class LoggerUtil { */ public static final Marker TRANSACTION_LOG_MARKER = MarkerFactory.getMarker(TRANSACTION_LOG_MARKER_NAME); - private LoggerUtil() { - // Empty constructor - } - /** * Set the log level of a logger. * diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java index 1c98eacd..1db498fc 100644 --- a/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java +++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/logging/MdcTransactionConstants.java @@ -19,7 +19,11 @@ package org.onap.policy.drools.utils.logging; -public class MdcTransactionConstants { +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class MdcTransactionConstants { /* * The fields must match the naming given at * https://wiki.onap.org/pages/viewpage.action?pageId=20087036 @@ -170,8 +174,4 @@ public class MdcTransactionConstants { * Status Code Error. */ public static final String STATUS_CODE_FAILURE = "ERROR"; - - private MdcTransactionConstants() { - // do nothing - } } |