diff options
author | rama-huawei <rama.subba.reddy.s@huawei.com> | 2017-09-22 14:29:14 +0530 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2017-09-22 22:28:18 +0000 |
commit | 9e7c10d65864e7fe95a6289f046b7c7e7b334b2e (patch) | |
tree | 5dd331d8edf1e5495a1c3a1d1f86381b6a037881 /policy-utils/src/main/java/org | |
parent | b9ddac6c072d7c00d61363efe2aaed9b37aa34d2 (diff) |
Added @Override method
Added diamond symbol on RHS
Removed useless parentheses
Issue-ID: POLICY-239
Change-Id: I1c3360a9c7242ff0ee23ab5599352d36bdf8ad9c
Signed-off-by: rama-huawei <rama.subba.reddy.s@huawei.com>
Diffstat (limited to 'policy-utils/src/main/java/org')
3 files changed, 24 insertions, 17 deletions
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/OrderedServiceImpl.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/OrderedServiceImpl.java index 88a53313..ee70a4b5 100644 --- a/policy-utils/src/main/java/org/onap/policy/drools/utils/OrderedServiceImpl.java +++ b/policy-utils/src/main/java/org/onap/policy/drools/utils/OrderedServiceImpl.java @@ -67,7 +67,7 @@ public class OrderedServiceImpl<T extends OrderedService> { rebuildList(); } - return(implementers); + return implementers; } /** @@ -85,7 +85,7 @@ public class OrderedServiceImpl<T extends OrderedService> public synchronized List<T> rebuildList() { // build a list of all of the current implementors - List<T> tmp = new LinkedList<T>(); + List<T> tmp = new LinkedList<>(); for (T service : serviceLoader) { tmp.add((T)getSingleton(service)); @@ -95,6 +95,7 @@ public class OrderedServiceImpl<T extends OrderedService> // according to full class name. Collections.sort(tmp, new Comparator<T>() { + @Override public int compare(T o1, T o2) { int s1 = o1.getSequenceNumber(); @@ -120,7 +121,7 @@ public class OrderedServiceImpl<T extends OrderedService> // create an unmodifiable version of this list implementers = Collections.unmodifiableList(tmp); logger.info("***** OrderedServiceImpl implementers:\n {}", implementers); - return(implementers); + return implementers; } // use this to ensure that we only use one unique instance of each class @@ -151,6 +152,6 @@ public class OrderedServiceImpl<T extends OrderedService> rval = service; classToSingleton.put(service.getClass(), service); } - return(rval); + return rval; } } 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 9cfe2ed1..84043d8f 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 @@ -56,7 +56,7 @@ public class PropertyUtil // load properties (may throw an IOException) rval.load(fis); - return(rval); + return rval; } finally { @@ -75,7 +75,7 @@ public class PropertyUtil */ static public Properties getProperties(String fileName) throws IOException { - return(getProperties(new File(fileName))); + return getProperties(new File(fileName)); } /* ============================================================ */ @@ -87,6 +87,7 @@ public class PropertyUtil * This is the callback interface, used for sending notifications of * changes in the properties file. */ + @FunctionalInterface public interface Listener { /** @@ -100,7 +101,7 @@ public class PropertyUtil // this table maps canonical file into a 'ListenerRegistration' instance static private HashMap<File, ListenerRegistration> registrations = - new HashMap<File, ListenerRegistration>(); + new HashMap<>(); /** * This is an internal class - one instance of this exists for each @@ -141,7 +142,7 @@ public class PropertyUtil properties = getProperties(file); // no listeners yet - listeners = new LinkedList<Listener>(); + listeners = new LinkedList<>(); // add to static table, so this instance can be shared registrations.put(file, this); @@ -163,6 +164,7 @@ public class PropertyUtil // create and schedule the timer task, so this is periodically polled timerTask = new TimerTask() { + @Override public void run() { try @@ -186,7 +188,7 @@ public class PropertyUtil synchronized Properties addListener(Listener listener) { listeners.add(listener); - return((Properties)properties.clone()); + return (Properties)properties.clone(); } /** @@ -203,7 +205,7 @@ public class PropertyUtil // one is being removed. synchronized(registrations) { - if (listeners.size() == 0) + if (listeners.isEmpty()) { timerTask.cancel(); registrations.remove(file); @@ -226,7 +228,7 @@ public class PropertyUtil // Save old set, and initial set of changed properties. Properties oldProperties = properties; HashSet<String> changedProperties = - new HashSet<String>(oldProperties.stringPropertyNames()); + new HashSet<>(oldProperties.stringPropertyNames()); // Fetch the list of listeners that we will potentially notify, // and the new properties. Note that this is in a 'synchronized' @@ -259,7 +261,7 @@ public class PropertyUtil } // 'changedProperties' should be correct at this point - if (changedProperties.size() != 0) + if (!changedProperties.isEmpty()) { // there were changes - notify everyone in 'listeners' for (final Listener notify : listeners) @@ -269,12 +271,13 @@ public class PropertyUtil final Properties tmpProperties = (Properties)(properties.clone()); final HashSet<String> tmpChangedProperties = - new HashSet<String>(changedProperties); + new HashSet<>(changedProperties); // Do the notification in a separate thread, so blocking // won't cause any problems. new Thread() { + @Override public void run() { notify.propertiesChanged @@ -309,7 +312,7 @@ public class PropertyUtil if (listener == null) { // no listener specified -- just fetch the properties - return(getProperties(file)); + return getProperties(file); } // Convert the file to a canonical form in order to avoid the situation @@ -327,7 +330,7 @@ public class PropertyUtil // a new registration is needed reg = new ListenerRegistration(file); } - return(reg.addListener(listener)); + return reg.addListener(listener); } } @@ -350,7 +353,7 @@ public class PropertyUtil static public Properties getProperties(String fileName, Listener listener) throws IOException { - return(getProperties(new File(fileName), listener)); + return getProperties(new File(fileName), listener); } /** 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 ba00c57e..d300058f 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 @@ -32,6 +32,9 @@ import org.slf4j.LoggerFactory; public class ReflectionUtil { protected final static Logger logger = LoggerFactory.getLogger(ReflectionUtil.class); + + private ReflectionUtil(){ + } /** * returns (if exists) a class fetched from a given classloader @@ -82,7 +85,7 @@ public class ReflectionUtil { * @return */ public static boolean isSubclass(Class<?> parent, Class<?> presumedSubclass) { - return (parent.isAssignableFrom(presumedSubclass)); + return parent.isAssignableFrom(presumedSubclass); } } |