*/
package org.opendaylight.mdsal.binding.api;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-
+import com.google.common.base.MoreObjects;
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;
* A unique identifier for a particular subtree. It is composed of the logical
* data store type and the instance identifier of the root node.
*/
-public final class DataTreeIdentifier<T extends DataObject> implements Immutable, Path<DataTreeIdentifier<?>>, Serializable {
+public final class DataTreeIdentifier<T extends DataObject> implements Immutable,
+ Path<DataTreeIdentifier<?>>, Serializable {
private static final long serialVersionUID = 1L;
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.
*
* @return Logical data store type. Guaranteed to be non-null.
*/
- public @Nonnull LogicalDatastoreType getDatastoreType() {
+ @Nonnull
+ public LogicalDatastoreType getDatastoreType() {
return datastoreType;
}
*
* @return Instance identifier corresponding to the root node.
*/
- public @Nonnull InstanceIdentifier<T> getRootIdentifier() {
+ @Nonnull
+ public InstanceIdentifier<T> getRootIdentifier() {
return rootIdentifier;
}
}
return rootIdentifier.equals(other.rootIdentifier);
}
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this).add("datastore", datastoreType).add("root", rootIdentifier).toString();
+ }
}
\ No newline at end of file