Added @Override method 27/14527/5
authorrama-huawei <rama.subba.reddy.s@huawei.com>
Fri, 22 Sep 2017 08:59:14 +0000 (14:29 +0530)
committerPamela Dragosh <pdragosh@research.att.com>
Fri, 22 Sep 2017 22:28:18 +0000 (22:28 +0000)
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>
policy-utils/src/main/java/org/onap/policy/drools/utils/OrderedServiceImpl.java
policy-utils/src/main/java/org/onap/policy/drools/utils/PropertyUtil.java
policy-utils/src/main/java/org/onap/policy/drools/utils/ReflectionUtil.java

index 88a5331..ee70a4b 100644 (file)
@@ -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;
   }
 }
index 9cfe2ed..84043d8 100644 (file)
@@ -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);
   }
 
   /**
index ba00c57..d300058 100644 (file)
@@ -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);
        }
 
 }