Merge topic 'checkstyle'
authorTony Tkacik <ttkacik@cisco.com>
Mon, 15 Dec 2014 11:43:59 +0000 (11:43 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 15 Dec 2014 11:43:59 +0000 (11:43 +0000)
* changes:
  Fix checkstyle if-statements must use braces northbound/commons
  Fix checkstyle if-statements must use braces hosttracker_new
  Fix checkstyle simplify boolean expression config-api

opendaylight/adsal/hosttracker_new/api/src/main/java/org/opendaylight/controller/hosttracker/Entity.java
opendaylight/adsal/hosttracker_new/api/src/main/java/org/opendaylight/controller/hosttracker/SwitchPort.java
opendaylight/adsal/hosttracker_new/api/src/main/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnector.java
opendaylight/adsal/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/IteratableTypeInfo.java
opendaylight/adsal/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryContextImpl.java
opendaylight/adsal/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/QueryImpl.java
opendaylight/adsal/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/TypeInfo.java
opendaylight/adsal/northbound/commons/src/main/java/org/opendaylight/controller/northbound/commons/query/WrapperTypeInfo.java
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/JmxAttributeValidationException.java
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtil.java

index 64f4c7ef1e1d65bddcafd7310dccfe6b44278741..f10c116755d06f3f4abedc1900e01a38449a6ace 100644 (file)
@@ -165,8 +165,9 @@ public class Entity implements Comparable<Entity> {
     public void setLastSeenTimestamp(Date lastSeenTimestamp) {
         if (activeSince == null
                 || (activeSince.getTime() + ACTIVITY_TIMEOUT) < lastSeenTimestamp
-                        .getTime())
+                        .getTime()) {
             this.activeSince = lastSeenTimestamp;
+        }
         this.lastSeenTimestamp = lastSeenTimestamp;
     }
 
@@ -180,8 +181,9 @@ public class Entity implements Comparable<Entity> {
 
     @Override
     public int hashCode() {
-        if (hashCode != 0)
+        if (hashCode != 0) {
             return hashCode;
+        }
         final int prime = 31;
         hashCode = 1;
         hashCode = prime * hashCode
@@ -194,30 +196,40 @@ public class Entity implements Comparable<Entity> {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         Entity other = (Entity) obj;
         if (ipv4Address == null) {
-            if (other.ipv4Address != null)
+            if (other.ipv4Address != null) {
                 return false;
-        } else if (!ipv4Address.equals(other.ipv4Address))
+            }
+        } else if (!ipv4Address.equals(other.ipv4Address)) {
             return false;
-        if (macAddress != other.macAddress)
+        }
+        if (macAddress != other.macAddress) {
             return false;
+        }
         if (port == null) {
-            if (other.port != null)
+            if (other.port != null) {
                 return false;
-        } else if (!port.equals(other.port))
+            }
+        } else if (!port.equals(other.port)) {
             return false;
+        }
         if (vlan == null) {
-            if (other.vlan != null)
+            if (other.vlan != null) {
                 return false;
-        } else if (!vlan.equals(other.vlan))
+            }
+        } else if (!vlan.equals(other.vlan)) {
             return false;
+        }
         return true;
     }
 
@@ -257,8 +269,9 @@ public class Entity implements Comparable<Entity> {
             Comparable switchId = (Comparable) port.getNode().getID();
             Comparable oswitchId = (Comparable) o.port.getNode().getID();
             r = switchId.compareTo(oswitchId);
-            if (r != 0)
+            if (r != 0) {
                 return r;
+            }
 
             Comparable portId = (Comparable) port.getID();
             Comparable oportId = (Comparable) o.port.getID();
index e60f8b4b0efe8dc84142750adbf76b8620859fe3..892e1d6c79296cdd2463702c5d7bfeab9405d1ee 100644 (file)
@@ -127,20 +127,26 @@ public class SwitchPort {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         SwitchPort other = (SwitchPort) obj;
-        if (errorStatus != other.errorStatus)
+        if (errorStatus != other.errorStatus) {
             return false;
+        }
         if (port == null) {
-            if (other.port != null)
+            if (other.port != null) {
                 return false;
-        } else if (!port.equals(other.port))
+            }
+        } else if (!port.equals(other.port)) {
             return false;
+        }
         return true;
     }
 
