/*
* 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.controller.md.sal.dom.api;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import java.io.Serializable;
import java.util.Iterator;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.concepts.Path;
/**
* A unique identifier for a particular subtree. It is composed of the logical
* data store type and the instance identifier of the root node.
+ *
+ * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier} instead.
*/
-public final class DOMDataTreeIdentifier implements Immutable, Path<DOMDataTreeIdentifier>, Serializable, Comparable<DOMDataTreeIdentifier> {
+@Deprecated(forRemoval = true)
+public final class DOMDataTreeIdentifier implements Immutable,
+ Path<DOMDataTreeIdentifier>, Serializable, Comparable<DOMDataTreeIdentifier> {
private static final long serialVersionUID = 1L;
- private final YangInstanceIdentifier rootIdentifier;
- private final LogicalDatastoreType datastoreType;
+ private final @NonNull YangInstanceIdentifier rootIdentifier;
+ private final @NonNull LogicalDatastoreType datastoreType;
+
+ public DOMDataTreeIdentifier(final LogicalDatastoreType datastoreType,
+ final YangInstanceIdentifier rootIdentifier) {
+ this.datastoreType = requireNonNull(datastoreType);
+ this.rootIdentifier = requireNonNull(rootIdentifier);
+ }
- public DOMDataTreeIdentifier(final LogicalDatastoreType datastoreType, final YangInstanceIdentifier rootIdentifier) {
- this.datastoreType = Preconditions.checkNotNull(datastoreType);
- this.rootIdentifier = Preconditions.checkNotNull(rootIdentifier);
+ /**
+ * Return a counterpart to an MD-SAL data tree identifier.
+ *
+ * @return Controller data tree identifier.
+ */
+ public static DOMDataTreeIdentifier fromMdsal(final org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier mdsal) {
+ return new DOMDataTreeIdentifier(LogicalDatastoreType.fromMdsal(mdsal.getDatastoreType()),
+ mdsal.getRootIdentifier());
+ }
+
+ /**
+ * Return MD-SAL counterpart of this object.
+ *
+ * @return MD-SAL data tree identifier.
+ */
+ public org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier toMdsal() {
+ return new org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier(datastoreType.toMdsal(), rootIdentifier);
}
/**
*
* @return Logical data store type. Guaranteed to be non-null.
*/
- public @Nonnull LogicalDatastoreType getDatastoreType() {
+ public @NonNull LogicalDatastoreType getDatastoreType() {
return datastoreType;
}
*
* @return Instance identifier corresponding to the root node.
*/
- public @Nonnull YangInstanceIdentifier getRootIdentifier() {
+ public @NonNull YangInstanceIdentifier getRootIdentifier() {
return rootIdentifier;
}
}
@Override
- public int compareTo(final DOMDataTreeIdentifier o) {
- int i = datastoreType.compareTo(o.datastoreType);
- if (i != 0) {
- return i;
+ public int compareTo(final DOMDataTreeIdentifier obj) {
+ int cmp = datastoreType.compareTo(obj.datastoreType);
+ if (cmp != 0) {
+ return cmp;
}
final Iterator<PathArgument> mi = rootIdentifier.getPathArguments().iterator();
- final Iterator<PathArgument> oi = o.rootIdentifier.getPathArguments().iterator();
+ final Iterator<PathArgument> oi = obj.rootIdentifier.getPathArguments().iterator();
while (mi.hasNext()) {
if (!oi.hasNext()) {
final PathArgument ma = mi.next();
final PathArgument oa = oi.next();
- i = ma.compareTo(oa);
- if (i != 0) {
- return i;
+ cmp = ma.compareTo(oa);
+ if (cmp != 0) {
+ return cmp;
}
}