Fix checkstyle issues to enforce it
[controller.git] / opendaylight / config / config-manager-facade-xml / src / main / java / org / opendaylight / controller / config / facade / xml / osgi / YangStoreService.java
index cd316611f6d4cb6736ba04a2a3374fe110777884..4eef7ee39eaeae9143214c45e343bf2f2e0a5a47 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2015, 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,
@@ -8,7 +8,6 @@
 
 package org.opendaylight.controller.config.facade.xml.osgi;
 
-import com.google.common.base.Function;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
@@ -36,24 +35,25 @@ public class YangStoreService implements YangStoreContext {
 
     private final SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
     private final ExecutorService notificationExecutor = Executors.newSingleThreadExecutor(
-        new ThreadFactoryBuilder().setDaemon(true).setNameFormat("yangstore-capability-notifications").build());
+            new ThreadFactoryBuilder().setDaemon(true).setNameFormat("yangstore-capability-notifications").build());
 
     /**
-     * Guarded by explicit lock to allow for properly synchronizing the initial notification and modification
-     * of the listener set.
+     * Guarded by explicit lock to allow for properly synchronizing the initial
+     * notification and modification of the listener set.
      */
     @GuardedBy("listeners")
     private final Set<ModuleListener> listeners = new HashSet<>();
 
     /**
-     * This is the latest snapshot. Some of its state is always initialized, but the MXBean maps potentially cause
-     * recomputation. Accessing those two specific methods needs to re-check whether the snapshot has changed
-     * asynchronously and retry if it didi.
+     * This is the latest snapshot. Some of its state is always initialized, but the
+     * MXBean maps potentially cause recomputation. Accessing those two specific
+     * methods needs to re-check whether the snapshot has changed asynchronously and
+     * retry if it didi.
      */
     private volatile YangStoreSnapshot snap;
 
     public YangStoreService(final SchemaContextProvider schemaContextProvider,
-        final SchemaSourceProvider<YangTextSchemaSource> sourceProvider) {
+            final SchemaSourceProvider<YangTextSchemaSource> sourceProvider) {
         this.sourceProvider = sourceProvider;
     }
 
@@ -107,12 +107,7 @@ public class YangStoreService implements YangStoreContext {
         final YangStoreSnapshot next = new YangStoreSnapshot(runtimeContext, this.sourceProvider);
         final YangStoreSnapshot previous = this.snap;
         this.snap = next;
-        this.notificationExecutor.submit(new Runnable() {
-            @Override
-            public void run() {
-                notifyListeners(previous, next);
-            }
-        });
+        this.notificationExecutor.submit(() -> notifyListeners(previous, next));
     }
 
     public AutoCloseable registerModuleListener(final ModuleListener listener) {
@@ -120,17 +115,15 @@ public class YangStoreService implements YangStoreContext {
 
         synchronized (this.listeners) {
             if (context != null) {
-                listener.onCapabilitiesChanged(toCapabilities(context.getModules(), context), Collections.<Capability>emptySet());
+                listener.onCapabilitiesChanged(toCapabilities(context.getModules(), context),
+                        Collections.<Capability>emptySet());
             }
             this.listeners.add(listener);
         }
 
-        return new AutoCloseable() {
-            @Override
-            public void close() {
-                synchronized (YangStoreService.this.listeners) {
-                    YangStoreService.this.listeners.remove(listener);
-                }
+        return () -> {
+            synchronized (YangStoreService.this.listeners) {
+                YangStoreService.this.listeners.remove(listener);
             }
         };
     }
@@ -152,11 +145,7 @@ public class YangStoreService implements YangStoreContext {
     }
 
     private static Set<Capability> toCapabilities(final Set<Module> modules, final YangStoreContext current) {
-        return ImmutableSet.copyOf(Collections2.transform(modules, new Function<Module, Capability>() {
-            @Override
-            public Capability apply(final Module input) {
-                return new YangModuleCapability(input, current.getModuleSource(input));
-            }
-        }));
+        return ImmutableSet.copyOf(Collections2.transform(modules,
+            input -> new YangModuleCapability(input, current.getModuleSource(input))));
     }
 }