Clean up (DOM)DataTreeIdentifier methods
[mdsal.git] / common / mdsal-common-api / src / main / java / org / opendaylight / mdsal / common / api / LogicalDatastorePath.java
diff --git a/common/mdsal-common-api/src/main/java/org/opendaylight/mdsal/common/api/LogicalDatastorePath.java b/common/mdsal-common-api/src/main/java/org/opendaylight/mdsal/common/api/LogicalDatastorePath.java
new file mode 100644 (file)
index 0000000..13538ad
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2023 PANTHEON.tech, s.r.o. 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.mdsal.common.api;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.opendaylight.yangtools.concepts.HierarchicalIdentifier;
+
+/**
+ * A path to a subtree within a particular datastore.
+ */
+@NonNullByDefault
+public interface LogicalDatastorePath<T extends LogicalDatastorePath<T, P>, P extends HierarchicalIdentifier<P>>
+        extends HierarchicalIdentifier<T> {
+    /**
+     * Return the {@link LogicalDatastoreType}.
+     *
+     * @return the {@link LogicalDatastoreType}
+     */
+    LogicalDatastoreType datastore();
+
+    /**
+     * Return the absolute path.
+     *
+     * @return the absolute path
+     */
+    P path();
+
+    @Override
+    default boolean contains(final T other) {
+        return datastore() == other.datastore() && path().contains(other.path());
+    }
+}