2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.sal.binding.api;
10 import static java.util.Objects.requireNonNull;
12 import java.io.Serializable;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.yangtools.concepts.Immutable;
16 import org.opendaylight.yangtools.concepts.Path;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
21 * A unique identifier for a particular subtree. It is composed of the logical
22 * data store type and the instance identifier of the root node.
24 * @deprecated Use {@link org.opendaylight.mdsal.binding.api.DataTreeIdentifier} instead.
26 @Deprecated(forRemoval = true)
27 public final class DataTreeIdentifier<T extends DataObject> implements Immutable,
28 Path<DataTreeIdentifier<?>>, Serializable {
29 private static final long serialVersionUID = 1L;
31 private final @NonNull InstanceIdentifier<T> rootIdentifier;
32 private final @NonNull LogicalDatastoreType datastoreType;
34 public DataTreeIdentifier(final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> rootIdentifier) {
35 this.datastoreType = requireNonNull(datastoreType);
36 this.rootIdentifier = requireNonNull(rootIdentifier);
40 * Return the logical data store type.
42 * @return Logical data store type. Guaranteed to be non-null.
44 public @NonNull LogicalDatastoreType getDatastoreType() {
49 * Return the {@link InstanceIdentifier} of the root node.
51 * @return Instance identifier corresponding to the root node.
53 public @NonNull InstanceIdentifier<T> getRootIdentifier() {
54 return rootIdentifier;
58 public boolean contains(final DataTreeIdentifier<?> other) {
59 return datastoreType == other.datastoreType && rootIdentifier.contains(other.rootIdentifier);
63 public int hashCode() {
66 result = prime * result + datastoreType.hashCode();
67 result = prime * result + rootIdentifier.hashCode();
72 public boolean equals(final Object obj) {
76 if (!(obj instanceof DataTreeIdentifier)) {
79 final DataTreeIdentifier<?> other = (DataTreeIdentifier<?>) obj;
80 if (datastoreType != other.datastoreType) {
83 return rootIdentifier.equals(other.rootIdentifier);
87 public String toString() {
88 return getClass().getSimpleName() + "{datastoreType = " + datastoreType + ", rootIdentifier = "
89 + rootIdentifier + "}";