yang-jmx-generator-plugin: use lambdas 90/57190/3
authorStephen Kitt <skitt@redhat.com>
Tue, 16 May 2017 15:49:08 +0000 (17:49 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 19 May 2017 08:24:45 +0000 (08:24 +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: Ic44563e54557fb678c23c7bd79121419303ef153
Signed-off-by: Stephen Kitt <skitt@redhat.com>
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/gofactory/AbsModuleGeneratedObjectFactory.java

index 7118405..b562a43 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.controller.config.yangjmxgenerator.plugin.gofactory;
 import static com.google.common.base.Preconditions.checkState;
 import static java.lang.String.format;
 
-import com.google.common.base.Function;
 import com.google.common.base.Joiner;
 import com.google.common.base.Optional;
 import com.google.common.collect.Collections2;
@@ -45,25 +44,21 @@ import org.slf4j.LoggerFactory;
 
 public class AbsModuleGeneratedObjectFactory {
 
-    private static final Function<String, FullyQualifiedName> FULLY_QUALIFIED_NAME_FUNCTION = new Function<String, FullyQualifiedName>() {
-        @Override
-        public FullyQualifiedName apply(final String input) {
-            return FullyQualifiedName.fromString(input);
-        }
-    };
-
     public GeneratedObject toGeneratedObject(ModuleMXBeanEntry mbe, Optional<String> copyright) {
         FullyQualifiedName abstractFQN = new FullyQualifiedName(mbe.getPackageName(), mbe.getAbstractModuleName());
         Optional<String> classJavaDoc = Optional.fromNullable(mbe.getNullableDescription());
         AbstractModuleTemplate abstractModuleTemplate = TemplateFactory.abstractModuleTemplateFromMbe(mbe);
         Optional<String> header = abstractModuleTemplate.getHeaderString();
 
-        List<FullyQualifiedName> implementedInterfaces = Lists.transform(abstractModuleTemplate.getTypeDeclaration().getImplemented(), FULLY_QUALIFIED_NAME_FUNCTION);
+        List<FullyQualifiedName> implementedInterfaces =
+                Lists.transform(abstractModuleTemplate.getTypeDeclaration().getImplemented(),
+                        FullyQualifiedName::fromString);
 
         Optional<FullyQualifiedName> extended =
                 Optional.fromNullable(
                         Iterables.getFirst(
-                                Collections2.transform(abstractModuleTemplate.getTypeDeclaration().getExtended(), FULLY_QUALIFIED_NAME_FUNCTION), null));
+                                Collections2.transform(abstractModuleTemplate.getTypeDeclaration().getExtended(),
+                                        FullyQualifiedName::fromString), null));
 
         Optional<FullyQualifiedName> maybeRegistratorType;
         if (abstractModuleTemplate.isRuntime()) {

©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.