yang-jmx-generator: use lambdas 89/57189/3
authorStephen Kitt <skitt@redhat.com>
Tue, 16 May 2017 15:49:19 +0000 (17:49 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 19 May 2017 08:25:57 +0000 (08:25 +0000)
This series of patches uses lambdas instead of anonymous classes for
functional interfaces when possible. Lambdas are replaced with method
references when appropriate.

Change-Id: Ica1ba9d37edbd25421b8fabac5cb1567608e1fb6
Signed-off-by: Stephen Kitt <skitt@redhat.com>
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/RuntimeBeanEntry.java

index 34e3c2e..d94c695 100644 (file)
@@ -64,19 +64,8 @@ import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
  */
 public class RuntimeBeanEntry {
 
-    private static final Function<SchemaNode, QName> QNAME_FROM_NODE = new Function<SchemaNode, QName>() {
-        @Override
-        public QName apply(final SchemaNode input) {
-            return input.getQName();
-        }
-    };
-
-    private static final Function<UnknownSchemaNode, String> UNKNOWN_NODE_TO_STRING = new Function<UnknownSchemaNode, String>() {
-        @Override
-        public String apply(final UnknownSchemaNode input) {
-            return input.getQName().getLocalName() + input.getNodeParameter();
-        }
-    };
+    private static final Function<UnknownSchemaNode, String> UNKNOWN_NODE_TO_STRING =
+            input -> input.getQName().getLocalName() + input.getNodeParameter();
 
     private final String packageName;
     private final String yangName, javaNamePrefix;
@@ -175,7 +164,8 @@ public class RuntimeBeanEntry {
         for (Module currentModule : schemaCtx.getModules()) {
 
             // Find all identities in current module for later identity->rpc mapping
-            Set<QName> allIdentitiesInModule = Sets.newHashSet(Collections2.transform(currentModule.getIdentities(), QNAME_FROM_NODE));
+            Set<QName> allIdentitiesInModule =
+                    Sets.newHashSet(Collections2.transform(currentModule.getIdentities(), SchemaNode::getQName));
 
             for (RpcDefinition rpc : currentModule.getRpcs()) {
                 ContainerSchemaNode input = rpc.getInput();
@@ -348,12 +338,8 @@ public class RuntimeBeanEntry {
     }
 
     private static Collection<DataSchemaNode> sortAttributes(final Collection<DataSchemaNode> childNodes) {
-        final TreeSet<DataSchemaNode> dataSchemaNodes = new TreeSet<>(new Comparator<DataSchemaNode>() {
-            @Override
-            public int compare(final DataSchemaNode o1, final DataSchemaNode o2) {
-                return o1.getQName().getLocalName().compareTo(o2.getQName().getLocalName());
-            }
-        });
+        final TreeSet<DataSchemaNode> dataSchemaNodes =
+                new TreeSet<>(Comparator.comparing(o -> o.getQName().getLocalName()));
         dataSchemaNodes.addAll(childNodes);
         return dataSchemaNodes;
     }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.