*/
package org.opendaylight.mdsal.binding.api;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-
import com.google.common.base.Preconditions;
import java.io.Serializable;
import javax.annotation.Nonnull;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.concepts.Path;
import org.opendaylight.yangtools.yang.binding.DataObject;
private final InstanceIdentifier<T> rootIdentifier;
private final LogicalDatastoreType datastoreType;
- public DataTreeIdentifier(final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> rootIdentifier) {
+ private DataTreeIdentifier(final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> rootIdentifier) {
this.datastoreType = Preconditions.checkNotNull(datastoreType);
this.rootIdentifier = Preconditions.checkNotNull(rootIdentifier);
}
+ public static <T extends DataObject> DataTreeIdentifier<T> create(final LogicalDatastoreType datastoreType,
+ final InstanceIdentifier<T> rootIdentifier) {
+ return new DataTreeIdentifier<>(datastoreType, rootIdentifier);
+ }
+
/**
* Return the logical data store type.
*
for (final Entry<DOMDataTreeIdentifier, NormalizedNode<?, ?>> domEntry : domSubtrees.entrySet()) {
final Entry<InstanceIdentifier<?>, DataObject> bindingEntry =
codec.fromNormalizedNode(domEntry.getKey().getRootIdentifier(), domEntry.getValue());
- ret.put(new DataTreeIdentifier<>(store, bindingEntry.getKey()), bindingEntry.getValue());
+ ret.put(DataTreeIdentifier.create(store, bindingEntry.getKey()), bindingEntry.getValue());
}
return ret;
}
private final DataObjectModification<T> rootNode;
LazyDataTreeModification(final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> path, final BindingCodecTreeNode<T> codec, final DataTreeCandidate domChange) {
- this.path = new DataTreeIdentifier<>(datastoreType, path);
+ this.path = DataTreeIdentifier.create(datastoreType, path);
this.rootNode = LazyDataObjectModification.create(codec, domChange.getRootNode());
}
private static final InstanceIdentifier<TopLevelList> BAR_PATH = path(TOP_BAR_KEY);
private static final PathArgument BAR_ARGUMENT = Iterables.getLast(BAR_PATH.getPathArguments());
private static final TopLevelList BAR_DATA = topLevelList(TOP_BAR_KEY);
-private static final DataTreeIdentifier<Top> TOP_IDENTIFIER = new DataTreeIdentifier<Top>(LogicalDatastoreType.OPERATIONAL,
+ private static final DataTreeIdentifier<Top> TOP_IDENTIFIER = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
TOP_PATH);
private static final Top TOP_INITIAL_DATA = top(FOO_DATA);
@Test
public void testWildcardedListListener() throws Exception {
final EventCapturingListener<TopLevelList> listener = new EventCapturingListener<>();
- final DataTreeIdentifier<TopLevelList> wildcard = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, TOP_PATH.child(TopLevelList.class));
+ final DataTreeIdentifier<TopLevelList> wildcard = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, TOP_PATH.child(TopLevelList.class));
dataBrokerImpl.registerDataTreeChangeListener(wildcard, listener);
putTx(TOP_PATH, TOP_INITIAL_DATA).submit().checkedGet();