/*
- * 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,
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;
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;
}
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) {
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);
}
};
}
}
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))));
}
}