2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
3 * This program and the accompanying materials are made available under the
4 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
5 * and is available at http://www.eclipse.org/legal/epl-v10.html
7 package org.opendaylight.controller.md.sal.dom.api;
9 import com.google.common.base.Preconditions;
10 import java.io.Serializable;
11 import javax.annotation.Nonnull;
12 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
13 import org.opendaylight.yangtools.concepts.Immutable;
14 import org.opendaylight.yangtools.concepts.Path;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18 * A unique identifier for a particular subtree. It is composed of the logical
19 * data store type and the instance identifier of the root node.
21 public final class DOMDataTreeIdentifier implements Immutable, Path<DOMDataTreeIdentifier>, Serializable {
22 private static final long serialVersionUID = 1L;
23 private final YangInstanceIdentifier rootIdentifier;
24 private final LogicalDatastoreType datastoreType;
26 public DOMDataTreeIdentifier(final LogicalDatastoreType datastoreType, final YangInstanceIdentifier rootIdentifier) {
27 this.datastoreType = Preconditions.checkNotNull(datastoreType);
28 this.rootIdentifier = Preconditions.checkNotNull(rootIdentifier);
32 * Return the logical data store type.
34 * @return Logical data store type. Guaranteed to be non-null.
36 public @Nonnull LogicalDatastoreType getDatastoreType() {
41 * Return the {@link YangInstanceIdentifier} of the root node.
43 * @return Instance identifier corresponding to the root node.
45 public @Nonnull YangInstanceIdentifier getRootIdentifier() {
46 return rootIdentifier;
50 public boolean contains(final DOMDataTreeIdentifier other) {
51 return datastoreType == other.datastoreType && rootIdentifier.contains(other.rootIdentifier);
55 public int hashCode() {
58 result = prime * result + datastoreType.hashCode();
59 result = prime * result + rootIdentifier.hashCode();
64 public boolean equals(final Object obj) {
68 if (!(obj instanceof DOMDataTreeIdentifier)) {
71 DOMDataTreeIdentifier other = (DOMDataTreeIdentifier) obj;
72 if (datastoreType != other.datastoreType) {
75 return rootIdentifier.equals(other.rootIdentifier);