index fe396ba92b4fe448f83290500ef936fc4ef1a869..86376be5c55fb7c07be637afbe198e000542f253 100644 (file)
@@ -150,22 +150,29 @@ public class HostNodeConnector extends Host {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (!super.equals(obj))
+        }
+        if (!super.equals(obj)) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         HostNodeConnector other = (HostNodeConnector) obj;
         if (nodeConnector == null) {
-            if (other.nodeConnector != null)
+            if (other.nodeConnector != null) {
                 return false;
-        } else if (!nodeConnector.equals(other.nodeConnector))
+            }
+        } else if (!nodeConnector.equals(other.nodeConnector)) {
             return false;
-        if (staticHost != other.staticHost)
+        }
+        if (staticHost != other.staticHost) {
             return false;
-        if (vlan != other.vlan)
+        }
+        if (vlan != other.vlan) {
             return false;
+        }
         return true;
     }
 
@@ -181,8 +188,9 @@ public class HostNodeConnector extends Host {
             EthernetAddress e = (EthernetAddress) getDataLayerAddress();
             macaddr = e.getValue();
         }
-        if (macaddr == null)
+        if (macaddr == null) {
             return false;
+        }
         return !Arrays.equals(emptyArray, macaddr);
     }
 
index 3977837c7faa38cb6423287e8b0fc7d8b6b34acf..d0386ed2c585aae9ee96128b140124e0b1dd923f 100644 (file)
@@ -29,7 +29,9 @@ import java.util.List;
             Object item = it.next();
             for (TypeInfo child : _types.values()) {
                 Object val = child.retrieve(item, query, index);
-                if (val != null) objects.add(val);
+                if (val != null) {
+                    objects.add(val);
+                }
             }
         }
         return objects;
