import java.util.HashSet;
import java.util.Set;
+import java.util.stream.Collectors;
import org.opendaylight.yangtools.yang.binding.Notification;
-import com.google.common.base.Predicate;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Multimap;
/**
private static Iterable<Class<?>> getNotificationTypes(final Class<?> cls) {
final Class<?>[] ifaces = cls.getInterfaces();
- return Iterables.filter(Arrays.asList(ifaces), new Predicate<Class<?>>() {
- @Override
- public boolean apply(final Class<?> input) {
- if (Notification.class.equals(input)) {
- return false;
- }
- return Notification.class.isAssignableFrom(input);
- }
- });
+ return Arrays.stream(ifaces)
+ .filter(input -> !Notification.class.equals(input) && Notification.class.isAssignableFrom(input))
+ .collect(Collectors.toList());
}
}
\ No newline at end of file
public class BindingDOMDataBrokerAdapter extends AbstractForwardedDataBroker implements DataBroker, DataTreeChangeService {
- static final Factory<DataBroker> BUILDER_FACTORY = () -> new Builder();
+ static final Factory<DataBroker> BUILDER_FACTORY = Builder::new;
private final DataTreeChangeService treeChangeService;
public BindingDOMDataBrokerAdapter(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec) {
public class BindingDOMNotificationPublishServiceAdapter implements NotificationPublishService, AutoCloseable {
- static final Factory<NotificationPublishService> BUILDER_FACTORY = new BindingDOMAdapterBuilder.Factory<NotificationPublishService>() {
-
- @Override
- public BindingDOMAdapterBuilder<NotificationPublishService> newBuilder() {
- return new Builder();
- }
-
- };
+ static final Factory<NotificationPublishService> BUILDER_FACTORY = Builder::new;
private final BindingToNormalizedNodeCodec codecRegistry;
private final DOMNotificationPublishService domPublishService;
public class BindingDOMNotificationServiceAdapter implements NotificationService, AutoCloseable {
- public static final Factory<NotificationService> BUILDER_FACTORY = new Factory<NotificationService>() {
-
- @Override
- public BindingDOMAdapterBuilder<NotificationService> newBuilder() {
- return new Builder();
- }
-
- };
+ public static final Factory<NotificationService> BUILDER_FACTORY = Builder::new;
private final BindingNormalizedNodeSerializer codec;
private final DOMNotificationService domNotifService;
public class BindingDOMRpcServiceAdapter implements RpcConsumerRegistry {
- protected static final Factory<RpcConsumerRegistry> BUILDER_FACTORY = new Factory<RpcConsumerRegistry>() {
-
- @Override
- public BindingDOMAdapterBuilder<RpcConsumerRegistry> newBuilder() {
- return new Builder();
- }
-
- };
+ protected static final Factory<RpcConsumerRegistry> BUILDER_FACTORY = Builder::new;
private final LoadingCache<Class<? extends RpcService>, RpcServiceAdapter> proxies = CacheBuilder.newBuilder()
.weakKeys()
private static ListenableFuture<RpcResult<?>> transformFuture(final SchemaPath rpc,
final ListenableFuture<DOMRpcResult> domFuture, final BindingNormalizedNodeSerializer codec) {
- return Futures.transform(domFuture, new Function<DOMRpcResult, RpcResult<?>>() {
- @Override
- public RpcResult<?> apply(final DOMRpcResult input) {
- final NormalizedNode<?, ?> domData = input.getResult();
- final DataObject bindingResult;
- if (domData != null) {
- final SchemaPath rpcOutput = rpc.createChild(QName.create(rpc.getLastComponent(), "output"));
- bindingResult = codec.fromNormalizedNodeRpcData(rpcOutput, (ContainerNode) domData);
- } else {
- bindingResult = null;
- }
- return RpcResult.class.cast(RpcResultBuilder.success(bindingResult).build());
+ return Futures.transform(domFuture, (Function<DOMRpcResult, RpcResult<?>>) input -> {
+ final NormalizedNode<?, ?> domData = input.getResult();
+ final DataObject bindingResult;
+ if (domData != null) {
+ final SchemaPath rpcOutput = rpc.createChild(QName.create(rpc.getLastComponent(), "output"));
+ bindingResult = codec.fromNormalizedNodeRpcData(rpcOutput, (ContainerNode) domData);
+ } else {
+ bindingResult = null;
}
+ return RpcResult.class.cast(RpcResultBuilder.success(bindingResult).build());
});
}
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
final ThreadPoolExecutor executor = new ThreadPoolExecutor(CORE_NOTIFICATION_THREADS, MAX_NOTIFICATION_THREADS,
NOTIFICATION_THREAD_LIFE, TimeUnit.SECONDS, queue, factory,
- new RejectedExecutionHandler() {
- // if the max threads are met, then it will raise a rejectedExecution. We then push to the queue.
- @Override
- public void rejectedExecution(final Runnable r, final ThreadPoolExecutor executor) {
- try {
- executor.getQueue().put(r);
- } catch (final InterruptedException e) {
- throw new RejectedExecutionException("Interrupted while waiting on the queue", e);
- }
- }
- });
+ // if the max threads are met, then it will raise a rejectedExecution. We then push to the queue.
+ (r, executor1) -> {
+ try {
+ executor1.getQueue().put(r);
+ } catch (final InterruptedException e) {
+ throw new RejectedExecutionException("Interrupted while waiting on the queue", e);
+ }
+ });
NOTIFICATION_EXECUTOR = MoreExecutors.listeningDecorator(executor);
}
final CountDownLatch done = new CountDownLatch(1);
final AtomicReference<YangInstanceIdentifier> yangId = new AtomicReference<>();
final AtomicReference<RuntimeException> error = new AtomicReference<>();
- new Thread() {
- @Override
- public void run() {
- try {
- yangId.set(BindingNormalizedCodecTest.this.codec.toYangInstanceIdentifierBlocking(BA_TOP_LEVEL_LIST));
- } catch(final RuntimeException e) {
- error.set(e);
- } finally {
- done.countDown();
- }
+ new Thread(() -> {
+ try {
+ yangId.set(BindingNormalizedCodecTest.this.codec.toYangInstanceIdentifierBlocking(BA_TOP_LEVEL_LIST));
+ } catch(final RuntimeException e) {
+ error.set(e);
+ } finally {
+ done.countDown();
}
- }.start();
+ }).start();
Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
this.codec.onGlobalContextUpdated(this.context);
final CountDownLatch done = new CountDownLatch(1);
final AtomicReference<ImmutableBiMap<Method, SchemaPath>> retMap = new AtomicReference<>();
final AtomicReference<RuntimeException> error = new AtomicReference<>();
- new Thread() {
- @Override
- public void run() {
- try {
- retMap.set(BindingNormalizedCodecTest.this.codec.getRpcMethodToSchemaPath(OpendaylightTestRpcServiceService.class));
- } catch(final RuntimeException e) {
- error.set(e);
- } finally {
- done.countDown();
- }
+ new Thread(() -> {
+ try {
+ retMap.set(BindingNormalizedCodecTest.this.codec.getRpcMethodToSchemaPath(OpendaylightTestRpcServiceService.class));
+ } catch(final RuntimeException e) {
+ error.set(e);
+ } finally {
+ done.countDown();
}
- }.start();
+ }).start();
Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
this.codec.onGlobalContextUpdated(this.context);
@Override
protected SchemaContext getSchemaContext() throws Exception {
- return SchemaContextSingleton.getSchemaContext(() -> super.getSchemaContext());
+ return SchemaContextSingleton.getSchemaContext(super::getSchemaContext);
}
}