This interface does not bring anything to the table, remove it.
JIRA: MDSAL-843
Change-Id: Ia39a79fe08e06c6f6ec98f9324fcec1fee8d73e6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import org.opendaylight.mdsal.binding.api.DataTreeCommitCohort;
import org.opendaylight.mdsal.binding.api.DataTreeCommitCohortRegistry;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistration;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.DataObject;
final class BindingDOMDataTreeCommitCohortRegistryAdapter
extends AbstractBindingAdapter<DOMDataTreeCommitCohortRegistry> implements DataTreeCommitCohortRegistry {
-
BindingDOMDataTreeCommitCohortRegistryAdapter(final AdapterContext codec,
final DOMDataTreeCommitCohortRegistry registry) {
super(codec, registry);
@Override
public <D extends DataObject, T extends DataTreeCommitCohort<D>> ObjectRegistration<T> registerCommitCohort(
final DataTreeIdentifier<D> subtree, final T cohort) {
- final Class<D> target = subtree.getRootIdentifier().getTargetType();
-
- final BindingDOMDataTreeCommitCohortAdapter<D> adapter = new BindingDOMDataTreeCommitCohortAdapter<>(
- adapterContext(), cohort, Augmentation.class.isAssignableFrom(target) ? target : null);
- final DOMDataTreeIdentifier domPath = currentSerializer().toDOMDataTreeIdentifier(subtree);
- final DOMDataTreeCommitCohortRegistration<?> domReg = getDelegate().registerCommitCohort(domPath, adapter);
+ final var target = subtree.getRootIdentifier().getTargetType();
+ final var adapter = new BindingDOMDataTreeCommitCohortAdapter<>(adapterContext(), cohort,
+ Augmentation.class.isAssignableFrom(target) ? target : null);
+ final var domPath = currentSerializer().toDOMDataTreeIdentifier(subtree);
+ final var domReg = getDelegate().registerCommitCohort(domPath, adapter);
return new ObjectRegistration<>() {
-
@Override
public T getInstance() {
return cohort;
*/
package org.opendaylight.mdsal.binding.dom.adapter;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
import com.google.common.util.concurrent.MoreExecutors;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.mdsal.binding.api.DataTreeCommitCohort;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
import org.opendaylight.mdsal.binding.dom.adapter.test.util.BindingBrokerTestFactory;
-import org.opendaylight.mdsal.binding.dom.adapter.test.util.BindingTestContext;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistration;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.Top;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class BindingDOMDataTreeCommitCohortRegistryAdapterTest {
-
@Test
- public void basicTest() throws Exception {
- final BindingBrokerTestFactory bindingBrokerTestFactory = new BindingBrokerTestFactory();
+ void basicTest() {
+ final var bindingBrokerTestFactory = new BindingBrokerTestFactory();
bindingBrokerTestFactory.setExecutor(MoreExecutors.newDirectExecutorService());
- final BindingTestContext bindingTestContext = bindingBrokerTestFactory.getTestContext();
+ final var bindingTestContext = bindingBrokerTestFactory.getTestContext();
bindingTestContext.start();
- final DOMDataTreeCommitCohortRegistry cohortRegistry = mock(DOMDataTreeCommitCohortRegistry.class);
- final DOMDataTreeCommitCohortRegistration<?> cohortRegistration =
- mock(DOMDataTreeCommitCohortRegistration.class);
- doReturn(cohortRegistration).when(cohortRegistry)
- .registerCommitCohort(any(), any());
+ final var cohortRegistry = mock(DOMDataTreeCommitCohortRegistry.class);
+ final var cohortRegistration = mock(Registration.class);
+ doReturn(cohortRegistration).when(cohortRegistry).registerCommitCohort(any(), any());
doNothing().when(cohortRegistration).close();
- final BindingDOMDataTreeCommitCohortRegistryAdapter registryAdapter =
- new BindingDOMDataTreeCommitCohortRegistryAdapter(bindingTestContext.getCodec(), cohortRegistry);
+ final var registryAdapter = new BindingDOMDataTreeCommitCohortRegistryAdapter(bindingTestContext.getCodec(),
+ cohortRegistry);
- final DataTreeIdentifier<Top> dataTreeIdentifier = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
+ final var dataTreeIdentifier = DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
InstanceIdentifier.create(Top.class));
final DataTreeCommitCohort<Top> dataTreeCommitCohort = mock(DataTreeCommitCohort.class);
- final ObjectRegistration<?> objectRegistration =
- registryAdapter.registerCommitCohort(dataTreeIdentifier, dataTreeCommitCohort);
- assertEquals(dataTreeCommitCohort, objectRegistration.getInstance());
-
- objectRegistration.close();
+ try (var objectRegistration = registryAdapter.registerCommitCohort(dataTreeIdentifier, dataTreeCommitCohort)) {
+ assertSame(dataTreeCommitCohort, objectRegistration.getInstance());
+ }
verify(cohortRegistration).close();
}
}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2015 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.mdsal.dom.api;
-
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-
-/**
- * Registration of {@link DOMDataTreeCommitCohort}. Used to track and revoke registration with
- * {@link DOMDataTreeCommitCohortRegistry}.
- *
- * @param <T> Type of {@link DOMDataTreeCommitCohort}
- */
-public interface DOMDataTreeCommitCohortRegistration<T> extends ObjectRegistration<T> {
-
-}
*/
package org.opendaylight.mdsal.dom.api;
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.opendaylight.yangtools.concepts.Registration;
+
/**
* Commit Cohort registry for {@link DOMDataTreeWriteTransaction}. See {@link DOMDataTreeCommitCohort} for more details.
*/
+@NonNullByDefault
public interface DOMDataTreeCommitCohortRegistry extends DOMDataBroker.Extension {
/**
* Register commit cohort which will participate in three-phase commit protocols of
- * {@link DOMDataTreeWriteTransaction}in data broker associated with this instance of extension.
+ * {@link DOMDataTreeWriteTransaction} in data broker associated with this instance of extension.
*
* @param path Subtree path on which commit cohort operates.
* @param cohort Commit cohort
- * @param <T> Cohort subclass
- * @return Registaration object for DOM Data Three Commit cohort.
+ * @return A {@link Registration}
+ * @throws NullPointerException if any argument is {@code null}
*/
- <T extends DOMDataTreeCommitCohort> DOMDataTreeCommitCohortRegistration<T> registerCommitCohort(
- DOMDataTreeIdentifier path, T cohort);
+ Registration registerCommitCohort(DOMDataTreeIdentifier path, DOMDataTreeCommitCohort cohort);
}
\ No newline at end of file