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: I3ed4fecf12d64254a3f3ec701ea22037e52149cc
Signed-off-by: Stephen Kitt <skitt@redhat.com>
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataStore.class);
private static final Invoker<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent> DCL_NOTIFICATION_MGR_INVOKER =
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataStore.class);
private static final Invoker<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent> DCL_NOTIFICATION_MGR_INVOKER =
- new Invoker<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent>() {
- @Override
- public void invokeListener(final DataChangeListenerRegistration<?> listener,
- final DOMImmutableDataChangeEvent notification ) {
- final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> inst = listener.getInstance();
- if (inst != null) {
- inst.onDataChanged(notification);
- }
+ (listener, notification) -> {
+ final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> inst = listener.getInstance();
+ if (inst != null) {
+ inst.onDataChanged(notification);
final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher {
private static final Invoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> MANAGER_INVOKER =
final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher {
private static final Invoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> MANAGER_INVOKER =
- new Invoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>() {
- @Override
- public void invokeListener(final AbstractDOMDataTreeChangeListenerRegistration<?> listener, final DataTreeCandidate notification) {
- // FIXME: this is inefficient, as we could grab the entire queue for the listener and post it
- final DOMDataTreeChangeListener inst = listener.getInstance();
- if (inst != null) {
- inst.onDataTreeChanged(Collections.singletonList(notification));
- }
+ (listener, notification) -> {
+ // FIXME: this is inefficient, as we could grab the entire queue for the listener and post it
+ final DOMDataTreeChangeListener inst = listener.getInstance();
+ if (inst != null) {
+ inst.onDataTreeChanged(Collections.singletonList(notification));
}
};
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMStoreTreeChangePublisher.class);
}
};
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMStoreTreeChangePublisher.class);
public static final WriteTransactionCustomizer simpleWrite(final YangInstanceIdentifier path,
final NormalizedNode<?, ?> data) {
public static final WriteTransactionCustomizer simpleWrite(final YangInstanceIdentifier path,
final NormalizedNode<?, ?> data) {
- return new WriteTransactionCustomizer() {
-
- @Override
- public void customize(final DOMStoreReadWriteTransaction tx) {
- tx.write(path, data);
- }
- };
+ return tx -> tx.write(path, data);
}
public static final WriteTransactionCustomizer simpleMerge(final YangInstanceIdentifier path,
final NormalizedNode<?, ?> data) {
}
public static final WriteTransactionCustomizer simpleMerge(final YangInstanceIdentifier path,
final NormalizedNode<?, ?> data) {
- return new WriteTransactionCustomizer() {
-
- @Override
- public void customize(final DOMStoreReadWriteTransaction tx) {
- tx.merge(path, data);
- }
- };
+ return tx -> tx.merge(path, data);
}
public static final WriteTransactionCustomizer simpleDelete(final YangInstanceIdentifier path) {
}
public static final WriteTransactionCustomizer simpleDelete(final YangInstanceIdentifier path) {
- return new WriteTransactionCustomizer() {
- @Override
- public void customize(final DOMStoreReadWriteTransaction tx) {
- tx.delete(path);
- }
- };
+ return tx -> tx.delete(path);
import java.util.concurrent.ExecutionException;
import org.junit.Test;
import java.util.concurrent.ExecutionException;
import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.WriteTransactionCustomizer;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
/**
* Base template for a test suite for testing DataChangeListener functionality.
/**
* Base template for a test suite for testing DataChangeListener functionality.
@Test
public final void existingTopWriteSibling() throws Exception {
DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
@Test
public final void existingTopWriteSibling() throws Exception {
DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
- new WriteTransactionCustomizer() {
- @Override
- public void customize(final DOMStoreReadWriteTransaction tx) {
- tx.write(path(FOO_SIBLING), topLevelList(FOO_SIBLING).build());
- }
- });
+ tx -> tx.write(path(FOO_SIBLING), topLevelList(FOO_SIBLING).build()));
customizeTask(task);
task.run();
existingTopWriteSibling(task);
customizeTask(task);
task.run();
existingTopWriteSibling(task);
@Test
public final void existingTopWriteTwoNested() throws Exception {
DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
@Test
public final void existingTopWriteTwoNested() throws Exception {
DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
- new WriteTransactionCustomizer() {
- @Override
- public void customize(final DOMStoreReadWriteTransaction tx) {
- tx.write(path(FOO,BAR), nestedList(BAR).build());
- tx.write(path(FOO,BAZ), nestedList(BAZ).build());
- }
+ tx -> {
+ tx.write(path(FOO,BAR), nestedList(BAR).build());
+ tx.write(path(FOO,BAZ), nestedList(BAZ).build());
});
customizeTask(task);
task.run();
});
customizeTask(task);
task.run();
@Test
public final void existingOneNestedWriteAdditionalNested() throws Exception {
DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
@Test
public final void existingOneNestedWriteAdditionalNested() throws Exception {
DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
- new WriteTransactionCustomizer() {
- @Override
- public void customize(final DOMStoreReadWriteTransaction tx) {
- tx.write(path(FOO,BAZ), nestedList(BAZ).build());
- }
- });
+ tx -> tx.write(path(FOO,BAZ), nestedList(BAZ).build()));
customizeTask(task);
task.run();
existingOneNestedWriteAdditionalNested(task);
customizeTask(task);
task.run();
existingOneNestedWriteAdditionalNested(task);