Fix checkstyle issues to enforce it
[controller.git] / opendaylight / config / config-manager-facade-xml / src / main / java / org / opendaylight / controller / config / facade / xml / runtime / InstanceRuntime.java
index 96287c7d165050bab1e8800c7a9c2849c5d434d6..c0532317d83df389e01b7af3d657cdaa36dd9ae1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -9,7 +9,6 @@
 package org.opendaylight.controller.config.facade.xml.runtime;
 
 import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.Sets;
 import java.util.Map;
@@ -24,9 +23,6 @@ import org.w3c.dom.Element;
 
 public class InstanceRuntime {
 
-    /**
-     *
-     */
     private static final String KEY_ATTRIBUTE_KEY = "key";
 
     private final InstanceConfig instanceMapping;
@@ -41,56 +37,49 @@ public class InstanceRuntime {
     }
 
     /**
-     * Finds all children runtime beans, same properties and values as current
-     * root + any number of additional properties
+     * Finds all children runtime beans, same properties and values as current root
+     * + any number of additional properties.
      */
     private Set<ObjectName> findChildren(ObjectName innerRootBean, Set<ObjectName> childRbeOns) {
         final Map<String, String> wantedProperties = innerRootBean.getKeyPropertyList();
 
-        return Sets.newHashSet(Collections2.filter(childRbeOns, new Predicate<ObjectName>() {
-
-            @Override
-            public boolean apply(ObjectName on) {
-                Map<String, String> localProperties = on.getKeyPropertyList();
-                for (Entry<String, String> propertyEntry : wantedProperties.entrySet()) {
-                    if (!localProperties.containsKey(propertyEntry.getKey())){
-                        return false;
-                    }
-                    if (!localProperties.get(propertyEntry.getKey()).equals(propertyEntry.getValue())){
-                        return false;
-                    }
-                    if (localProperties.size() <= wantedProperties.size()){
-                        return false;
-                    }
+        return Sets.newHashSet(Collections2.filter(childRbeOns, on -> {
+            Map<String, String> localProperties = on.getKeyPropertyList();
+            for (Entry<String, String> propertyEntry : wantedProperties.entrySet()) {
+                if (!localProperties.containsKey(propertyEntry.getKey())) {
+                    return false;
+                }
+                if (!localProperties.get(propertyEntry.getKey()).equals(propertyEntry.getValue())) {
+                    return false;
+                }
+                if (localProperties.size() <= wantedProperties.size()) {
+                    return false;
                 }
-                return true;
             }
+            return true;
         }));
     }
 
     /**
-     * Finds next level root runtime beans, beans that have the same properties
-     * as current root + one additional
+     * Finds next level root runtime beans, beans that have the same properties as
+     * current root + one additional.
      */
     private Set<ObjectName> getRootBeans(Set<ObjectName> childRbeOns, final String string, final int keyListSize) {
-        return Sets.newHashSet(Collections2.filter(childRbeOns, new Predicate<ObjectName>() {
-
-            @Override
-            public boolean apply(ObjectName on) {
-                if (on.getKeyPropertyList().size() != keyListSize + 1){
-                    return false;
-                }
-                return on.getKeyPropertyList().containsKey(string);
+        return Sets.newHashSet(Collections2.filter(childRbeOns, on -> {
+            if (on.getKeyPropertyList().size() != keyListSize + 1) {
+                return false;
             }
+            return on.getKeyPropertyList().containsKey(string);
         }));
     }
 
-    public Element toXml(ObjectName rootOn, Set<ObjectName> childRbeOns, Document document, Element parentElement, String namespace, final EnumResolver enumResolver) {
+    public Element toXml(ObjectName rootOn, Set<ObjectName> childRbeOns, Document document, Element parentElement,
+            String namespace, final EnumResolver enumResolver) {
         return toXml(rootOn, childRbeOns, document, null, parentElement, namespace, enumResolver);
     }
 
     public Element toXml(ObjectName rootOn, Set<ObjectName> childRbeOns, Document document, String instanceIndex,
-                         Element parentElement, String namespace, final EnumResolver enumResolver) {
+            Element parentElement, String namespace, final EnumResolver enumResolver) {
         Element xml = instanceMapping.toXml(rootOn, namespace, document, parentElement, enumResolver);
 
         if (instanceIndex != null) {
@@ -98,8 +87,8 @@ public class InstanceRuntime {
         }
 
         for (Entry<String, InstanceRuntime> childMappingEntry : childrenMappings.entrySet()) {
-            Set<ObjectName> innerRootBeans = getRootBeans(childRbeOns, childMappingEntry.getKey(), rootOn
-                    .getKeyPropertyList().size());
+            Set<ObjectName> innerRootBeans = getRootBeans(childRbeOns, childMappingEntry.getKey(),
+                    rootOn.getKeyPropertyList().size());
 
             for (ObjectName objectName : innerRootBeans) {
                 Set<ObjectName> innerChildRbeOns = findChildren(objectName, childRbeOns);
@@ -108,13 +97,11 @@ public class InstanceRuntime {
                 String elementName = jmxToYangChildRbeMapping.get(childMappingEntry.getKey());
 
                 Element innerXml = XmlUtil.createElement(document, elementName, Optional.of(namespace));
-                childMappingEntry.getValue().toXml(objectName, innerChildRbeOns, document,
-                        runtimeInstanceIndex, innerXml, namespace, enumResolver);
+                childMappingEntry.getValue().toXml(objectName, innerChildRbeOns, document, runtimeInstanceIndex,
+                        innerXml, namespace, enumResolver);
                 xml.appendChild(innerXml);
             }
         }
-
         return xml;
     }
-
 }