@@ -38,7 +40,9 @@ import java.util.List;
 
     @Override
     public synchronized void explore() {
-        if (_explored) return;
+        if (_explored) {
+            return;
+        }
         if (LOGGER.isDebugEnabled()) {
             LOGGER.debug("exploring iteratable type: {} gtype: {}", _class,
                     _accessor.getGenericType());
index 13d70b1cb01efe930c0db042e10d97d753429fe0..8f83c147c8d405de04f7e343cd1db72874ea5991 100644 (file)
@@ -16,17 +16,25 @@ import org.slf4j.LoggerFactory;
 
     @Override
     public <T> Query<T> createQuery(String queryString, Class<T> type) throws QueryException {
-        if (queryString == null || queryString.trim().length() == 0) return null;
+        if (queryString == null || queryString.trim().length() == 0) {
+            return null;
+        }
         try {
-            if (LOGGER.isDebugEnabled()) LOGGER.debug("Processing query: {}", queryString);
+            if (LOGGER.isDebugEnabled()) {
+                LOGGER.debug("Processing query: {}", queryString);
+            }
             // FiqlParser is a parser generated by javacc
             Expression expression = FiqlParser.parse(queryString);
-            if (LOGGER.isDebugEnabled()) LOGGER.debug("Query expression: {}", expression);
+            if (LOGGER.isDebugEnabled()) {
+                LOGGER.debug("Query expression: {}", expression);
+            }
             // create Query and return;
             return new QueryImpl<T>(type, expression);
         } catch (Exception ex) {
-            if (LOGGER.isDebugEnabled()) LOGGER.error("Query processing failed = {}",
+            if (LOGGER.isDebugEnabled()) {
+                LOGGER.error("Query processing failed = {}",
                     queryString, ex);
+            }
             throw new QueryException("Unable to parse query.", ex);
         }
     }
index a520f98fc0642fcae707ca0fe5faec8e7c158868..cb77e04a59074a7da020a6c52c4372b137f3471e 100644 (file)
@@ -158,7 +158,9 @@ import org.slf4j.LoggerFactory;
     }
 
     private boolean compare(Object valueToMatch, Object actualValue, OP operator) {
-        if (valueToMatch == null || actualValue == null) return false;
+        if (valueToMatch == null || actualValue == null) {
+            return false;
+        }
         if (ALLOW_OBJECT_STRING_COMPARE && (valueToMatch instanceof String)
                 && !(actualValue instanceof String)) {
             actualValue = actualValue.toString();
@@ -203,7 +205,9 @@ import org.slf4j.LoggerFactory;
         }
     }
     private Object parse(String arg, Object value) {
-        if (value == null) return null;
+        if (value == null) {
+            return null;
+        }
 
         try {
             if (value instanceof String) {
index 91f01d8ad76ac1b023055612fd292146c57d5e5a..6c0c5dc816c6c1279dea19553cdc72e62fa5cf18 100644 (file)
@@ -107,7 +107,9 @@ import org.slf4j.LoggerFactory;
         if (LOGGER.isDebugEnabled()) {
             LOGGER.debug("retrieve: {}/{} type:{}", index, query.length, target.getClass());
         }
-        if (index >= query.length) return null;
+        if (index >= query.length) {
+            return null;
+        }
         explore();
         if (!target.getClass().equals(_class)) {
             if (_class.isAssignableFrom(target.getClass())) {
@@ -124,7 +126,9 @@ import org.slf4j.LoggerFactory;
             }
         }
         TypeInfo child = getChild(query[index]);
-        if (child == null) return null;
+        if (child == null) {
+            return null;
+        }
         target = child.getAccessor().getValue(target);
         if (index+1 == query.length) {
             // match found
@@ -137,27 +141,35 @@ import org.slf4j.LoggerFactory;
      * Explore the type info for children.
      */
     public synchronized void explore() {
-        if (_explored) return;
+        if (_explored) {
+            return;
+        }
         for (Class<?> c = _class; c != null; c = c.getSuperclass()) {
-            if (c.equals(Object.class)) break;
+            if (c.equals(Object.class)) {
+                break;
+            }
             // Currently only fields and methods annotated with JAXB annotations are
             // considered as valid for search purposes.
             //check methods first
             for (Method m : c.getDeclaredMethods()) {
                 String tn = getTypeName(m, _accessType);
                 if (tn != null) {
-                    if (LOGGER.isDebugEnabled()) LOGGER.debug(
+                    if (LOGGER.isDebugEnabled()) {
+                        LOGGER.debug(
                             "exploring type: {} name: {} method: {}",
                             _class.getSimpleName(), tn, m);
+                    }
                     _types.put(tn, createTypeInfo(tn, new Accessor(m)));
                 }
             }
             for (Field f : c.getDeclaredFields()) {
                 String tn = getTypeName(f, _accessType);
                 if (tn != null) {
-                    if (LOGGER.isDebugEnabled()) LOGGER.debug(
+                    if (LOGGER.isDebugEnabled()) {
+                        LOGGER.debug(
                             "exploring type: {} name: {} field: {}",
                             _class.getSimpleName(), tn, f);
+                    }
                     _types.put(tn, createTypeInfo(tn, new Accessor(f)));
                 }
             }
@@ -219,7 +231,9 @@ import org.slf4j.LoggerFactory;
             PropertyDescriptor[] props = info.getPropertyDescriptors();
             for (PropertyDescriptor pd : props)
             {
-                if (m.equals(pd.getReadMethod())) return pd.getName();
+                if (m.equals(pd.getReadMethod())) {
+                    return pd.getName();
+                }
             }
         }
         catch (IntrospectionException e)
@@ -234,8 +248,12 @@ import org.slf4j.LoggerFactory;
         // root is always a composite type
         // FIXME assert its a JAXB type
         XmlRootElement root = clz.getAnnotation(XmlRootElement.class);
-        if (root == null) throw new IllegalArgumentException("Not a JAXB type: " + clz);
-        if (name == null) name = getRootName(clz);
+        if (root == null) {
+            throw new IllegalArgumentException("Not a JAXB type: " + clz);
+        }
+        if (name == null) {
+            name = getRootName(clz);
+        }
         return new TypeInfo(name, clz, null);
     }
 
@@ -252,7 +270,9 @@ import org.slf4j.LoggerFactory;
 
     public static String getRootName(Class<?> cls) {
         XmlRootElement root = cls.getAnnotation(XmlRootElement.class);
-        if (root == null) return null;
+        if (root == null) {
+            return null;
+        }
         String rootName = root.name();
         if (DEFAULT_NAME.equals(rootName)) {
             String clsName = cls.getSimpleName();
@@ -281,7 +301,9 @@ import org.slf4j.LoggerFactory;
                 return null;
             }
         }
-        if (DEFAULT_NAME.equals(name)) return dflt;
+        if (DEFAULT_NAME.equals(name)) {
+            return dflt;
+        }
         return name;
     }
 
index a8172f2adda2b2ec5554c52e21a1e5d9ac7c5bae..156942c61d79447ce8f00da4a97f3f35ec1be57f 100644 (file)
@@ -24,10 +24,14 @@ public class WrapperTypeInfo extends TypeInfo {
         if (LOGGER.isDebugEnabled()) {
             LOGGER.debug("retrieve collection: {}/{}", index, query.length);
         }
-        if (index >= query.length) return null;
+        if (index >= query.length) {
+            return null;
+        }
         explore();
         TypeInfo child = getChild(query[index]);
-        if (child == null) return null;
+        if (child == null) {
+            return null;
+        }
         if (query.length == index+1) { // skipping this node
             return target;
         }else { // if list of list go to next node to get value
@@ -37,7 +41,9 @@ public class WrapperTypeInfo extends TypeInfo {
 
     @Override
     public synchronized void explore() {
-        if (_explored) return;
+        if (_explored) {
+            return;
+        }
         if (LOGGER.isDebugEnabled()) {
             LOGGER.debug("exploring wrapper type: {} gtype: {}", _class,
                     _accessor.getGenericType());
index 3380a10afe38d6aa71b20566223a989c91cdfe68..b09017fe55d1c3ddcff118c0cd21353ea6aa542f 100644 (file)
@@ -84,7 +84,7 @@ public class JmxAttributeValidationException extends RuntimeException {
 
     public static void checkCondition(boolean condition, String message,
             JmxAttribute jmxAttribute) throws JmxAttributeValidationException {
-        if (condition == false) {
+        if (!condition) {
             throw new JmxAttributeValidationException(
                     jmxAttribute.getAttributeName() + " " + message,
                     jmxAttribute);
index ee23206eebf35fba353d82581f3513e5ffb7f808..0c7478dca0f1008955bcc03c60cd17d3bb309287 100644 (file)
@@ -128,7 +128,7 @@ public class ObjectNameUtil {
         if (quoted == null) {
             throw new IllegalArgumentException("Cannot find " + SERVICE_QNAME_KEY + " in " + objectName);
         }
-        if (quoted.startsWith("\"") == false || quoted.endsWith("\"") == false) {
+        if (!quoted.startsWith("\"") || !quoted.endsWith("\"")) {
             throw new IllegalArgumentException("Quotes not found in " + objectName);
         }
         String substring = quoted.substring(1);
@@ -201,7 +201,7 @@ public class ObjectNameUtil {
             throw new IllegalArgumentException(
                     "Expected ObjectName with transaction:" + inputON);
         }
-        if (ON_DOMAIN.equals(inputON.getDomain()) == false) {
+        if (!ON_DOMAIN.equals(inputON.getDomain())) {
             throw new IllegalArgumentException("Expected different domain: "
                     + inputON);
         }
@@ -263,7 +263,7 @@ public class ObjectNameUtil {
         Map<String, String> allProperties = getAdditionalProperties(on);
         Map<String, String> result = new HashMap<>();
         for (Entry<String, String> entry : allProperties.entrySet()) {
-            if (blacklist.contains(entry.getKey()) == false) {
+            if (!blacklist.contains(entry.getKey())) {
                 result.put(entry.getKey(), entry.getValue());
             }
         }